Skip to content
Snippets Groups Projects
Commit a38bf33d authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utils_Crypto to SimpleSAML\Utils\Crypto.

parent 2548d57b
Branches
Tags
No related merge requests found
...@@ -44,4 +44,4 @@ if(!in_array(strtolower($algo), hash_algos())) { ...@@ -44,4 +44,4 @@ if(!in_array(strtolower($algo), hash_algos())) {
echo "Do you want to use a salt? (yes/no) [yes] "; echo "Do you want to use a salt? (yes/no) [yes] ";
$s = (trim(fgets(STDIN)) == 'no') ? '' : 'S'; $s = (trim(fgets(STDIN)) == 'no') ? '' : 'S';
echo "\n " . SimpleSAML_Utils_Crypto::pwHash($password, strtoupper( $s . $algo ) ). "\n\n"; echo "\n " . SimpleSAML\Utils\Crypto::pwHash($password, strtoupper( $s . $algo ) ). "\n\n";
...@@ -29,8 +29,8 @@ class SimpleSAML_Bindings_Shib13_HTTPPost { ...@@ -29,8 +29,8 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
SimpleSAML_Utilities::validateXMLDocument($response, 'saml11'); SimpleSAML_Utilities::validateXMLDocument($response, 'saml11');
$privatekey = SimpleSAML_Utils_Crypto::loadPrivateKey($idpmd, TRUE); $privatekey = SimpleSAML\Utils\Crypto::loadPrivateKey($idpmd, TRUE);
$publickey = SimpleSAML_Utils_Crypto::loadPublicKey($idpmd, TRUE); $publickey = SimpleSAML\Utils\Crypto::loadPublicKey($idpmd, TRUE);
$responsedom = new DOMDocument(); $responsedom = new DOMDocument();
$responsedom->loadXML(str_replace ("\r", "", $response)); $responsedom->loadXML(str_replace ("\r", "", $response));
......
...@@ -1020,18 +1020,18 @@ class SimpleSAML_Utilities { ...@@ -1020,18 +1020,18 @@ class SimpleSAML_Utilities {
/** /**
* @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML_Utils_Crypto::loadPublicKey() instead. * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::loadPublicKey() instead.
*/ */
public static function loadPublicKey(SimpleSAML_Configuration $metadata, $required = FALSE, $prefix = '') { public static function loadPublicKey(SimpleSAML_Configuration $metadata, $required = FALSE, $prefix = '') {
return SimpleSAML_Utils_Crypto::loadPublicKey($metadata, $required, $prefix); return SimpleSAML\Utils\Crypto::loadPublicKey($metadata, $required, $prefix);
} }
/** /**
* @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML_Utils_Crypto::loadPrivateKey() instead. * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::loadPrivateKey() instead.
*/ */
public static function loadPrivateKey(SimpleSAML_Configuration $metadata, $required = FALSE, $prefix = '') { public static function loadPrivateKey(SimpleSAML_Configuration $metadata, $required = FALSE, $prefix = '') {
return SimpleSAML_Utils_Crypto::loadPrivateKey($metadata, $required, $prefix); return SimpleSAML\Utils\Crypto::loadPrivateKey($metadata, $required, $prefix);
} }
...@@ -1163,7 +1163,7 @@ class SimpleSAML_Utilities { ...@@ -1163,7 +1163,7 @@ class SimpleSAML_Utilities {
$session = SimpleSAML_Session::getSessionFromRequest(); $session = SimpleSAML_Session::getSessionFromRequest();
$session->setData('core_postdatalink', $postId, $postData); $session->setData('core_postdatalink', $postId, $postData);
$redirInfo = base64_encode(SimpleSAML_Utils_Crypto::aesEncrypt($session->getSessionId() . ':' . $postId)); $redirInfo = base64_encode(SimpleSAML\Utils\Crypto::aesEncrypt($session->getSessionId() . ':' . $postId));
$url = SimpleSAML_Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $redirInfo)); $url = SimpleSAML_Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $redirInfo));
$url = preg_replace("#^https:#", "http:", $url); $url = preg_replace("#^https:#", "http:", $url);
...@@ -1571,18 +1571,18 @@ class SimpleSAML_Utilities { ...@@ -1571,18 +1571,18 @@ class SimpleSAML_Utilities {
/** /**
* @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML_Utils_Crypto::aesEncrypt() instead. * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::aesEncrypt() instead.
*/ */
public static function aesEncrypt($clear) { public static function aesEncrypt($clear) {
return SimpleSAML_Utils_Crypto::aesEncrypt($clear); return SimpleSAML\Utils\Crypto::aesEncrypt($clear);
} }
/** /**
* @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML_Utils_Crypto::aesDecrypt() instead. * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::aesDecrypt() instead.
*/ */
public static function aesDecrypt($encData) { public static function aesDecrypt($encData) {
return SimpleSAML_Utils_Crypto::aesDecrypt($encData); return SimpleSAML\Utils\Crypto::aesDecrypt($encData);
} }
......
<?php <?php
namespace SimpleSAML\Utils;
/** /**
...@@ -6,26 +7,26 @@ ...@@ -6,26 +7,26 @@
* *
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
class SimpleSAML_Utils_Crypto class Crypto
{ {
/** /**
* Decrypt data using AES and the system-wide secret salt as key. * Decrypt data using AES and the system-wide secret salt as key.
* *
* @param string $data The encrypted data to decrypt. * @param string $ciphertext The encrypted data to decrypt.
* *
* @return string The decrypted data. * @return string The decrypted data.
* @throws SimpleSAML_Error_Exception If the mcrypt module is not loaded or $ciphertext is not a string. * @throws \SimpleSAML_Error_Exception If the mcrypt module is not loaded or $ciphertext is not a string.
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/ */
public static function aesDecrypt($ciphertext) public static function aesDecrypt($ciphertext)
{ {
if (!is_string($ciphertext)) { if (!is_string($ciphertext)) {
throw new SimpleSAML_Error_Exception('Input parameter "$ciphertext" must be a string.'); throw new \SimpleSAML_Error_Exception('Input parameter "$ciphertext" must be a string.');
} }
if (!function_exists("mcrypt_encrypt")) { if (!function_exists("mcrypt_encrypt")) {
throw new SimpleSAML_Error_Exception("The mcrypt PHP module is not loaded."); throw new \SimpleSAML_Error_Exception("The mcrypt PHP module is not loaded.");
} }
$enc = MCRYPT_RIJNDAEL_256; $enc = MCRYPT_RIJNDAEL_256;
...@@ -34,7 +35,7 @@ class SimpleSAML_Utils_Crypto ...@@ -34,7 +35,7 @@ class SimpleSAML_Utils_Crypto
$ivSize = mcrypt_get_iv_size($enc, $mode); $ivSize = mcrypt_get_iv_size($enc, $mode);
$keySize = mcrypt_get_key_size($enc, $mode); $keySize = mcrypt_get_key_size($enc, $mode);
$key = hash('sha256', SimpleSAML\Utils\Config::getSecretSalt(), true); $key = hash('sha256', Config::getSecretSalt(), true);
$key = substr($key, 0, $keySize); $key = substr($key, 0, $keySize);
$iv = substr($ciphertext, 0, $ivSize); $iv = substr($ciphertext, 0, $ivSize);
...@@ -55,17 +56,17 @@ class SimpleSAML_Utils_Crypto ...@@ -55,17 +56,17 @@ class SimpleSAML_Utils_Crypto
* @param string $data The data to encrypt. * @param string $data The data to encrypt.
* *
* @return string The encrypted data and IV. * @return string The encrypted data and IV.
* @throws SimpleSAML_Error_Exception If the mcrypt module is not loaded or $data is not a string. * @throws \SimpleSAML_Error_Exception If the mcrypt module is not loaded or $data is not a string.
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/ */
public static function aesEncrypt($data) public static function aesEncrypt($data)
{ {
if (!is_string($data)) { if (!is_string($data)) {
throw new SimpleSAML_Error_Exception('Input parameter "$data" must be a string.'); throw new \SimpleSAML_Error_Exception('Input parameter "$data" must be a string.');
} }
if (!function_exists("mcrypt_encrypt")) { if (!function_exists("mcrypt_encrypt")) {
throw new SimpleSAML_Error_Exception('The mcrypt PHP module is not loaded.'); throw new \SimpleSAML_Error_Exception('The mcrypt PHP module is not loaded.');
} }
$enc = MCRYPT_RIJNDAEL_256; $enc = MCRYPT_RIJNDAEL_256;
...@@ -75,7 +76,7 @@ class SimpleSAML_Utils_Crypto ...@@ -75,7 +76,7 @@ class SimpleSAML_Utils_Crypto
$ivSize = mcrypt_get_iv_size($enc, $mode); $ivSize = mcrypt_get_iv_size($enc, $mode);
$keySize = mcrypt_get_key_size($enc, $mode); $keySize = mcrypt_get_key_size($enc, $mode);
$key = hash('sha256', SimpleSAML\Utils\Config::getSecretSalt(), true); $key = hash('sha256', Config::getSecretSalt(), true);
$key = substr($key, 0, $keySize); $key = substr($key, 0, $keySize);
$len = strlen($data); $len = strlen($data);
...@@ -101,38 +102,38 @@ class SimpleSAML_Utils_Crypto ...@@ -101,38 +102,38 @@ class SimpleSAML_Utils_Crypto
* - 'PEM': Data for the private key, in PEM-format. * - 'PEM': Data for the private key, in PEM-format.
* - 'password': Password for the private key. * - 'password': Password for the private key.
* *
* @param SimpleSAML_Configuration $metadata The metadata array the private key should be loaded from. * @param \SimpleSAML_Configuration $metadata The metadata array the private key should be loaded from.
* @param bool $required Whether the private key is required. If this is true, a * @param bool $required Whether the private key is required. If this is true, a
* missing key will cause an exception. Defaults to false. * missing key will cause an exception. Defaults to false.
* @param string $prefix The prefix which should be used when reading from the metadata * @param string $prefix The prefix which should be used when reading from the metadata
* array. Defaults to ''. * array. Defaults to ''.
* *
* @return array|NULL Extracted private key, or NULL if no private key is present. * @return array|NULL Extracted private key, or NULL if no private key is present.
* @throws SimpleSAML_Error_Exception If no private key is found in the metadata, or it was not possible to load it. * @throws \SimpleSAML_Error_Exception If no private key is found in the metadata, or it was not possible to load it.
* *
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
*/ */
public static function loadPrivateKey(SimpleSAML_Configuration $metadata, $required = false, $prefix = '') public static function loadPrivateKey(\SimpleSAML_Configuration $metadata, $required = false, $prefix = '')
{ {
if (!is_bool($required) || !is_string($prefix)) { if (!is_bool($required) || !is_string($prefix)) {
throw new SimpleSAML_Error_Exception('Invalid input parameters.'); throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
} }
$file = $metadata->getString($prefix.'privatekey', null); $file = $metadata->getString($prefix.'privatekey', null);
if ($file === null) { if ($file === null) {
// no private key found // no private key found
if ($required) { if ($required) {
throw new SimpleSAML_Error_Exception('No private key found in metadata.'); throw new \SimpleSAML_Error_Exception('No private key found in metadata.');
} else { } else {
return null; return null;
} }
} }
$file = SimpleSAML_Utilities::resolveCert($file); $file = \SimpleSAML_Utilities::resolveCert($file);
$data = @file_get_contents($file); $data = @file_get_contents($file);
if ($data === false) { if ($data === false) {
throw new SimpleSAML_Error_Exception('Unable to load private key from file "'.$file.'"'); throw new \SimpleSAML_Error_Exception('Unable to load private key from file "'.$file.'"');
} }
$ret = array( $ret = array(
...@@ -162,7 +163,7 @@ class SimpleSAML_Utils_Crypto ...@@ -162,7 +163,7 @@ class SimpleSAML_Utils_Crypto
* - 'certData': The certificate data, base64 encoded, on a single line. (Only present if this is a certificate.) * - 'certData': The certificate data, base64 encoded, on a single line. (Only present if this is a certificate.)
* - 'certFingerprint': Array of valid certificate fingerprints. (Only present if this is a certificate.) * - 'certFingerprint': Array of valid certificate fingerprints. (Only present if this is a certificate.)
* *
* @param SimpleSAML_Configuration $metadata The metadata. * @param \SimpleSAML_Configuration $metadata The metadata.
* @param bool $required Whether the private key is required. If this is TRUE, a missing key * @param bool $required Whether the private key is required. If this is TRUE, a missing key
* will cause an exception. Default is FALSE. * will cause an exception. Default is FALSE.
* @param string $prefix The prefix which should be used when reading from the metadata array. * @param string $prefix The prefix which should be used when reading from the metadata array.
...@@ -170,12 +171,12 @@ class SimpleSAML_Utils_Crypto ...@@ -170,12 +171,12 @@ class SimpleSAML_Utils_Crypto
* *
* @return array|NULL Public key or certificate data, or NULL if no public key or certificate was found. * @return array|NULL Public key or certificate data, or NULL if no public key or certificate was found.
* *
* @throws SimpleSAML_Error_Exception If no private key is found in the metadata, or it was not possible to load it. * @throws \SimpleSAML_Error_Exception If no private key is found in the metadata, or it was not possible to load it.
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
* @author Lasse Birnbaum Jensen * @author Lasse Birnbaum Jensen
*/ */
public static function loadPublicKey(SimpleSAML_Configuration $metadata, $required = false, $prefix = '') public static function loadPublicKey(\SimpleSAML_Configuration $metadata, $required = false, $prefix = '')
{ {
assert('is_bool($required)'); assert('is_bool($required)');
assert('is_string($prefix)'); assert('is_string($prefix)');
...@@ -219,7 +220,7 @@ class SimpleSAML_Utils_Crypto ...@@ -219,7 +220,7 @@ class SimpleSAML_Utils_Crypto
// no public key/certificate available // no public key/certificate available
if ($required) { if ($required) {
throw new SimpleSAML_Error_Exception('No public key / certificate found in metadata.'); throw new \SimpleSAML_Error_Exception('No public key / certificate found in metadata.');
} else { } else {
return null; return null;
} }
...@@ -234,7 +235,7 @@ class SimpleSAML_Utils_Crypto ...@@ -234,7 +235,7 @@ class SimpleSAML_Utils_Crypto
* @param string $salt An optional salt to use. * @param string $salt An optional salt to use.
* *
* @return string The hashed password. * @return string The hashed password.
* @throws SimpleSAML_Error_Exception If the algorithm specified is not supported, or the input parameters are not * @throws \SimpleSAML_Error_Exception If the algorithm specified is not supported, or the input parameters are not
* strings. * strings.
* @see hash_algos() * @see hash_algos()
* @author Dyonisius Visser, TERENA <visser@terena.org> * @author Dyonisius Visser, TERENA <visser@terena.org>
...@@ -243,7 +244,7 @@ class SimpleSAML_Utils_Crypto ...@@ -243,7 +244,7 @@ class SimpleSAML_Utils_Crypto
public static function pwHash($password, $algorithm, $salt = null) public static function pwHash($password, $algorithm, $salt = null)
{ {
if (!is_string($algorithm) || !is_string($password)) { if (!is_string($algorithm) || !is_string($password)) {
throw new SimpleSAML_Error_Exception('Invalid input parameters.'); throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
} }
// hash w/o salt // hash w/o salt
...@@ -267,7 +268,7 @@ class SimpleSAML_Utils_Crypto ...@@ -267,7 +268,7 @@ class SimpleSAML_Utils_Crypto
return $alg_str.base64_encode($hash.$salt); return $alg_str.base64_encode($hash.$salt);
} }
throw new SimpleSAML_Error_Exception('Hashing algorithm \''.strtolower($algorithm).'\' is not supported'); throw new \SimpleSAML_Error_Exception('Hashing algorithm \''.strtolower($algorithm).'\' is not supported');
} }
...@@ -278,14 +279,14 @@ class SimpleSAML_Utils_Crypto ...@@ -278,14 +279,14 @@ class SimpleSAML_Utils_Crypto
* @param string $password The password to check in clear. * @param string $password The password to check in clear.
* *
* @return boolean True if the hash corresponds with the given password, false otherwise. * @return boolean True if the hash corresponds with the given password, false otherwise.
* @throws SimpleSAML_Error_Exception If the algorithm specified is not supported, or the input parameters are not * @throws \SimpleSAML_Error_Exception If the algorithm specified is not supported, or the input parameters are not
* strings. * strings.
* @author Dyonisius Visser, TERENA <visser@terena.org> * @author Dyonisius Visser, TERENA <visser@terena.org>
*/ */
public static function pwValid($hash, $password) public static function pwValid($hash, $password)
{ {
if (!is_string($hash) || !is_string($password)) { if (!is_string($hash) || !is_string($password)) {
throw new SimpleSAML_Error_Exception('Invalid input parameters.'); throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
} }
// match algorithm string (e.g. '{SSHA256}', '{MD5}') // match algorithm string (e.g. '{SSHA256}', '{MD5}')
...@@ -312,6 +313,6 @@ class SimpleSAML_Utils_Crypto ...@@ -312,6 +313,6 @@ class SimpleSAML_Utils_Crypto
return $hash === $password; return $hash === $password;
} }
throw new SimpleSAML_Error_Exception('Hashing algorithm \''.strtolower($alg).'\' is not supported'); throw new \SimpleSAML_Error_Exception('Hashing algorithm \''.strtolower($alg).'\' is not supported');
} }
} }
...@@ -20,7 +20,7 @@ try { ...@@ -20,7 +20,7 @@ try {
$availableCerts = array(); $availableCerts = array();
$keys = array(); $keys = array();
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, FALSE, 'new_'); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, FALSE, 'new_');
if ($certInfo !== NULL) { if ($certInfo !== NULL) {
$availableCerts['new_idp.crt'] = $certInfo; $availableCerts['new_idp.crt'] = $certInfo;
$keys[] = array( $keys[] = array(
...@@ -34,7 +34,7 @@ try { ...@@ -34,7 +34,7 @@ try {
$hasNewCert = FALSE; $hasNewCert = FALSE;
} }
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE);
$availableCerts['idp.crt'] = $certInfo; $availableCerts['idp.crt'] = $certInfo;
$keys[] = array( $keys[] = array(
'type' => 'X509Certificate', 'type' => 'X509Certificate',
...@@ -44,7 +44,7 @@ try { ...@@ -44,7 +44,7 @@ try {
); );
if ($idpmeta->hasValue('https.certificate')) { if ($idpmeta->hasValue('https.certificate')) {
$httpsCert = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE, 'https.'); $httpsCert = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE, 'https.');
assert('isset($httpsCert["certData"])'); assert('isset($httpsCert["certData"])');
$availableCerts['https.crt'] = $httpsCert; $availableCerts['https.crt'] = $httpsCert;
$keys[] = array( $keys[] = array(
......
...@@ -82,7 +82,7 @@ class sspmod_authcrypt_Auth_Source_Hash extends sspmod_core_Auth_UserPassBase { ...@@ -82,7 +82,7 @@ class sspmod_authcrypt_Auth_Source_Hash extends sspmod_core_Auth_UserPassBase {
foreach($this->users as $userpass=>$attrs) { foreach($this->users as $userpass=>$attrs) {
$matches = explode(':', $userpass, 2); $matches = explode(':', $userpass, 2);
if ($matches[0] === $username) { if ($matches[0] === $username) {
if(SimpleSAML_Utils_Crypto::pwValid($matches[1], $password)) { if(SimpleSAML\Utils\Crypto::pwValid($matches[1], $password)) {
return $this->users[$userpass]; return $this->users[$userpass];
} else { } else {
SimpleSAML_Logger::debug('Incorrect password "' . $password . '" for user '. $username); SimpleSAML_Logger::debug('Incorrect password "' . $password . '" for user '. $username);
......
...@@ -86,7 +86,7 @@ class sspmod_authcrypt_Auth_Source_Htpasswd extends sspmod_core_Auth_UserPassBas ...@@ -86,7 +86,7 @@ class sspmod_authcrypt_Auth_Source_Htpasswd extends sspmod_core_Auth_UserPassBas
} }
// SHA1 or plain-text // SHA1 or plain-text
if(SimpleSAML_Utils_Crypto::pwValid($crypted, $password)) { if(SimpleSAML\Utils\Crypto::pwValid($crypted, $password)) {
SimpleSAML_Logger::debug('User '. $username . ' authenticated successfully'); SimpleSAML_Logger::debug('User '. $username . ' authenticated successfully');
return $attributes; return $attributes;
} }
......
...@@ -54,7 +54,7 @@ class sspmod_core_Auth_Source_AdminPassword extends sspmod_core_Auth_UserPassBas ...@@ -54,7 +54,7 @@ class sspmod_core_Auth_Source_AdminPassword extends sspmod_core_Auth_UserPassBas
throw new SimpleSAML_Error_Error('WRONGUSERPASS'); throw new SimpleSAML_Error_Error('WRONGUSERPASS');
} }
if (!SimpleSAML_Utils_Crypto::pwValid($adminPassword, $password)) { if (!SimpleSAML\Utils\Crypto::pwValid($adminPassword, $password)) {
throw new SimpleSAML_Error_Error('WRONGUSERPASS'); throw new SimpleSAML_Error_Error('WRONGUSERPASS');
} }
......
...@@ -16,7 +16,7 @@ if (array_key_exists('RedirId', $_REQUEST)) { ...@@ -16,7 +16,7 @@ if (array_key_exists('RedirId', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Invalid RedirInfo data.'); throw new SimpleSAML_Error_BadRequest('Invalid RedirInfo data.');
} }
list($sessionId, $postId) = explode(':', SimpleSAML_Utils_Crypto::aesDecrypt($encData)); list($sessionId, $postId) = explode(':', SimpleSAML\Utils\Crypto::aesDecrypt($encData));
if (empty($sessionId) || empty($postId)) { if (empty($sessionId) || empty($postId)) {
throw new SimpleSAML_Error_BadRequest('Invalid session info data.'); throw new SimpleSAML_Error_BadRequest('Invalid session info data.');
......
...@@ -21,11 +21,11 @@ class sspmod_saml_Message { ...@@ -21,11 +21,11 @@ class sspmod_saml_Message {
$dstPrivateKey = $dstMetadata->getString('signature.privatekey', NULL); $dstPrivateKey = $dstMetadata->getString('signature.privatekey', NULL);
if ($dstPrivateKey !== NULL) { if ($dstPrivateKey !== NULL) {
$keyArray = SimpleSAML_Utils_Crypto::loadPrivateKey($dstMetadata, TRUE, 'signature.'); $keyArray = SimpleSAML\Utils\Crypto::loadPrivateKey($dstMetadata, TRUE, 'signature.');
$certArray = SimpleSAML_Utils_Crypto::loadPublicKey($dstMetadata, FALSE, 'signature.'); $certArray = SimpleSAML\Utils\Crypto::loadPublicKey($dstMetadata, FALSE, 'signature.');
} else { } else {
$keyArray = SimpleSAML_Utils_Crypto::loadPrivateKey($srcMetadata, TRUE); $keyArray = SimpleSAML\Utils\Crypto::loadPrivateKey($srcMetadata, TRUE);
$certArray = SimpleSAML_Utils_Crypto::loadPublicKey($srcMetadata, FALSE); $certArray = SimpleSAML\Utils\Crypto::loadPublicKey($srcMetadata, FALSE);
} }
$algo = $dstMetadata->getString('signature.algorithm', NULL); $algo = $dstMetadata->getString('signature.algorithm', NULL);
...@@ -281,7 +281,7 @@ class sspmod_saml_Message { ...@@ -281,7 +281,7 @@ class sspmod_saml_Message {
$keys = array(); $keys = array();
/* Load the new private key if it exists. */ /* Load the new private key if it exists. */
$keyArray = SimpleSAML_Utils_Crypto::loadPrivateKey($dstMetadata, FALSE, 'new_'); $keyArray = SimpleSAML\Utils\Crypto::loadPrivateKey($dstMetadata, FALSE, 'new_');
if ($keyArray !== NULL) { if ($keyArray !== NULL) {
assert('isset($keyArray["PEM"])'); assert('isset($keyArray["PEM"])');
...@@ -294,7 +294,7 @@ class sspmod_saml_Message { ...@@ -294,7 +294,7 @@ class sspmod_saml_Message {
} }
/* Find the existing private key. */ /* Find the existing private key. */
$keyArray = SimpleSAML_Utils_Crypto::loadPrivateKey($dstMetadata, TRUE); $keyArray = SimpleSAML\Utils\Crypto::loadPrivateKey($dstMetadata, TRUE);
assert('isset($keyArray["PEM"])'); assert('isset($keyArray["PEM"])');
$key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'private')); $key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'private'));
......
...@@ -17,13 +17,13 @@ $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'saml20-idp-hosted'); ...@@ -17,13 +17,13 @@ $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'saml20-idp-hosted');
switch($_SERVER['PATH_INFO']) { switch($_SERVER['PATH_INFO']) {
case '/new_idp.crt': case '/new_idp.crt':
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, FALSE, 'new_'); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, FALSE, 'new_');
break; break;
case '/idp.crt': case '/idp.crt':
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE);
break; break;
case '/https.crt': case '/https.crt':
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE, 'https.'); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE, 'https.');
break; break;
default: default:
throw new SimpleSAML_Error_NotFound('Unknown certificate.'); throw new SimpleSAML_Error_NotFound('Unknown certificate.');
......
...@@ -91,7 +91,7 @@ foreach ($assertionsconsumerservices as $services) { ...@@ -91,7 +91,7 @@ foreach ($assertionsconsumerservices as $services) {
$metaArray20['AssertionConsumerService'] = $eps; $metaArray20['AssertionConsumerService'] = $eps;
$keys = array(); $keys = array();
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($spconfig, FALSE, 'new_'); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($spconfig, FALSE, 'new_');
if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) { if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) {
$hasNewCert = TRUE; $hasNewCert = TRUE;
...@@ -107,7 +107,7 @@ if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) { ...@@ -107,7 +107,7 @@ if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) {
$hasNewCert = FALSE; $hasNewCert = FALSE;
} }
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($spconfig); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($spconfig);
if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) { if ($certInfo !== NULL && array_key_exists('certData', $certInfo)) {
$certData = $certInfo['certData']; $certData = $certInfo['certData'];
......
...@@ -22,7 +22,7 @@ try { ...@@ -22,7 +22,7 @@ try {
$availableCerts = array(); $availableCerts = array();
$keys = array(); $keys = array();
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, FALSE, 'new_'); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, FALSE, 'new_');
if ($certInfo !== NULL) { if ($certInfo !== NULL) {
$availableCerts['new_idp.crt'] = $certInfo; $availableCerts['new_idp.crt'] = $certInfo;
$keys[] = array( $keys[] = array(
...@@ -36,7 +36,7 @@ try { ...@@ -36,7 +36,7 @@ try {
$hasNewCert = FALSE; $hasNewCert = FALSE;
} }
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE);
$availableCerts['idp.crt'] = $certInfo; $availableCerts['idp.crt'] = $certInfo;
$keys[] = array( $keys[] = array(
'type' => 'X509Certificate', 'type' => 'X509Certificate',
...@@ -46,7 +46,7 @@ try { ...@@ -46,7 +46,7 @@ try {
); );
if ($idpmeta->hasValue('https.certificate')) { if ($idpmeta->hasValue('https.certificate')) {
$httpsCert = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE, 'https.'); $httpsCert = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE, 'https.');
assert('isset($httpsCert["certData"])'); assert('isset($httpsCert["certData"])');
$availableCerts['https.crt'] = $httpsCert; $availableCerts['https.crt'] = $httpsCert;
$keys[] = array( $keys[] = array(
......
...@@ -21,7 +21,7 @@ try { ...@@ -21,7 +21,7 @@ try {
$idpmeta = $metadata->getMetaDataConfig($idpentityid, 'shib13-idp-hosted'); $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'shib13-idp-hosted');
$keys = array(); $keys = array();
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, FALSE, 'new_'); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, FALSE, 'new_');
if ($certInfo !== NULL) { if ($certInfo !== NULL) {
$keys[] = array( $keys[] = array(
'type' => 'X509Certificate', 'type' => 'X509Certificate',
...@@ -31,7 +31,7 @@ try { ...@@ -31,7 +31,7 @@ try {
); );
} }
$certInfo = SimpleSAML_Utils_Crypto::loadPublicKey($idpmeta, TRUE); $certInfo = SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, TRUE);
$keys[] = array( $keys[] = array(
'type' => 'X509Certificate', 'type' => 'X509Certificate',
'signing' => TRUE, 'signing' => TRUE,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment