Back to index

php5  5.3.10
Classes | Functions
php_hash_snefru.h File Reference
#include "ext/standard/basic_functions.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PHP_SNEFRU_CTX

Functions

PHP_HASH_API void PHP_SNEFRUInit (PHP_SNEFRU_CTX *)
PHP_HASH_API void PHP_SNEFRUUpdate (PHP_SNEFRU_CTX *, const unsigned char *, size_t)
PHP_HASH_API void PHP_SNEFRUFinal (unsigned char[32], PHP_SNEFRU_CTX *)

Class Documentation

struct PHP_SNEFRU_CTX

Definition at line 31 of file php_hash_snefru.h.

Class Members
unsigned char buffer
php_hash_uint32 count
unsigned char length
php_hash_uint32 state

Function Documentation

PHP_HASH_API void PHP_SNEFRUFinal ( unsigned  char[32],
PHP_SNEFRU_CTX  
)

Definition at line 174 of file hash_snefru.c.

{
       php_hash_uint32 i, j;
       
       if (context->length) {
              SnefruTransform(context, context->buffer);
       }
       
       context->state[14] = context->count[0];
       context->state[15] = context->count[1];
       Snefru(context->state);
       
       for (i = 0, j = 0; j < 32; 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));
}

Here is the call graph for this function:

Definition at line 135 of file hash_snefru.c.

{
       memset(context, 0, sizeof(*context));
}
PHP_HASH_API void PHP_SNEFRUUpdate ( PHP_SNEFRU_CTX ,
const unsigned char *  ,
size_t   
)

Definition at line 142 of file hash_snefru.c.

{
       if ((MAX32 - context->count[1]) < (len * 8)) {
              context->count[0]++;
              context->count[1] = MAX32 - context->count[1];
              context->count[1] = (len * 8) - context->count[1];
       } else {
              context->count[1] += len * 8;
       }
       
       if (context->length + len < 32) {
              memcpy(&context->buffer[context->length], input, len);
              context->length += len;
       } else {
              size_t i = 0, r = (context->length + len) % 32;
              
              if (context->length) {
                     i = 32 - context->length;
                     memcpy(&context->buffer[context->length], input, i);
                     SnefruTransform(context, context->buffer);
              }
              
              for (; i + 32 <= len; i += 32) {
                     SnefruTransform(context, input + i);
              }
              
              memcpy(context->buffer, input + i, r);
              memset(&context->buffer[r], 0, 32 - r);
              context->length = r;
       }
}

Here is the call graph for this function: