mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 03:42:40 +00:00
Hash: add sha256-96 and sha512-96
IPSec uses them and some versions of OpenSSH use them (even though RFC6668 makes no mention of them)
This commit is contained in:
parent
c52441e7f2
commit
88d6517d93
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Uses hash() or mhash() if available and an internal implementation, otherwise. Currently supports the following:
|
* Uses hash() or mhash() if available and an internal implementation, otherwise. Currently supports the following:
|
||||||
*
|
*
|
||||||
* md2, md5, md5-96, sha1, sha1-96, sha256, sha384, and sha512
|
* md2, md5, md5-96, sha1, sha1-96, sha256, sha256-96, sha384, and sha512, sha512-96
|
||||||
*
|
*
|
||||||
* If {@link Crypt_Hash::setKey() setKey()} is called, {@link Crypt_Hash::hash() hash()} will return the HMAC as opposed to
|
* If {@link Crypt_Hash::setKey() setKey()} is called, {@link Crypt_Hash::hash() hash()} will return the HMAC as opposed to
|
||||||
* the hash. If no valid algorithm is provided, sha1 will be used.
|
* the hash. If no valid algorithm is provided, sha1 will be used.
|
||||||
@ -207,6 +207,9 @@ class Crypt_Hash
|
|||||||
switch ($hash) {
|
switch ($hash) {
|
||||||
case 'md5-96':
|
case 'md5-96':
|
||||||
case 'sha1-96':
|
case 'sha1-96':
|
||||||
|
case 'sha256-96':
|
||||||
|
case 'sha512-96':
|
||||||
|
$hash = substr($hash, 0, -3);
|
||||||
$this->l = 12; // 96 / 8 = 12
|
$this->l = 12; // 96 / 8 = 12
|
||||||
break;
|
break;
|
||||||
case 'md2':
|
case 'md2':
|
||||||
@ -243,14 +246,12 @@ class Crypt_Hash
|
|||||||
case CRYPT_HASH_MODE_MHASH:
|
case CRYPT_HASH_MODE_MHASH:
|
||||||
switch ($hash) {
|
switch ($hash) {
|
||||||
case 'md5':
|
case 'md5':
|
||||||
case 'md5-96':
|
|
||||||
$this->hash = MHASH_MD5;
|
$this->hash = MHASH_MD5;
|
||||||
break;
|
break;
|
||||||
case 'sha256':
|
case 'sha256':
|
||||||
$this->hash = MHASH_SHA256;
|
$this->hash = MHASH_SHA256;
|
||||||
break;
|
break;
|
||||||
case 'sha1':
|
case 'sha1':
|
||||||
case 'sha1-96':
|
|
||||||
default:
|
default:
|
||||||
$this->hash = MHASH_SHA1;
|
$this->hash = MHASH_SHA1;
|
||||||
}
|
}
|
||||||
@ -258,7 +259,6 @@ class Crypt_Hash
|
|||||||
case CRYPT_HASH_MODE_HASH:
|
case CRYPT_HASH_MODE_HASH:
|
||||||
switch ($hash) {
|
switch ($hash) {
|
||||||
case 'md5':
|
case 'md5':
|
||||||
case 'md5-96':
|
|
||||||
$this->hash = 'md5';
|
$this->hash = 'md5';
|
||||||
return;
|
return;
|
||||||
case 'md2':
|
case 'md2':
|
||||||
@ -268,7 +268,6 @@ class Crypt_Hash
|
|||||||
$this->hash = $hash;
|
$this->hash = $hash;
|
||||||
return;
|
return;
|
||||||
case 'sha1':
|
case 'sha1':
|
||||||
case 'sha1-96':
|
|
||||||
default:
|
default:
|
||||||
$this->hash = 'sha1';
|
$this->hash = 'sha1';
|
||||||
}
|
}
|
||||||
@ -281,7 +280,6 @@ class Crypt_Hash
|
|||||||
$this->hash = array($this, '_md2');
|
$this->hash = array($this, '_md2');
|
||||||
break;
|
break;
|
||||||
case 'md5':
|
case 'md5':
|
||||||
case 'md5-96':
|
|
||||||
$this->b = 64;
|
$this->b = 64;
|
||||||
$this->hash = array($this, '_md5');
|
$this->hash = array($this, '_md5');
|
||||||
break;
|
break;
|
||||||
@ -295,7 +293,6 @@ class Crypt_Hash
|
|||||||
$this->hash = array($this, '_sha512');
|
$this->hash = array($this, '_sha512');
|
||||||
break;
|
break;
|
||||||
case 'sha1':
|
case 'sha1':
|
||||||
case 'sha1-96':
|
|
||||||
default:
|
default:
|
||||||
$this->b = 64;
|
$this->b = 64;
|
||||||
$this->hash = array($this, '_sha1');
|
$this->hash = array($this, '_sha1');
|
||||||
|
Loading…
Reference in New Issue
Block a user