Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
HMAC -> Hmac; RSA -> Rsa
Browse files Browse the repository at this point in the history
- Updated all Crypt and OAuth libraries to convert:
  - HMAC -> Hmac
  - RSA -> Rsa
  • Loading branch information
weierophinney committed Jul 22, 2010
4 parents 0301e5f + edddb78 + 896bec8 + 15ea6b9 commit 342e692
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions src/HMAC.php → src/Hmac.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

/**
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/HMACException.php → src/HmacException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
32 changes: 16 additions & 16 deletions src/RSA.php → src/Rsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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
Expand All @@ -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);
}
}

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/RSA/Key.php → src/Rsa/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @namespace
*/
namespace Zend\Crypt\RSA;
namespace Zend\Crypt\Rsa;

/**
* @uses Zend\Crypt\Exception
Expand Down
6 changes: 3 additions & 3 deletions src/RSA/PrivateKey.php → src/Rsa/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/RSA/PublicKey.php → src/Rsa/PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/HMACTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/RSATest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @namespace
*/
namespace ZendTest\Crypt;
use Zend\Crypt\RSA,
use Zend\Crypt\Rsa as RSA,
Zend\Crypt;

/**
Expand Down

0 comments on commit 342e692

Please sign in to comment.