diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index 402eeeaefb6fd809e0a36da7df42a7bdc43b6a14..a422e624e142a2bb5ee3016717143c2a7b1f2e72 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -202,7 +202,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception { $emsg = array_shift($data); $etrace = implode("\n", $data); - $reportId = SimpleSAML_Utilities::stringToHex(openssl_random_pseudo_bytes(4)); + $reportId = bin2hex(openssl_random_pseudo_bytes(4)); SimpleSAML_Logger::error('Error report with id ' . $reportId . ' generated.'); $config = SimpleSAML_Configuration::getInstance(); diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index dbe899f5de727a279b407c3e269cd82d0e0d6f1d..df43435454ed4554d839733bd6d0de841007eddf 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -137,7 +137,7 @@ class SimpleSAML_Session $sh = SimpleSAML_SessionHandler::getSessionHandler(); $this->sessionId = $sh->newSessionId(); - $this->trackid = SimpleSAML_Utilities::stringToHex(openssl_random_pseudo_bytes(5)); + $this->trackid = bin2hex(openssl_random_pseudo_bytes(5)); $this->dirty = true; diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php index 86486fd6e4b7d5c8c80b6abb526616fcb6d6b11f..9e47a8ab8d92e2b138967454f38367010921382e 100644 --- a/lib/SimpleSAML/SessionHandlerCookie.php +++ b/lib/SimpleSAML/SessionHandlerCookie.php @@ -93,7 +93,7 @@ extends SimpleSAML_SessionHandler { * A random session id. */ private static function createSessionID() { - return SimpleSAML_Utilities::stringToHex(openssl_random_pseudo_bytes(16)); + return bin2hex(openssl_random_pseudo_bytes(16)); } diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index 2fe63c390a56227277399b0999918dc27c5434a5..36fe0753c90f5275846d699af7eaf55d8e3ea781 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -77,7 +77,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler { } /* Generate new (secure) session id. */ - $sessionId = SimpleSAML_Utilities::stringToHex(openssl_random_pseudo_bytes(16)); + $sessionId = bin2hex(openssl_random_pseudo_bytes(16)); SimpleSAML_Session::createSession($sessionId); if (session_id() !== '') { diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index e22fea3ed60d54e27e28f8b995753067e93629c0..b71a6e2a79cf0e317a65c774deab51929d2e5120 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -382,7 +382,7 @@ class SimpleSAML_Utilities { public static function generateID() { - return '_' . self::stringToHex(openssl_random_pseudo_bytes(21)); + return '_' . bin2hex(openssl_random_pseudo_bytes(21)); } @@ -967,10 +967,7 @@ class SimpleSAML_Utilities { /** - * This function converts a binary string to hexadecimal characters. - * - * @param $bytes Input string. - * @return String with lowercase hexadecimal characters. + * @deprecated This function will be removed in SSP 2.0. Please use bin2hex() instead. */ public static function stringToHex($bytes) { $ret = ''; diff --git a/lib/SimpleSAML/XHTML/EMail.php b/lib/SimpleSAML/XHTML/EMail.php index 761f5de776a7a4b0a0815c0cfb2f363de423aea2..5b69962e04429938eba6b1ae08c575735ebc350a 100644 --- a/lib/SimpleSAML/XHTML/EMail.php +++ b/lib/SimpleSAML/XHTML/EMail.php @@ -65,7 +65,7 @@ pre { if ($this->subject == NULL) throw new Exception('EMail field [subject] is required and not set.'); if ($this->body == NULL) throw new Exception('EMail field [body] is required and not set.'); - $random_hash = SimpleSAML_Utilities::stringToHex(openssl_random_pseudo_bytes(16)); + $random_hash = bin2hex(openssl_random_pseudo_bytes(16)); if (isset($this->from)) $this->headers[]= 'From: ' . $this->from; diff --git a/modules/saml/lib/Auth/Process/SQLPersistentNameID.php b/modules/saml/lib/Auth/Process/SQLPersistentNameID.php index ebfab8eef3e804112e8dfb9e367405becf2facc1..767aec324cf8c5bee6d82cee812113e6daec5bd4 100644 --- a/modules/saml/lib/Auth/Process/SQLPersistentNameID.php +++ b/modules/saml/lib/Auth/Process/SQLPersistentNameID.php @@ -81,7 +81,7 @@ class sspmod_saml_Auth_Process_SQLPersistentNameID extends sspmod_saml_BaseNameI throw new sspmod_saml_Error(SAML2_Const::STATUS_RESPONDER, 'urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy'); } - $value = SimpleSAML_Utilities::stringToHex(openssl_random_pseudo_bytes(20)); + $value = bin2hex(openssl_random_pseudo_bytes(20)); SimpleSAML_Logger::debug('SQLPersistentNameID: Created persistent NameID ' . var_export($value, TRUE) . ' for user ' . var_export($uid, TRUE) . '.'); sspmod_saml_IdP_SQLNameID::add($idpEntityId, $spEntityId, $uid, $value);