diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-11 15:05:36 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-11 15:05:36 +0200 |
commit | 4878f7a416ca210523e737e7c47597ca2617c2a9 (patch) | |
tree | a4385dea63caa43276fc0f7b4b942faf55df5c06 /lib | |
parent | 9737ba74ce828c745794af26e2bd2bb4ec7b1803 (diff) | |
parent | 1973275adc576aaf2cf6481d6cb91b0a6adc1f8d (diff) | |
download | nextcloud-server-4878f7a416ca210523e737e7c47597ca2617c2a9.tar.gz nextcloud-server-4878f7a416ca210523e737e7c47597ca2617c2a9.zip |
Merge pull request #11006 from owncloud/addCustomHex2BinImplementationBecauseSupporting53IsSomethingReallyReallyCoolAndWeAreObviouslySomeOfTheCoolGuys
Add custom hex2bin implementation for 5.3
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/security/crypto.php | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/private/security/crypto.php b/lib/private/security/crypto.php index 6fdff8d92a2..498e15d6bc3 100644 --- a/lib/private/security/crypto.php +++ b/lib/private/security/crypto.php @@ -43,6 +43,22 @@ class Crypto implements ICrypto { } /** + * Custom implementation of hex2bin since the function is only available starting + * with PHP 5.4 + * + * @TODO Remove this once 5.3 support for ownCloud is dropped + * @param $message + * @return string + */ + protected static function hexToBin($message) { + if (function_exists('hex2bin')) { + return hex2bin($message); + } + + return pack("H*", $message); + } + + /** * @param string $message The message to authenticate * @param string $password Password to use (defaults to `secret` in config.php) * @return string Calculated HMAC @@ -99,9 +115,9 @@ class Crypto implements ICrypto { throw new \Exception('Authenticated ciphertext could not be decoded.'); } - $ciphertext = hex2bin($parts[0]); + $ciphertext = self::hexToBin($parts[0]); $iv = $parts[1]; - $hmac = hex2bin($parts[2]); + $hmac = self::hexToBin($parts[2]); $this->cipher->setIV($iv); |