Back to index

php5  5.3.10
Classes | Defines | Functions
php_hash_salsa.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_SALSA_CTX

Defines

#define PHP_SALSAInit   PHP_SALSA20Init

Functions

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 *)

Define Documentation

Definition at line 35 of file php_hash_salsa.h.


Function Documentation

Definition at line 143 of file hash_salsa.c.

{
       memset(context, 0, sizeof(*context));
       context->Transform = Salsa10;
}

Here is the call graph for this function:

Definition at line 149 of file hash_salsa.c.

{
       memset(context, 0, sizeof(*context));
       context->Transform = Salsa20;
}

Here is the call graph for this function:

PHP_HASH_API void PHP_SALSAFinal ( unsigned  char[64],
PHP_SALSA_CTX  
)

Definition at line 179 of file hash_salsa.c.

{
       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));
}

Here is the call graph for this function:

PHP_HASH_API void PHP_SALSAUpdate ( PHP_SALSA_CTX ,
const unsigned char *  ,
size_t   
)

Definition at line 155 of file hash_salsa.c.

{
       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;
       }
}

Here is the call graph for this function: