Back to index

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

Go to the source code of this file.

Classes

struct  PHP_MD4_CTX
struct  PHP_MD2_CTX

Functions

PHP_HASH_API void PHP_MD4Init (PHP_MD4_CTX *)
PHP_HASH_API void PHP_MD4Update (PHP_MD4_CTX *context, const unsigned char *, unsigned int)
PHP_HASH_API void PHP_MD4Final (unsigned char[16], PHP_MD4_CTX *)
PHP_HASH_API void PHP_MD2Init (PHP_MD2_CTX *context)
PHP_HASH_API void PHP_MD2Update (PHP_MD2_CTX *context, const unsigned char *, unsigned int)
PHP_HASH_API void PHP_MD2Final (unsigned char[16], PHP_MD2_CTX *)

Class Documentation

struct PHP_MD4_CTX

Definition at line 78 of file php_hash_md.h.

Class Members
unsigned char buffer
php_hash_uint32 count
php_hash_uint32 state
struct PHP_MD2_CTX

Definition at line 89 of file php_hash_md.h.

Class Members
unsigned char buffer
unsigned char checksum
char in_buffer
unsigned char state

Function Documentation

PHP_HASH_API void PHP_MD2Final ( unsigned  char[16],
PHP_MD2_CTX  
)

Definition at line 688 of file hash_md.c.

{
       memset(context->buffer + context->in_buffer, 16 - context->in_buffer, 16 - context->in_buffer);
       MD2_Transform(context, context->buffer);
       MD2_Transform(context, context->checksum);

       memcpy(output, context->state, 16);
}

Here is the call graph for this function:

PHP_HASH_API void PHP_MD2Init ( PHP_MD2_CTX context)

Definition at line 629 of file hash_md.c.

{
       memset(context, 0, sizeof(PHP_MD2_CTX));
}
PHP_HASH_API void PHP_MD2Update ( PHP_MD2_CTX context,
const unsigned char *  ,
unsigned  int 
)

Definition at line 657 of file hash_md.c.

{
       const unsigned char *p = buf, *e = buf + len;

       if (context->in_buffer) {
              if (context->in_buffer + len < 16) {
                     /* Not enough for block, just pass into buffer */
                     memcpy(context->buffer + context->in_buffer, p, len);
                     context->in_buffer += len;
                     return;
              }
              /* Put buffered data together with inbound for a single block */
              memcpy(context->buffer + context->in_buffer, p, 16 - context->in_buffer);
              MD2_Transform(context, context->buffer);
              p += 16 - context->in_buffer;
              context->in_buffer = 0;
       }

       /* Process as many whole blocks as remain */
       while ((p + 16) <= e) {
              MD2_Transform(context, p);
              p += 16;
       }

       /* Copy remaining data to buffer */
       if (p < e) {
              memcpy(context->buffer, p, e - p);
              context->in_buffer = e - p;
       }
}

Here is the call graph for this function:

PHP_HASH_API void PHP_MD4Final ( unsigned  char[16],
PHP_MD4_CTX  
)

Definition at line 583 of file hash_md.c.

{
       unsigned char bits[8];
       unsigned int index, padLen;

       /* Save number of bits */
       Encode(bits, context->count, 8);

       /* Pad out to 56 mod 64.
        */
       index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
       padLen = (index < 56) ? (56 - index) : (120 - index);
       PHP_MD4Update(context, PADDING, padLen);

       /* Append length (before padding) */
       PHP_MD4Update(context, bits, 8);

       /* Store state in digest */
       Encode(digest, context->state, 16);

       /* Zeroize sensitive information.
        */
       memset((unsigned char*) context, 0, sizeof(*context));
}

Here is the call graph for this function:

Definition at line 527 of file hash_md.c.

{
       context->count[0] = context->count[1] = 0;
       /* Load magic initialization constants.
        */
       context->state[0] = 0x67452301;
       context->state[1] = 0xefcdab89;
       context->state[2] = 0x98badcfe;
       context->state[3] = 0x10325476;
}
PHP_HASH_API void PHP_MD4Update ( PHP_MD4_CTX context,
const unsigned char *  ,
unsigned  int 
)

Definition at line 544 of file hash_md.c.

{
       unsigned int i, index, partLen;

       /* Compute number of bytes mod 64 */
       index = (unsigned int) ((context->count[0] >> 3) & 0x3F);

       /* Update number of bits */
       if ((context->count[0] += ((php_hash_uint32) inputLen << 3))
              < ((php_hash_uint32) inputLen << 3))
              context->count[1]++;
       context->count[1] += ((php_hash_uint32) inputLen >> 29);

       partLen = 64 - index;

       /* Transform as many times as possible.
        */
       if (inputLen >= partLen) {
              memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
              MD4Transform(context->state, context->buffer);

              for (i = partLen; i + 63 < inputLen; i += 64) {
                     MD4Transform(context->state, &input[i]);
              }

              index = 0;
       } else {
              i = 0;
       }

       /* Buffer remaining input */
       memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
}

Here is the call graph for this function:

Here is the caller graph for this function: