librsync
2.3.2
|
MD4 message digest algorithm. More...
Go to the source code of this file.
Macros | |
#define | F(X, Y, Z) (((X)&(Y)) | ((~(X))&(Z))) |
#define | G(X, Y, Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z))) |
#define | H(X, Y, Z) ((X)^(Y)^(Z)) |
#define | lshift(x, s) (((x)<<(s)) | ((x)>>(32-(s)))) |
#define | ROUND1(a, b, c, d, k, s) a = lshift(a + F(b,c,d) + X[k], s) |
#define | ROUND2(a, b, c, d, k, s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999U, s) |
#define | ROUND3(a, b, c, d, k, s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1U, s) |
Functions | |
static void | rs_mdfour_block (rs_mdfour_t *md, void const *p) |
static void | rs_mdfour64 (rs_mdfour_t *m, const void *p) |
Update an MD4 accumulator from a 64-byte chunk. | |
static void | copy4 (unsigned char *out, uint32_t const x) |
These next routines are necessary because MD4 is specified in terms of little-endian int32s, but we have a byte buffer. | |
void | rs_mdfour_begin (rs_mdfour_t *md) |
static void | rs_mdfour_tail (rs_mdfour_t *m) |
Handle special behaviour for processing the last block of a file when calculating its MD4 checksum. | |
void | rs_mdfour_update (rs_mdfour_t *md, void const *in_void, size_t n) |
Feed some data into the MD4 accumulator. | |
void | rs_mdfour_result (rs_mdfour_t *md, unsigned char *out) |
void | rs_mdfour (unsigned char *out, void const *in, size_t n) |
Variables | |
static unsigned char | PADDING [64] |
padding data used for finalising | |
MD4 message digest algorithm.
This was originally written by Andrew Tridgell for use in Samba. It was then modified by;
2002-06-xx: Robert Weber rober.nosp@m.t.we.nosp@m.ber@C.nosp@m.olor.nosp@m.ado.e.nosp@m.du optimisations and fixed >512M support.
2002-06-27: Donovan Baarda abo@m.nosp@m.inki.nosp@m.rri.a.nosp@m.pana.nosp@m..org..nosp@m.au further optimisations and cleanups.
2004-09-09: Simon Law sflla.nosp@m.w@de.nosp@m.bian..nosp@m.org handle little-endian machines that can't do unaligned access (e.g. ia64, pa-risc).
Definition in file mdfour.c.
#define ROUND1 | ( | a, | |
b, | |||
c, | |||
d, | |||
k, | |||
s | |||
) | a = lshift(a + F(b,c,d) + X[k], s) |
#define ROUND2 | ( | a, | |
b, | |||
c, | |||
d, | |||
k, | |||
s | |||
) | a = lshift(a + G(b,c,d) + X[k] + 0x5A827999U, s) |
#define ROUND3 | ( | a, | |
b, | |||
c, | |||
d, | |||
k, | |||
s | |||
) | a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1U, s) |
|
inlinestatic |
|
static |
Update an MD4 accumulator from a 64-byte chunk.
This cannot be used for the last chunk of the file, which must be padded and contain the file length. rs_mdfour_tail() is used for that.
*m | An rs_mdfour_t instance to accumulate with. |
*p | An array of uint32 integers, as read little-endian from the file. |
|
inlinestatic |
These next routines are necessary because MD4 is specified in terms of little-endian int32s, but we have a byte buffer.
On little-endian platforms, I think we can just use the buffer pointer directly.
There are some nice endianness routines in glib, including assembler variants. If we ever depended on glib, then it could be good to use them instead.
void rs_mdfour_begin | ( | rs_mdfour_t * | md | ) |
|
static |
Handle special behaviour for processing the last block of a file when calculating its MD4 checksum.
This must be called exactly once per file.
Modified by Robert Weber to use uint64 in order that we can sum files > 2^29 = 512 MB. –Rober.nosp@m.t.We.nosp@m.ber@c.nosp@m.olor.nosp@m.ado.e.nosp@m.du
void rs_mdfour_update | ( | rs_mdfour_t * | md, |
void const * | in_void, | ||
size_t | n | ||
) |
void rs_mdfour_result | ( | rs_mdfour_t * | md, |
unsigned char * | out | ||
) |
void rs_mdfour | ( | unsigned char * | out, |
void const * | in, | ||
size_t | n | ||
) |
|
static |