mirror of
https://github.com/php/php-src.git
synced 2025-01-22 03:34:19 +08:00
merge ext/hash from trunk
This commit is contained in:
parent
d940f2d38a
commit
6a7bbb1561
4
NEWS
4
NEWS
@ -7,6 +7,10 @@ PHP NEWS
|
||||
$_SERVER['REQUEST_TIME_FLOAT'] to include microsecond precision. (Patrick)
|
||||
. Fixed bug #60768 (Output buffer not discarded) (Mike)
|
||||
|
||||
- Hash
|
||||
. Fixed bug #60221 (Tiger hash output byte order) (Mike)
|
||||
. Removed Salsa10/Salsa20, which are actually stream ciphers (Mike)
|
||||
|
||||
- Pdo Firebird:
|
||||
. Fixed bug #47415 (segfaults when passing lowercased column name to
|
||||
bindColumn). (Mariuz)
|
||||
|
@ -27,10 +27,10 @@ if test "$PHP_HASH" != "no"; then
|
||||
|
||||
EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
|
||||
hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \
|
||||
hash_crc32.c hash_salsa.c hash_fnv.c hash_joaat.c"
|
||||
hash_crc32.c hash_fnv.c hash_joaat.c"
|
||||
EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
|
||||
php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
|
||||
php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h php_hash_salsa.h \
|
||||
php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h \
|
||||
php_hash_fnv.h php_hash_joaat.h php_hash_types.h"
|
||||
|
||||
PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared)
|
||||
|
@ -15,11 +15,11 @@ if (PHP_HASH != "no") {
|
||||
AC_DEFINE('HAVE_HASH_EXT', 1);
|
||||
EXTENSION("hash", "hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c "
|
||||
+ "hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c "
|
||||
+ "hash_adler32.c hash_crc32.c hash_salsa.c hash_joaat.c hash_fnv.c");
|
||||
+ "hash_adler32.c hash_crc32.c hash_joaat.c hash_fnv.c");
|
||||
|
||||
PHP_INSTALL_HEADERS("ext/hash/", "php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h " +
|
||||
"php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h " +
|
||||
"php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h php_hash_salsa.h " +
|
||||
"php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h " +
|
||||
"php_hash_types.h");
|
||||
}
|
||||
|
||||
|
@ -851,8 +851,6 @@ PHP_MINIT_FUNCTION(hash)
|
||||
php_hash_register_algo("adler32", &php_hash_adler32_ops);
|
||||
php_hash_register_algo("crc32", &php_hash_crc32_ops);
|
||||
php_hash_register_algo("crc32b", &php_hash_crc32b_ops);
|
||||
php_hash_register_algo("salsa10", &php_hash_salsa10_ops);
|
||||
php_hash_register_algo("salsa20", &php_hash_salsa20_ops);
|
||||
php_hash_register_algo("fnv132", &php_hash_fnv132_ops);
|
||||
php_hash_register_algo("fnv164", &php_hash_fnv164_ops);
|
||||
php_hash_register_algo("joaat", &php_hash_joaat_ops);
|
||||
|
@ -1,224 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2012 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_salsa.h"
|
||||
|
||||
#define R(a,b) (((a) << (b)) | ((a) >> (32 - (b))))
|
||||
|
||||
/* {{{ Salsa10
|
||||
|
||||
The 64-byte input x to Salsa10 is viewed in little-endian form as 16 integers
|
||||
x0, x1, x2, ..., x15 in {0,1,...,2^32-1}. These 16 integers are fed through
|
||||
320 invertible modifications, where each modification changes one integer.
|
||||
The modifications involve, overall,
|
||||
|
||||
* 10 additions of constants modulo 2^32;
|
||||
* 320 more additions modulo 2^32;
|
||||
* 80 ``or'' operations;
|
||||
* 240 ``xor'' operations; and
|
||||
* 320 constant-distance rotations.
|
||||
|
||||
The resulting 16 integers are added to the original x0, x1, x2, ..., x15
|
||||
respectively modulo 2^32, producing, in little-endian form, the 64-byte output
|
||||
Salsa10(x).
|
||||
|
||||
D.J.Bernstein
|
||||
*/
|
||||
static void Salsa10(php_hash_uint32 x[16], php_hash_uint32 in[16])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 10; i > 0; --i) {
|
||||
x[ 4] ^= R(x[ 0]+x[12], 6); x[ 8] ^= R(x[ 4]+x[ 0],17);
|
||||
x[12] += R(x[ 8]|x[ 4],16); x[ 0] += R(x[12]^x[ 8], 5);
|
||||
x[ 9] += R(x[ 5]|x[ 1], 8); x[13] += R(x[ 9]|x[ 5], 7);
|
||||
x[ 1] ^= R(x[13]+x[ 9],17); x[ 5] += R(x[ 1]^x[13],12);
|
||||
x[14] ^= R(x[10]+x[ 6], 7); x[ 2] += R(x[14]^x[10],15);
|
||||
x[ 6] ^= R(x[ 2]+x[14],13); x[10] ^= R(x[ 6]+x[ 2],15);
|
||||
x[ 3] += R(x[15]|x[11],20); x[ 7] ^= R(x[ 3]+x[15],16);
|
||||
x[11] += R(x[ 7]^x[ 3], 7); x[15] += R(x[11]^x[ 7], 8);
|
||||
x[ 1] += R(x[ 0]|x[ 3], 8)^i;x[ 2] ^= R(x[ 1]+x[ 0],14);
|
||||
x[ 3] ^= R(x[ 2]+x[ 1], 6); x[ 0] += R(x[ 3]^x[ 2],18);
|
||||
x[ 6] += R(x[ 5]^x[ 4], 8); x[ 7] += R(x[ 6]^x[ 5],12);
|
||||
x[ 4] += R(x[ 7]|x[ 6],13); x[ 5] ^= R(x[ 4]+x[ 7],15);
|
||||
x[11] ^= R(x[10]+x[ 9],18); x[ 8] += R(x[11]^x[10],11);
|
||||
x[ 9] ^= R(x[ 8]+x[11], 8); x[10] += R(x[ 9]|x[ 8], 6);
|
||||
x[12] += R(x[15]^x[14],17); x[13] ^= R(x[12]+x[15],15);
|
||||
x[14] += R(x[13]|x[12], 9); x[15] += R(x[14]^x[13], 7);
|
||||
}
|
||||
for (i = 0; i < 16; ++i) {
|
||||
x[i] += in[i];
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Salsa20
|
||||
|
||||
The 64-byte input x to Salsa20 is viewed in little-endian form as 16 words
|
||||
x0, x1, x2, ..., x15 in {0,1,...,2^32-1}. These 16 words are fed through 320
|
||||
invertible modifications, where each modification changes one word. The
|
||||
resulting 16 words are added to the original x0, x1, x2, ..., x15 respectively
|
||||
modulo 2^32, producing, in little-endian form, the 64-byte output Salsa20(x).
|
||||
|
||||
Each modification involves xor'ing into one word a rotated version of the sum
|
||||
of two other words modulo 2^32. Thus the 320 modifications involve, overall,
|
||||
320 additions, 320 xor's, and 320 rotations. The rotations are all by constant
|
||||
distances.
|
||||
|
||||
The entire series of modifications is a series of 10 identical double-rounds.
|
||||
Each double-round is a series of 2 rounds. Each round is a set of 4 parallel
|
||||
quarter-rounds. Each quarter-round modifies 4 words.
|
||||
|
||||
D.J.Bernstein
|
||||
*/
|
||||
static void Salsa20(php_hash_uint32 x[16], php_hash_uint32 in[16])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 20; i > 0; i -= 2) {
|
||||
x[ 4] ^= R(x[ 0]+x[12], 7); x[ 8] ^= R(x[ 4]+x[ 0], 9);
|
||||
x[12] ^= R(x[ 8]+x[ 4],13); x[ 0] ^= R(x[12]+x[ 8],18);
|
||||
x[ 9] ^= R(x[ 5]+x[ 1], 7); x[13] ^= R(x[ 9]+x[ 5], 9);
|
||||
x[ 1] ^= R(x[13]+x[ 9],13); x[ 5] ^= R(x[ 1]+x[13],18);
|
||||
x[14] ^= R(x[10]+x[ 6], 7); x[ 2] ^= R(x[14]+x[10], 9);
|
||||
x[ 6] ^= R(x[ 2]+x[14],13); x[10] ^= R(x[ 6]+x[ 2],18);
|
||||
x[ 3] ^= R(x[15]+x[11], 7); x[ 7] ^= R(x[ 3]+x[15], 9);
|
||||
x[11] ^= R(x[ 7]+x[ 3],13); x[15] ^= R(x[11]+x[ 7],18);
|
||||
x[ 1] ^= R(x[ 0]+x[ 3], 7); x[ 2] ^= R(x[ 1]+x[ 0], 9);
|
||||
x[ 3] ^= R(x[ 2]+x[ 1],13); x[ 0] ^= R(x[ 3]+x[ 2],18);
|
||||
x[ 6] ^= R(x[ 5]+x[ 4], 7); x[ 7] ^= R(x[ 6]+x[ 5], 9);
|
||||
x[ 4] ^= R(x[ 7]+x[ 6],13); x[ 5] ^= R(x[ 4]+x[ 7],18);
|
||||
x[11] ^= R(x[10]+x[ 9], 7); x[ 8] ^= R(x[11]+x[10], 9);
|
||||
x[ 9] ^= R(x[ 8]+x[11],13); x[10] ^= R(x[ 9]+x[ 8],18);
|
||||
x[12] ^= R(x[15]+x[14], 7); x[13] ^= R(x[12]+x[15], 9);
|
||||
x[14] ^= R(x[13]+x[12],13); x[15] ^= R(x[14]+x[13],18);
|
||||
}
|
||||
for (i = 0; i < 16; ++i) {
|
||||
x[i] += in[i];
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static inline void SalsaTransform(PHP_SALSA_CTX *context, const unsigned char input[64])
|
||||
{
|
||||
php_hash_uint32 i, j, a[16];
|
||||
|
||||
#if 0
|
||||
fprintf(stderr, "> INPUT: %.*s\n", 64, input);
|
||||
#endif
|
||||
|
||||
for (i = 0, j = 0; j < 64; i++, j += 4) {
|
||||
a[i] = ((php_hash_uint32) input[j + 3]) | (((php_hash_uint32) input[j + 2]) << 8) |
|
||||
(((php_hash_uint32) input[j + 1]) << 16) | (((php_hash_uint32) input[j]) << 24);
|
||||
}
|
||||
|
||||
if (!context->init) {
|
||||
memcpy(context->state, a, sizeof(a));
|
||||
context->init = 1;
|
||||
}
|
||||
|
||||
context->Transform(context->state, a);
|
||||
memset(a, 0, sizeof(a));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_SALSA10Init(PHP_SALSA_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
context->Transform = Salsa10;
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_SALSA20Init(PHP_SALSA_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
context->Transform = Salsa20;
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_SALSAUpdate(PHP_SALSA_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
if (context->length + len < 64) {
|
||||
memcpy(&context->buffer[context->length], input, len);
|
||||
context->length += len;
|
||||
} else {
|
||||
size_t i = 0, r = (context->length + len) % 64;
|
||||
|
||||
if (context->length) {
|
||||
i = 64 - context->length;
|
||||
memcpy(&context->buffer[context->length], input, i);
|
||||
SalsaTransform(context, context->buffer);
|
||||
memset(context->buffer, 0, 64);
|
||||
}
|
||||
|
||||
for (; i + 64 <= len; i += 64) {
|
||||
SalsaTransform(context, input + i);
|
||||
}
|
||||
|
||||
memcpy(context->buffer, input + i, r);
|
||||
context->length = r;
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_SALSAFinal(unsigned char digest[64], PHP_SALSA_CTX *context)
|
||||
{
|
||||
php_hash_uint32 i, j;
|
||||
|
||||
if (context->length) {
|
||||
SalsaTransform(context, context->buffer);
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; j < 64; i++, j += 4) {
|
||||
digest[j] = (unsigned char) ((context->state[i] >> 24) & 0xff);
|
||||
digest[j + 1] = (unsigned char) ((context->state[i] >> 16) & 0xff);
|
||||
digest[j + 2] = (unsigned char) ((context->state[i] >> 8) & 0xff);
|
||||
digest[j + 3] = (unsigned char) (context->state[i] & 0xff);
|
||||
}
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
const php_hash_ops php_hash_salsa10_ops = {
|
||||
(php_hash_init_func_t) PHP_SALSA10Init,
|
||||
(php_hash_update_func_t) PHP_SALSAUpdate,
|
||||
(php_hash_final_func_t) PHP_SALSAFinal,
|
||||
(php_hash_copy_func_t) php_hash_copy,
|
||||
64,
|
||||
64,
|
||||
sizeof(PHP_SALSA_CTX)
|
||||
};
|
||||
|
||||
const php_hash_ops php_hash_salsa20_ops = {
|
||||
(php_hash_init_func_t) PHP_SALSA20Init,
|
||||
(php_hash_update_func_t) PHP_SALSAUpdate,
|
||||
(php_hash_final_func_t) PHP_SALSAFinal,
|
||||
(php_hash_copy_func_t) php_hash_copy,
|
||||
64,
|
||||
64,
|
||||
sizeof(PHP_SALSA_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
@ -169,6 +169,15 @@ static inline void TigerFinalize(PHP_TIGER_CTX *context)
|
||||
tiger_compress(context->passes, ((php_hash_uint64 *) context->buffer), context->state);
|
||||
}
|
||||
|
||||
static inline void TigerDigest(unsigned char *digest_str, unsigned int digest_len, PHP_TIGER_CTX *context)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < digest_len; ++i) {
|
||||
digest_str[i] = (unsigned char) ((context->state[i/8] >> (8 * (i%8))) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
@ -216,84 +225,21 @@ PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *i
|
||||
PHP_HASH_API void PHP_TIGER128Final(unsigned char digest[16], PHP_TIGER_CTX *context)
|
||||
{
|
||||
TigerFinalize(context);
|
||||
|
||||
digest[0] = (unsigned char) ((context->state[0] >> 56) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state[0] >> 48) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state[0] >> 40) & 0xff);
|
||||
digest[3] = (unsigned char) ((context->state[0] >> 32) & 0xff);
|
||||
digest[4] = (unsigned char) ((context->state[0] >> 24) & 0xff);
|
||||
digest[5] = (unsigned char) ((context->state[0] >> 16) & 0xff);
|
||||
digest[6] = (unsigned char) ((context->state[0] >> 8) & 0xff);
|
||||
digest[7] = (unsigned char) (context->state[0] & 0xff);
|
||||
digest[8] = (unsigned char) ((context->state[1] >> 56) & 0xff);
|
||||
digest[9] = (unsigned char) ((context->state[1] >> 48) & 0xff);
|
||||
digest[10] = (unsigned char) ((context->state[1] >> 40) & 0xff);
|
||||
digest[11] = (unsigned char) ((context->state[1] >> 32) & 0xff);
|
||||
digest[12] = (unsigned char) ((context->state[1] >> 24) & 0xff);
|
||||
digest[13] = (unsigned char) ((context->state[1] >> 16) & 0xff);
|
||||
digest[14] = (unsigned char) ((context->state[1] >> 8) & 0xff);
|
||||
digest[15] = (unsigned char) (context->state[1] & 0xff);
|
||||
|
||||
TigerDigest(digest, 16, context);
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_TIGER160Final(unsigned char digest[20], PHP_TIGER_CTX *context)
|
||||
{
|
||||
TigerFinalize(context);
|
||||
|
||||
digest[0] = (unsigned char) ((context->state[0] >> 56) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state[0] >> 48) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state[0] >> 40) & 0xff);
|
||||
digest[3] = (unsigned char) ((context->state[0] >> 32) & 0xff);
|
||||
digest[4] = (unsigned char) ((context->state[0] >> 24) & 0xff);
|
||||
digest[5] = (unsigned char) ((context->state[0] >> 16) & 0xff);
|
||||
digest[6] = (unsigned char) ((context->state[0] >> 8) & 0xff);
|
||||
digest[7] = (unsigned char) (context->state[0] & 0xff);
|
||||
digest[8] = (unsigned char) ((context->state[1] >> 56) & 0xff);
|
||||
digest[9] = (unsigned char) ((context->state[1] >> 48) & 0xff);
|
||||
digest[10] = (unsigned char) ((context->state[1] >> 40) & 0xff);
|
||||
digest[11] = (unsigned char) ((context->state[1] >> 32) & 0xff);
|
||||
digest[12] = (unsigned char) ((context->state[1] >> 24) & 0xff);
|
||||
digest[13] = (unsigned char) ((context->state[1] >> 16) & 0xff);
|
||||
digest[14] = (unsigned char) ((context->state[1] >> 8) & 0xff);
|
||||
digest[15] = (unsigned char) (context->state[1] & 0xff);
|
||||
digest[16] = (unsigned char) ((context->state[2] >> 56) & 0xff);
|
||||
digest[17] = (unsigned char) ((context->state[2] >> 48) & 0xff);
|
||||
digest[18] = (unsigned char) ((context->state[2] >> 40) & 0xff);
|
||||
digest[19] = (unsigned char) ((context->state[2] >> 32) & 0xff);
|
||||
|
||||
TigerDigest(digest, 20, context);
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_TIGER192Final(unsigned char digest[24], PHP_TIGER_CTX *context)
|
||||
{
|
||||
TigerFinalize(context);
|
||||
|
||||
digest[0] = (unsigned char) ((context->state[0] >> 56) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state[0] >> 48) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state[0] >> 40) & 0xff);
|
||||
digest[3] = (unsigned char) ((context->state[0] >> 32) & 0xff);
|
||||
digest[4] = (unsigned char) ((context->state[0] >> 24) & 0xff);
|
||||
digest[5] = (unsigned char) ((context->state[0] >> 16) & 0xff);
|
||||
digest[6] = (unsigned char) ((context->state[0] >> 8) & 0xff);
|
||||
digest[7] = (unsigned char) (context->state[0] & 0xff);
|
||||
digest[8] = (unsigned char) ((context->state[1] >> 56) & 0xff);
|
||||
digest[9] = (unsigned char) ((context->state[1] >> 48) & 0xff);
|
||||
digest[10] = (unsigned char) ((context->state[1] >> 40) & 0xff);
|
||||
digest[11] = (unsigned char) ((context->state[1] >> 32) & 0xff);
|
||||
digest[12] = (unsigned char) ((context->state[1] >> 24) & 0xff);
|
||||
digest[13] = (unsigned char) ((context->state[1] >> 16) & 0xff);
|
||||
digest[14] = (unsigned char) ((context->state[1] >> 8) & 0xff);
|
||||
digest[15] = (unsigned char) (context->state[1] & 0xff);
|
||||
digest[16] = (unsigned char) ((context->state[2] >> 56) & 0xff);
|
||||
digest[17] = (unsigned char) ((context->state[2] >> 48) & 0xff);
|
||||
digest[18] = (unsigned char) ((context->state[2] >> 40) & 0xff);
|
||||
digest[19] = (unsigned char) ((context->state[2] >> 32) & 0xff);
|
||||
digest[20] = (unsigned char) ((context->state[2] >> 24) & 0xff);
|
||||
digest[21] = (unsigned char) ((context->state[2] >> 16) & 0xff);
|
||||
digest[22] = (unsigned char) ((context->state[2] >> 8) & 0xff);
|
||||
digest[23] = (unsigned char) (context->state[2] & 0xff);
|
||||
|
||||
TigerDigest(digest, 24, context);
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,6 @@ extern const php_hash_ops php_hash_gost_ops;
|
||||
extern const php_hash_ops php_hash_adler32_ops;
|
||||
extern const php_hash_ops php_hash_crc32_ops;
|
||||
extern const php_hash_ops php_hash_crc32b_ops;
|
||||
extern const php_hash_ops php_hash_salsa10_ops;
|
||||
extern const php_hash_ops php_hash_salsa20_ops;
|
||||
extern const php_hash_ops php_hash_fnv132_ops;
|
||||
extern const php_hash_ops php_hash_fnv164_ops;
|
||||
extern const php_hash_ops php_hash_joaat_ops;
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2012 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_SALSA_H
|
||||
#define PHP_HASH_SALSA_H
|
||||
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
/* SALSA context */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[16];
|
||||
unsigned char init:1;
|
||||
unsigned char length:7;
|
||||
unsigned char buffer[64];
|
||||
void (*Transform)(php_hash_uint32 state[16], php_hash_uint32 data[16]);
|
||||
} PHP_SALSA_CTX;
|
||||
|
||||
#define PHP_SALSAInit PHP_SALSA20Init
|
||||
PHP_HASH_API void PHP_SALSA10Init(PHP_SALSA_CTX *);
|
||||
PHP_HASH_API void PHP_SALSA20Init(PHP_SALSA_CTX *);
|
||||
|
||||
PHP_HASH_API void PHP_SALSAUpdate(PHP_SALSA_CTX *, const unsigned char *, size_t);
|
||||
PHP_HASH_API void PHP_SALSAFinal(unsigned char[64], PHP_SALSA_CTX *);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
@ -18,96 +18,92 @@ var_dump(hash_algos());
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash_algos() : basic functionality ***
|
||||
array(45) {
|
||||
[0]=>
|
||||
array(43) {
|
||||
[%d]=>
|
||||
string(3) "md2"
|
||||
[1]=>
|
||||
[%d]=>
|
||||
string(3) "md4"
|
||||
[2]=>
|
||||
[%d]=>
|
||||
string(3) "md5"
|
||||
[3]=>
|
||||
[%d]=>
|
||||
string(4) "sha1"
|
||||
[4]=>
|
||||
[%d]=>
|
||||
string(6) "sha224"
|
||||
[5]=>
|
||||
[%d]=>
|
||||
string(6) "sha256"
|
||||
[6]=>
|
||||
[%d]=>
|
||||
string(6) "sha384"
|
||||
[7]=>
|
||||
[%d]=>
|
||||
string(6) "sha512"
|
||||
[8]=>
|
||||
[%d]=>
|
||||
string(9) "ripemd128"
|
||||
[9]=>
|
||||
[%d]=>
|
||||
string(9) "ripemd160"
|
||||
[10]=>
|
||||
[%d]=>
|
||||
string(9) "ripemd256"
|
||||
[11]=>
|
||||
[%d]=>
|
||||
string(9) "ripemd320"
|
||||
[12]=>
|
||||
[%d]=>
|
||||
string(9) "whirlpool"
|
||||
[13]=>
|
||||
[%d]=>
|
||||
string(10) "tiger128,3"
|
||||
[14]=>
|
||||
[%d]=>
|
||||
string(10) "tiger160,3"
|
||||
[15]=>
|
||||
[%d]=>
|
||||
string(10) "tiger192,3"
|
||||
[16]=>
|
||||
[%d]=>
|
||||
string(10) "tiger128,4"
|
||||
[17]=>
|
||||
[%d]=>
|
||||
string(10) "tiger160,4"
|
||||
[18]=>
|
||||
[%d]=>
|
||||
string(10) "tiger192,4"
|
||||
[19]=>
|
||||
[%d]=>
|
||||
string(6) "snefru"
|
||||
[20]=>
|
||||
[%d]=>
|
||||
string(9) "snefru256"
|
||||
[21]=>
|
||||
[%d]=>
|
||||
string(4) "gost"
|
||||
[22]=>
|
||||
[%d]=>
|
||||
string(7) "adler32"
|
||||
[23]=>
|
||||
[%d]=>
|
||||
string(5) "crc32"
|
||||
[24]=>
|
||||
[%d]=>
|
||||
string(6) "crc32b"
|
||||
[25]=>
|
||||
string(7) "salsa10"
|
||||
[26]=>
|
||||
string(7) "salsa20"
|
||||
[27]=>
|
||||
[%d]=>
|
||||
string(6) "fnv132"
|
||||
[28]=>
|
||||
[%d]=>
|
||||
string(6) "fnv164"
|
||||
[29]=>
|
||||
[%d]=>
|
||||
string(5) "joaat"
|
||||
[30]=>
|
||||
[%d]=>
|
||||
string(10) "haval128,3"
|
||||
[31]=>
|
||||
[%d]=>
|
||||
string(10) "haval160,3"
|
||||
[32]=>
|
||||
[%d]=>
|
||||
string(10) "haval192,3"
|
||||
[33]=>
|
||||
[%d]=>
|
||||
string(10) "haval224,3"
|
||||
[34]=>
|
||||
[%d]=>
|
||||
string(10) "haval256,3"
|
||||
[35]=>
|
||||
[%d]=>
|
||||
string(10) "haval128,4"
|
||||
[36]=>
|
||||
[%d]=>
|
||||
string(10) "haval160,4"
|
||||
[37]=>
|
||||
[%d]=>
|
||||
string(10) "haval192,4"
|
||||
[38]=>
|
||||
[%d]=>
|
||||
string(10) "haval224,4"
|
||||
[39]=>
|
||||
[%d]=>
|
||||
string(10) "haval256,4"
|
||||
[40]=>
|
||||
[%d]=>
|
||||
string(10) "haval128,5"
|
||||
[41]=>
|
||||
[%d]=>
|
||||
string(10) "haval160,5"
|
||||
[42]=>
|
||||
[%d]=>
|
||||
string(10) "haval192,5"
|
||||
[43]=>
|
||||
[%d]=>
|
||||
string(10) "haval224,5"
|
||||
[44]=>
|
||||
[%d]=>
|
||||
string(10) "haval256,5"
|
||||
}
|
||||
===Done===
|
@ -71,23 +71,23 @@ string(9) "whirlpool"
|
||||
string(128) "6e60597340640e621e25f975cef2b000b0c4c09a7af7d240a52d193002b0a8426fa7da7acc5b37ed9608016d4f396db834a0ea2f2c35f900461c9ac7e5604082"
|
||||
string(128) "6e60597340640e621e25f975cef2b000b0c4c09a7af7d240a52d193002b0a8426fa7da7acc5b37ed9608016d4f396db834a0ea2f2c35f900461c9ac7e5604082"
|
||||
string(10) "tiger128,3"
|
||||
string(32) "a92be6c58be7688dc6cf9585a47aa625"
|
||||
string(32) "a92be6c58be7688dc6cf9585a47aa625"
|
||||
string(32) "8d68e78bc5e62ba925a67aa48595cfc6"
|
||||
string(32) "8d68e78bc5e62ba925a67aa48595cfc6"
|
||||
string(10) "tiger160,3"
|
||||
string(40) "a92be6c58be7688dc6cf9585a47aa62535fc2482"
|
||||
string(40) "a92be6c58be7688dc6cf9585a47aa62535fc2482"
|
||||
string(40) "8d68e78bc5e62ba925a67aa48595cfc62cd1e5e0"
|
||||
string(40) "8d68e78bc5e62ba925a67aa48595cfc62cd1e5e0"
|
||||
string(10) "tiger192,3"
|
||||
string(48) "a92be6c58be7688dc6cf9585a47aa62535fc2482e0e5d12c"
|
||||
string(48) "a92be6c58be7688dc6cf9585a47aa62535fc2482e0e5d12c"
|
||||
string(48) "8d68e78bc5e62ba925a67aa48595cfc62cd1e5e08224fc35"
|
||||
string(48) "8d68e78bc5e62ba925a67aa48595cfc62cd1e5e08224fc35"
|
||||
string(10) "tiger128,4"
|
||||
string(32) "32fb748ef5a36ca222511bcb99b044ee"
|
||||
string(32) "32fb748ef5a36ca222511bcb99b044ee"
|
||||
string(32) "a26ca3f58e74fb32ee44b099cb1b5122"
|
||||
string(32) "a26ca3f58e74fb32ee44b099cb1b5122"
|
||||
string(10) "tiger160,4"
|
||||
string(40) "32fb748ef5a36ca222511bcb99b044ee1d740bf3"
|
||||
string(40) "32fb748ef5a36ca222511bcb99b044ee1d740bf3"
|
||||
string(40) "a26ca3f58e74fb32ee44b099cb1b512203375900"
|
||||
string(40) "a26ca3f58e74fb32ee44b099cb1b512203375900"
|
||||
string(10) "tiger192,4"
|
||||
string(48) "32fb748ef5a36ca222511bcb99b044ee1d740bf300593703"
|
||||
string(48) "32fb748ef5a36ca222511bcb99b044ee1d740bf300593703"
|
||||
string(48) "a26ca3f58e74fb32ee44b099cb1b512203375900f30b741d"
|
||||
string(48) "a26ca3f58e74fb32ee44b099cb1b512203375900f30b741d"
|
||||
string(6) "snefru"
|
||||
string(64) "fbe88daa74c89b9e29468fa3cd3a657d31845e21bb58dd3f8d806f5179a85c26"
|
||||
string(64) "fbe88daa74c89b9e29468fa3cd3a657d31845e21bb58dd3f8d806f5179a85c26"
|
||||
@ -106,12 +106,6 @@ string(8) "e5cfc160"
|
||||
string(6) "crc32b"
|
||||
string(8) "69147a4e"
|
||||
string(8) "69147a4e"
|
||||
string(7) "salsa10"
|
||||
string(128) "aa39bc97c2bbcb0d79bbebfddca0bf8d769c7919c9e537e456efb5fc67f33f161758dd9da3ddcec7bbbd9c04553a03f74d2dbd26175dd75c353e9300674caa4e"
|
||||
string(128) "aa39bc97c2bbcb0d79bbebfddca0bf8d769c7919c9e537e456efb5fc67f33f161758dd9da3ddcec7bbbd9c04553a03f74d2dbd26175dd75c353e9300674caa4e"
|
||||
string(7) "salsa20"
|
||||
string(128) "2ecbea42273e1e18affc7ef028674c8e55f9382f36de21e5fc38af76e4a7231d0a92feca9bdf586ac18d8a5bdd82be8a1cb1e9186871d6ff785c76a9090ac774"
|
||||
string(128) "2ecbea42273e1e18affc7ef028674c8e55f9382f36de21e5fc38af76e4a7231d0a92feca9bdf586ac18d8a5bdd82be8a1cb1e9186871d6ff785c76a9090ac774"
|
||||
string(6) "fnv132"
|
||||
string(8) "98139504"
|
||||
string(8) "98139504"
|
||||
@ -206,23 +200,23 @@ string(9) "whirlpool"
|
||||
string(128) "6e60597340640e621e25f975cef2b000b0c4c09a7af7d240a52d193002b0a8426fa7da7acc5b37ed9608016d4f396db834a0ea2f2c35f900461c9ac7e5604082"
|
||||
string(128) "e8c6a921e7d8eac2fd21d4df6054bb27a02321b2beb5b01b6f88c40706164e64d67ec97519bf76c8af8df896745478b78d42a0159f1a0db16777771fd9d420dc"
|
||||
string(10) "tiger128,3"
|
||||
string(32) "a92be6c58be7688dc6cf9585a47aa625"
|
||||
string(32) "dc80d448032c9da9f1e0262985353c0f"
|
||||
string(32) "8d68e78bc5e62ba925a67aa48595cfc6"
|
||||
string(32) "a99d2c0348d480dc0f3c35852926e0f1"
|
||||
string(10) "tiger160,3"
|
||||
string(40) "a92be6c58be7688dc6cf9585a47aa62535fc2482"
|
||||
string(40) "dc80d448032c9da9f1e0262985353c0fe37e9551"
|
||||
string(40) "8d68e78bc5e62ba925a67aa48595cfc62cd1e5e0"
|
||||
string(40) "a99d2c0348d480dc0f3c35852926e0f1e1825c16"
|
||||
string(10) "tiger192,3"
|
||||
string(48) "a92be6c58be7688dc6cf9585a47aa62535fc2482e0e5d12c"
|
||||
string(48) "dc80d448032c9da9f1e0262985353c0fe37e9551165c82e1"
|
||||
string(48) "8d68e78bc5e62ba925a67aa48595cfc62cd1e5e08224fc35"
|
||||
string(48) "a99d2c0348d480dc0f3c35852926e0f1e1825c1651957ee3"
|
||||
string(10) "tiger128,4"
|
||||
string(32) "32fb748ef5a36ca222511bcb99b044ee"
|
||||
string(32) "e5c4212432c0e266e581d4ee6a8e20a9"
|
||||
string(32) "a26ca3f58e74fb32ee44b099cb1b5122"
|
||||
string(32) "66e2c0322421c4e5a9208e6aeed481e5"
|
||||
string(10) "tiger160,4"
|
||||
string(40) "32fb748ef5a36ca222511bcb99b044ee1d740bf3"
|
||||
string(40) "e5c4212432c0e266e581d4ee6a8e20a9d0d944e3"
|
||||
string(40) "a26ca3f58e74fb32ee44b099cb1b512203375900"
|
||||
string(40) "66e2c0322421c4e5a9208e6aeed481e5c4b00448"
|
||||
string(10) "tiger192,4"
|
||||
string(48) "32fb748ef5a36ca222511bcb99b044ee1d740bf300593703"
|
||||
string(48) "e5c4212432c0e266e581d4ee6a8e20a9d0d944e34804b0c4"
|
||||
string(48) "a26ca3f58e74fb32ee44b099cb1b512203375900f30b741d"
|
||||
string(48) "66e2c0322421c4e5a9208e6aeed481e5c4b00448e344d9d0"
|
||||
string(6) "snefru"
|
||||
string(64) "fbe88daa74c89b9e29468fa3cd3a657d31845e21bb58dd3f8d806f5179a85c26"
|
||||
string(64) "614ca924864fa0e8fa309aa0944e047d5edbfd4964a35858f4d8ec66a0fb88b0"
|
||||
@ -241,12 +235,6 @@ string(8) "59f8d3d2"
|
||||
string(6) "crc32b"
|
||||
string(8) "69147a4e"
|
||||
string(8) "3ee63999"
|
||||
string(7) "salsa10"
|
||||
string(128) "aa39bc97c2bbcb0d79bbebfddca0bf8d769c7919c9e537e456efb5fc67f33f161758dd9da3ddcec7bbbd9c04553a03f74d2dbd26175dd75c353e9300674caa4e"
|
||||
string(128) "709b9196710f035e3602649fdae94f939775fa6a5a0bf01f9884d8af54579cafa01a81ee23d511b85d7fb11c4d827e4309953e3c844b8d66a80c57b6eaf2d8c1"
|
||||
string(7) "salsa20"
|
||||
string(128) "2ecbea42273e1e18affc7ef028674c8e55f9382f36de21e5fc38af76e4a7231d0a92feca9bdf586ac18d8a5bdd82be8a1cb1e9186871d6ff785c76a9090ac774"
|
||||
string(128) "272fd2209f237b9be674eb4917eda0bd978908d56190e62aec283585d6325d8fcbba2b616dd7ba90f93cc5ecdede7185d17a06467b2a17b5c836ee115974ca20"
|
||||
string(6) "fnv132"
|
||||
string(8) "98139504"
|
||||
string(8) "59ad036f"
|
||||
|
@ -77,7 +77,7 @@ sha256: a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245
|
||||
sha384: a35d875ed96d94b6452acad910f97978200faa2398d8a0e6b9cffa33704c3809e3d2e5b0d63700d8f32a0716e7d2d528
|
||||
sha512: 1f42adaf938fbf136e381b164bae5f984c7f9fe60c82728bd889c14f187c7d63e81a0305a1731c7e0a8f3ed9fd2ec92a3833a93502bdf269532601f0b8e2bab0
|
||||
snefru: d414b2345d3e7fa1a31c044cf334bfc1fec24d89e464411998d579d24663895f
|
||||
tiger192,3: c6fa75a0be4ecf7afa3cafb4e2a08efc3a40534c0e46b971
|
||||
tiger192,3: 7acf4ebea075fac6fc8ea0e2b4af3cfa71b9460e4c53403a
|
||||
whirlpool: 4248b149e000477269a4a5f1a84d97cfc3d0199b7aaf505913e6f010a6f83276029d11a9ad545374bc710eb59c7d958985023ab886ffa9ec9a23852844c764ec
|
||||
adler32(raw): ff87222e
|
||||
md5(raw): 704bf818448f5bbb94061332d2c889aa
|
||||
|
@ -58,7 +58,7 @@ sha256: 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838
|
||||
sha384: b781415b856744834e532b9899e1aa0bec5a82cf09a838f0a833470468e2a42648a52428cfd9012385d04de5cd9bd122
|
||||
sha512: 7de05636b18e2b0ca3427e03f53074af3a48a7b9df226daba4f22324c570638e7d7b26430e214799c9ce0db5ee88dad3292ca0f38bf99b8eaebed59b3a9c140a
|
||||
snefru: 67af483046f9cf16fe19f9087929ccfc6ad176ade3290b4d33f43e0ddb07e711
|
||||
tiger192,3: 82779797cdc439e886884953ba21fa38e35679041e95ee27
|
||||
tiger192,3: 00a0f884f15a9e5549ed0e40ca0190522d369027e16d5b59
|
||||
whirlpool: 4a0f1582b21b7aff59bfba7f9c29131c69741b2ce80acdc7d314040f3b768cf5a17e30b74cceb86fbc6b34b1692e0addd5bfd7cfc043d40c0621f1b97e26fa49
|
||||
adler32(raw): 12c803f7
|
||||
md5(raw): 2a632783e2812cf23de100d7d6a463ae
|
||||
|
@ -86,7 +86,7 @@ sha256: 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40
|
||||
sha384: 364fdc45a4c742763366ab5d3d1c17c24057e6c3b641607a36d969f00c88da25b19c8b88c8632411e3a0a02397f88aca
|
||||
sha512: d460aabdf0353655059ed0d408efa91f19c4cda46acc2a4e0adf4764b06951c899fbb2ed41519db78b58ff7be17b1b2910aebe674a56861b232143571b35c83f
|
||||
snefru: 7b79787e1c1d926b6cc98327f05c5d04ba6227ab51c1398661861196016ef34c
|
||||
tiger192,3: 5577f21e2af269fff41e023db30e2b01bfd8b8f669177929
|
||||
tiger192,3: ca89badf843ba68e3fae5832635aa848a72a4bc11676edd4
|
||||
whirlpool: 37a0fbb90547690d5e5e11c046f6654ffdb7bab15e16d9d79c7d85765cc4bdcbfd9df8db7a3ce9558f3f244fead00ca29cf05297f75596555195a0683f15d69f
|
||||
adler32(raw): 0f8c02f9
|
||||
md5(raw): 8bddf39dd1c566c27acc7fa85ec36acf
|
||||
|
@ -11,8 +11,9 @@ echo hash('tiger192,3', str_repeat('abc', 61)),"\n";
|
||||
echo hash('tiger192,3', str_repeat('abc', 64)),"\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
24f0130c63ac933216166e76b1bb925ff373de2d49584e7a
|
||||
f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951
|
||||
8ee409a14e6066933b63d5b2abca63d71a78f55e29eb4649
|
||||
2586156d16bf9ab1e6e48bdf5e038f8053c30e071db3bcb0
|
||||
3ee8a9405396ddba1bc038508af4164ac1fe59ef58916a85
|
||||
3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3
|
||||
2aab1484e8c158f2bfb8c5ff41b57a525129131c957b5f93
|
||||
9366604ea109e48ed763caabb2d5633b4946eb295ef5781a
|
||||
b19abf166d158625808f035edf8be4e6b0bcb31d070ec353
|
||||
badd965340a9e83e4a16f48a5038c01b856a9158ef59fec1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user