Back to index

lightning-sunbird  0.9+nobinonly
md4.h File Reference
#include "prtypes.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


void md4sum (const PRUint8 *input, PRUint32 inputLen, PRUint8 *result)
 md4sum - computes the MD4 sum over the input buffer per RFC 1320

Function Documentation

void md4sum ( const PRUint8 input,
PRUint32  inputLen,
PRUint8 result 

md4sum - computes the MD4 sum over the input buffer per RFC 1320

inputbuffer containing input data
inputLenlength of input buffer (number of bytes)
result16-byte buffer that will contain the MD4 sum upon return

NOTE: MD4 is superceded by MD5. do not use MD4 unless required by the protocol you are implementing (e.g., NTLM requires MD4).

NOTE: this interface is designed for relatively small buffers. A streaming interface would make more sense if that were a requirement. Currently, this is good enough for the applications we care about.

Definition at line 138 of file md4.c.

  Uint8 final[128];
  Uint32 i, n, m, state[4];

  /* magic initial states */
  state[0] = 0x67452301;
  state[1] = 0xEFCDAB89;
  state[2] = 0x98BADCFE;
  state[3] = 0x10325476;

  /* compute number of complete 64-byte segments contained in input */
  m = inputLen >> 6;

  /* digest first m segments */
  for (i=0; i<m; ++i)
    md4step(state, (input + (i << 6)));

  /* build final buffer */
  n = inputLen % 64;
  memcpy(final, input + (m << 6), n);
  final[n] = 0x80;
  memset(final + n + 1, 0, 120 - (n + 1));

  inputLen = inputLen << 3;
  w2b(final + (n >= 56 ? 120 : 56), &inputLen, 4);

  md4step(state, final);
  if (n >= 56)
    md4step(state, final + 64);

  /* copy state to result */
  w2b(result, state, 16);

Here is the call graph for this function:

Here is the caller graph for this function: