You are here

private function XMLSecurityKey::decryptMcrypt in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

Decrypts the given data (string) using the mcrypt-extension

Parameters

string $data:

Return value

string

1 call to XMLSecurityKey::decryptMcrypt()
XMLSecurityKey::decryptData in src/XMLSecurityKey.php
Decrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

File

src/XMLSecurityKey.php, line 396

Class

XMLSecurityKey

Namespace

Drupal\miniorange_saml

Code

private function decryptMcrypt($data) {
  $td = mcrypt_module_open($this->cryptParams['cipher'], '', $this->cryptParams['mode'], '');
  $iv_length = mcrypt_enc_get_iv_size($td);
  $this->iv = substr($data, 0, $iv_length);
  $data = substr($data, $iv_length);
  mcrypt_generic_init($td, $this->key, $this->iv);
  $decrypted_data = mdecrypt_generic($td, $data);
  mcrypt_generic_deinit($td);
  mcrypt_module_close($td);
  if ($this->cryptParams['mode'] == MCRYPT_MODE_CBC) {
    $dataLen = strlen($decrypted_data);
    $paddingLength = substr($decrypted_data, $dataLen - 1, 1);
    $decrypted_data = substr($decrypted_data, 0, $dataLen - ord($paddingLength));
  }
  return $decrypted_data;
}