- ditch warnings

- add gost and snefru test
- CREDITS += mike
This commit is contained in:
Michael Wallner 2005-11-25 18:24:34 +00:00
parent 7a9fcb329f
commit 55f3cabb90
6 changed files with 91 additions and 37 deletions

View File

@ -1,2 +1,2 @@
PHP hash
Sara Golemon, Rasmus Lerdorf, Stefan Esser
Sara Golemon, Rasmus Lerdorf, Stefan Esser, Michael Wallner

View File

@ -777,22 +777,22 @@ PHP_HASH_API void PHP_SHA384Final(unsigned char digest[48], PHP_SHA384_CTX * con
unsigned int index, padLen;
/* Save number of bits */
bits[15] = context->count[0] & 0xFF;
bits[14] = (context->count[0] >> 8) & 0xFF;
bits[13] = (context->count[0] >> 16) & 0xFF;
bits[12] = (context->count[0] >> 24) & 0xFF;
bits[11] = (context->count[0] >> 32) & 0xFF;
bits[10] = (context->count[0] >> 40) & 0xFF;
bits[9] = (context->count[0] >> 48) & 0xFF;
bits[8] = (context->count[0] >> 56) & 0xFF;
bits[7] = context->count[1] & 0xFF;
bits[6] = (context->count[1] >> 8) & 0xFF;
bits[5] = (context->count[1] >> 16) & 0xFF;
bits[4] = (context->count[1] >> 24) & 0xFF;
bits[3] = (context->count[1] >> 32) & 0xFF;
bits[2] = (context->count[1] >> 40) & 0xFF;
bits[1] = (context->count[1] >> 48) & 0xFF;
bits[0] = (context->count[1] >> 56) & 0xFF;
bits[15] = (unsigned char) (context->count[0] & 0xFF);
bits[14] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
bits[13] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
bits[12] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
bits[11] = (unsigned char) ((context->count[0] >> 32) & 0xFF);
bits[10] = (unsigned char) ((context->count[0] >> 40) & 0xFF);
bits[9] = (unsigned char) ((context->count[0] >> 48) & 0xFF);
bits[8] = (unsigned char) ((context->count[0] >> 56) & 0xFF);
bits[7] = (unsigned char) (context->count[1] & 0xFF);
bits[6] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
bits[5] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
bits[4] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
bits[3] = (unsigned char) ((context->count[1] >> 32) & 0xFF);
bits[2] = (unsigned char) ((context->count[1] >> 40) & 0xFF);
bits[1] = (unsigned char) ((context->count[1] >> 48) & 0xFF);
bits[0] = (unsigned char) ((context->count[1] >> 56) & 0xFF);
/* Pad out to 112 mod 128.
*/
@ -890,22 +890,22 @@ PHP_HASH_API void PHP_SHA512Final(unsigned char digest[48], PHP_SHA512_CTX * con
unsigned int index, padLen;
/* Save number of bits */
bits[15] = context->count[0] & 0xFF;
bits[14] = (context->count[0] >> 8) & 0xFF;
bits[13] = (context->count[0] >> 16) & 0xFF;
bits[12] = (context->count[0] >> 24) & 0xFF;
bits[11] = (context->count[0] >> 32) & 0xFF;
bits[10] = (context->count[0] >> 40) & 0xFF;
bits[9] = (context->count[0] >> 48) & 0xFF;
bits[8] = (context->count[0] >> 56) & 0xFF;
bits[7] = context->count[1] & 0xFF;
bits[6] = (context->count[1] >> 8) & 0xFF;
bits[5] = (context->count[1] >> 16) & 0xFF;
bits[4] = (context->count[1] >> 24) & 0xFF;
bits[3] = (context->count[1] >> 32) & 0xFF;
bits[2] = (context->count[1] >> 40) & 0xFF;
bits[1] = (context->count[1] >> 48) & 0xFF;
bits[0] = (context->count[1] >> 56) & 0xFF;
bits[15] = (unsigned char) (context->count[0] & 0xFF);
bits[14] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
bits[13] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
bits[12] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
bits[11] = (unsigned char) ((context->count[0] >> 32) & 0xFF);
bits[10] = (unsigned char) ((context->count[0] >> 40) & 0xFF);
bits[9] = (unsigned char) ((context->count[0] >> 48) & 0xFF);
bits[8] = (unsigned char) ((context->count[0] >> 56) & 0xFF);
bits[7] = (unsigned char) (context->count[1] & 0xFF);
bits[6] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
bits[5] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
bits[4] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
bits[3] = (unsigned char) ((context->count[1] >> 32) & 0xFF);
bits[2] = (unsigned char) ((context->count[1] >> 40) & 0xFF);
bits[1] = (unsigned char) ((context->count[1] >> 48) & 0xFF);
bits[0] = (unsigned char) ((context->count[1] >> 56) & 0xFF);
/* Pad out to 112 mod 128.
*/

View File

@ -45,7 +45,8 @@ static inline void Snefru(php_uint32 input[16])
{
static int shifts[4] = {16, 8, 16, 24};
int b, index, rshift, lshift;
php_uint32 *t0,*t1,SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15;
const php_uint32 *t0,*t1;
php_uint32 SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15;
B00 = input[0];
B01 = input[1];

View File

@ -12,13 +12,26 @@
<email>pollita@php.net</email>
<role>lead</role>
</maintainer>
<maintainer>
<user>mike</user>
<name>Michael Wallner</name>
<email>mike@php.net</email>
<role>developer</role>
</maintainer>
</maintainers>
<release>
<version>0.1</version>
<state>beta</state>
<date>2005-11-18</date>
<notes>Initial Release - md5, sha1, sha256, sha384, sha512, ripemd128, ripemd160, tiger, gost, snefru, whirlpool</notes>
<date>2005-11-00</date>
<notes>
Initial Release
* md5
* sha1, sha256, sha384, sha512
* ripemd128, ripemd160
* tiger128, tiger160, tiger192
* gost, snefru, whirlpool
</notes>
</release>
<filelist>
@ -39,7 +52,7 @@
<file role="src" name="php_hash_tiger.h"/>
<file role="src" name="php_hash_tiger_tables.h"/>
<file role="src" name="hash_snefru.c"/>
<file role="src" name="php_hash_snefru.c"/>
<file role="src" name="php_hash_snefru.h"/>
<file role="src" name="php_hash_snefru_tables.h"/>
<file role="src" name="hash_gost.c"/>
<file role="src" name="php_hash_gost.h"/>
@ -57,6 +70,8 @@
<file role="test" name="haval.phpt"/>
<file role="test" name="tiger.phpt"/>
<file role="test" name="whirlpool.phpt"/>
<file role="test" name="gost.phpt"/>
<file role="test" name="snefru.phpt"/>
</dir>
</filelist>

20
ext/hash/tests/gost.phpt Normal file
View File

@ -0,0 +1,20 @@
--TEST--
gost
--SKIPIF--
<?php extension_loaded('hash') or die('skip'); ?>
--FILE--
<?php
echo hash('gost', ''), "\n";
echo hash('gost', 'The quick brown fox jumps over the lazy dog'), "\n";
echo hash('gost', 'The quick brown fox jumps over the lazy cog'), "\n";
echo hash('gost', str_repeat('a', 31)), "\n";
echo hash('gost', str_repeat('a', 32)), "\n";
echo hash('gost', str_repeat('a', 33)), "\n";
?>
--EXPECT--
ce85b99cc46752fffee35cab9a7b0278abb4c2d2055cff685af4912c49490f8d
77b7fa410c9ac58a25f49bca7d0468c9296529315eaca76bd1a10f376d1f4294
a3ebc4daaab78b0be131dab5737a7f67e602670d543521319150d2e14eeec445
03840d6348763f11e28e7b1ecc4da0cdf7f898fa555b928ef684c6c5b8f46d9f
fd1b746d9397e78edd311baef391450434271e02816caa37680d6d7381c79d4e
715e59cdc8ebde9fdf0fe2a2e811b3bf7f48209a01505e467d2cd2aa2bbb5ecf

View File

@ -0,0 +1,18 @@
--TEST--
snefru
--SKIPIF--
<?php extension_loaded('hash') or die('skip'); ?>
--FILE--
<?php
echo hash('snefru', ''), "\n";
echo hash('snefru', 'The quick brown fox jumps over the lazy dog'), "\n";
echo hash('snefru', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), "\n";
echo hash('snefru', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), "\n";
echo hash('snefru', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), "\n";
?>
--EXPECT--
8617f366566a011837f4fb4ba5bedea2b892f3ed8b894023d16ae344b2be5881
674caa75f9d8fd2089856b95e93a4fb42fa6c8702f8980e11d97a142d76cb358
94682bc46e5fbb8417e2f3e10ed360484048d946bb8cbb0ea4cad2700dbeaab0
c54c602ac46383716ee7200a76c9c90a7b435bbe31d13f04e0b00a7ea5c347fa
7a8539c59e192e8d70b1ab82aa86a1b54560d42020bda4e00ddd6d048fe3bcaa