diff --git a/src/HMAC.php b/src/Hmac.php similarity index 95% rename from src/HMAC.php rename to src/Hmac.php index 6e46d5b..ba3819e 100644 --- a/src/HMAC.php +++ b/src/Hmac.php @@ -31,13 +31,13 @@ * @todo Patch for refactoring failed tests (key block sizes >80 using internal algo) * @todo Check if mhash() is a required alternative (will be PECL-only soon) * @uses Zend\Crypt\Crypt - * @uses Zend\Crypt\HMACException + * @uses Zend\Crypt\HmacException * @category Zend * @package Zend_Crypt * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class HMAC extends Crypt +class Hmac extends Crypt { /** @@ -108,7 +108,7 @@ public static function compute($key, $hash, $data, $output = self::STRING) { // set the key if (!isset($key) || empty($key)) { - throw new HMACException('provided key is null or empty'); + throw new HmacException('provided key is null or empty'); } self::$_key = $key; @@ -128,7 +128,7 @@ public static function compute($key, $hash, $data, $output = self::STRING) protected static function _setHashAlgorithm($hash) { if (!isset($hash) || empty($hash)) { - throw new HMACException('provided hash string is null or empty'); + throw new HmacException('provided hash string is null or empty'); } $hash = strtolower($hash); @@ -143,7 +143,7 @@ protected static function _setHashAlgorithm($hash) } if ($hashSupported === false) { - throw new HMACException('hash algorithm provided is not supported on this PHP installation; please enable the hash or mhash extensions'); + throw new HmacException('hash algorithm provided is not supported on this PHP installation; please enable the hash or mhash extensions'); } self::$_hashAlgorithm = $hash; } diff --git a/src/HMACException.php b/src/HmacException.php similarity index 96% rename from src/HMACException.php rename to src/HmacException.php index 4018538..b3bc8ee 100644 --- a/src/HMACException.php +++ b/src/HmacException.php @@ -32,6 +32,6 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class HMACException extends Exception +class HmacException extends Exception { } diff --git a/src/RSA.php b/src/Rsa.php similarity index 90% rename from src/RSA.php rename to src/Rsa.php index 61b03cb..3449102 100644 --- a/src/RSA.php +++ b/src/Rsa.php @@ -25,14 +25,14 @@ namespace Zend\Crypt; /** - * @uses Zend\Crypt\RSA\PrivateKey - * @uses Zend\Crypt\RSA\PublicKey + * @uses Zend\Crypt\Rsa\PrivateKey + * @uses Zend\Crypt\Rsa\PublicKey * @category Zend * @package Zend_Crypt * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class RSA +class Rsa { const BINARY = 'binary'; const BASE64 = 'base64'; @@ -101,11 +101,11 @@ public function getPublicKey() /** * @param string $data - * @param Zend\Crypt\RSA\PrivateKey $privateKey + * @param Zend\Crypt\Rsa\PrivateKey $privateKey * @param string $format * @return string */ - public function sign($data, RSA\PrivateKey $privateKey = null, $format = null) + public function sign($data, Rsa\PrivateKey $privateKey = null, $format = null) { $signature = ''; if (isset($privateKey)) { @@ -143,15 +143,15 @@ public function verifySignature($data, $signature, $format = null) /** * @param string $data - * @param Zend\Crypt\RSA\Key $key + * @param Zend\Crypt\Rsa\Key $key * @param string $format * @return string */ - public function encrypt($data, RSA\Key $key, $format = null) + public function encrypt($data, Rsa\Key $key, $format = null) { $encrypted = ''; $function = 'openssl_public_encrypt'; - if ($key instanceof RSA\PrivateKey) { + if ($key instanceof Rsa\PrivateKey) { $function = 'openssl_private_encrypt'; } $function($data, $encrypted, $key->getOpensslKeyResource()); @@ -163,18 +163,18 @@ public function encrypt($data, RSA\Key $key, $format = null) /** * @param string $data - * @param \Zend\Crypt\RSA\Key $key + * @param \Zend\Crypt\Rsa\Key $key * @param string $format * @return string */ - public function decrypt($data, RSA\Key $key, $format = null) + public function decrypt($data, Rsa\Key $key, $format = null) { $decrypted = ''; if ($format == self::BASE64) { $data = base64_decode($data); } $function = 'openssl_private_decrypt'; - if ($key instanceof RSA\PublicKey) { + if ($key instanceof Rsa\PublicKey) { $function = 'openssl_public_decrypt'; } $function($data, $decrypted, $key->getOpensslKeyResource()); @@ -200,9 +200,9 @@ public function generateKeys(array $configargs = null) openssl_pkey_export($resource, $private, $passPhrase); - $privateKey = new RSA\PrivateKey($private, $passPhrase); + $privateKey = new Rsa\PrivateKey($private, $passPhrase); $details = openssl_pkey_get_details($resource); - $publicKey = new RSA\PublicKey($details['key']); + $publicKey = new Rsa\PublicKey($details['key']); $return = new \ArrayObject(array( 'privateKey' => $privateKey, 'publicKey' => $publicKey @@ -217,11 +217,11 @@ public function setPemString($value) { $this->_pemString = $value; try { - $this->_privateKey = new RSA\PrivateKey($this->_pemString, $this->_passPhrase); + $this->_privateKey = new Rsa\PrivateKey($this->_pemString, $this->_passPhrase); $this->_publicKey = $this->_privateKey->getPublicKey(); } catch (Exception $e) { $this->_privateKey = null; - $this->_publicKey = new RSA\PublicKey($this->_pemString); + $this->_publicKey = new Rsa\PublicKey($this->_pemString); } } @@ -234,7 +234,7 @@ public function setPemPath($value) public function setCertificateString($value) { $this->_certificateString = $value; - $this->_publicKey = new RSA\PublicKey($this->_certificateString, $this->_passPhrase); + $this->_publicKey = new Rsa\PublicKey($this->_certificateString, $this->_passPhrase); } public function setCertificatePath($value) diff --git a/src/RSA/Key.php b/src/Rsa/Key.php similarity index 98% rename from src/RSA/Key.php rename to src/Rsa/Key.php index 3688ac1..2939318 100644 --- a/src/RSA/Key.php +++ b/src/Rsa/Key.php @@ -23,7 +23,7 @@ /** * @namespace */ -namespace Zend\Crypt\RSA; +namespace Zend\Crypt\Rsa; /** * @uses Zend\Crypt\Exception diff --git a/src/RSA/PrivateKey.php b/src/Rsa/PrivateKey.php similarity index 94% rename from src/RSA/PrivateKey.php rename to src/Rsa/PrivateKey.php index c3c5b14..5a2156a 100644 --- a/src/RSA/PrivateKey.php +++ b/src/Rsa/PrivateKey.php @@ -23,12 +23,12 @@ /** * @namespace */ -namespace Zend\Crypt\RSA; +namespace Zend\Crypt\Rsa; /** * @uses Zend\Crypt\Exception - * @uses Zend\Crypt\RSA\Key - * @uses Zend\Crypt\RSA\PublicKey + * @uses Zend\Crypt\Rsa\Key + * @uses Zend\Crypt\Rsa\PublicKey * @category Zend * @package Zend_Crypt * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) diff --git a/src/RSA/PublicKey.php b/src/Rsa/PublicKey.php similarity index 96% rename from src/RSA/PublicKey.php rename to src/Rsa/PublicKey.php index 94daa47..ce12ae3 100644 --- a/src/RSA/PublicKey.php +++ b/src/Rsa/PublicKey.php @@ -23,11 +23,11 @@ /** * @namespace */ -namespace Zend\Crypt\RSA; +namespace Zend\Crypt\Rsa; /** * @uses Zend\Crypt\Exception - * @uses Zend\Crypt\RSA\Key + * @uses Zend\Crypt\Rsa\Key * @category Zend * @package Zend_Crypt * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) diff --git a/test/HMACTest.php b/test/HMACTest.php index 157ba70..166e00b 100644 --- a/test/HMACTest.php +++ b/test/HMACTest.php @@ -24,7 +24,7 @@ * @namespace */ namespace ZendTest\Crypt; -use Zend\Crypt\HMAC; +use Zend\Crypt\Hmac as HMAC; /** * Outside the Internal Function tests, tests do not distinguish between hash and mhash diff --git a/test/RSATest.php b/test/RSATest.php index 559b213..9240c14 100644 --- a/test/RSATest.php +++ b/test/RSATest.php @@ -24,7 +24,7 @@ * @namespace */ namespace ZendTest\Crypt; -use Zend\Crypt\RSA, +use Zend\Crypt\Rsa as RSA, Zend\Crypt; /**