#include <string.h>
#include <stdio.h>
#include "xyssl/md4.h"
Go to the source code of this file.
Defines | |
#define | _CRT_SECURE_NO_DEPRECATE 1 |
#define | GET_UINT32_LE(n, b, i) |
#define | PUT_UINT32_LE(n, b, i) |
#define | S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) |
#define | F(x, y, z) ((x & y) | ((~x) & z)) |
#define | P(a, b, c, d, x, s) { a += F(b,c,d) + x; a = S(a,s); } |
#define | F(x, y, z) ((x & y) | (x & z) | (y & z)) |
#define | P(a, b, c, d, x, s) { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); } |
#define | F(x, y, z) (x ^ y ^ z) |
#define | P(a, b, c, d, x, s) { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); } |
Functions | |
void | md4_starts (md4_context *ctx) |
MD4 context setup. | |
static void | md4_process (md4_context *ctx, unsigned char data[64]) |
void | md4_update (md4_context *ctx, unsigned char *input, int ilen) |
MD4 process buffer. | |
void | md4_finish (md4_context *ctx, unsigned char *output) |
MD4 final digest. | |
void | md4 (unsigned char *input, int ilen, unsigned char *output) |
Output = MD4( input buffer ). | |
int | md4_file (char *path, unsigned char *output) |
Output = MD4( file contents ). | |
void | md4_hmac_starts (md4_context *ctx, unsigned char *key, int keylen) |
MD4 HMAC context setup. | |
void | md4_hmac_update (md4_context *ctx, unsigned char *input, int ilen) |
MD4 HMAC process buffer. | |
void | md4_hmac_finish (md4_context *ctx, unsigned char *output) |
MD4 HMAC final digest. | |
void | md4_hmac (unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char *output) |
Output = HMAC-MD4( hmac key, input buffer ). | |
int | md4_self_test (int verbose) |
Checkup routine. | |
Variables | |
static const unsigned char | md4_padding [64] |
static const char | _md4_src [] = "_md4_src" |
#define F | ( | x, | |||
y, | |||||
z | ) | (x ^ y ^ z) |
#define F | ( | x, | |||
y, | |||||
z | ) | ((x & y) | (x & z) | (y & z)) |
#define F | ( | x, | |||
y, | |||||
z | ) | ((x & y) | ((~x) & z)) |
Referenced by sha2_process(), and sha4_process().
#define GET_UINT32_LE | ( | n, | |||
b, | |||||
i | ) |
Value:
{ \ (n) = ( (unsigned long) (b)[(i) ] ) \ | ( (unsigned long) (b)[(i) + 1] << 8 ) \ | ( (unsigned long) (b)[(i) + 2] << 16 ) \ | ( (unsigned long) (b)[(i) + 3] << 24 ); \ }
Definition at line 40 of file md4.c.
Referenced by md4_process(), and md5_process().
#define P | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
x, | |||||
s | ) | { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); } |
#define P | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
x, | |||||
s | ) | { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); } |
#define P | ( | a, | |||
b, | |||||
c, | |||||
d, | |||||
x, | |||||
s | ) | { a += F(b,c,d) + x; a = S(a,s); } |
Referenced by main(), md4_process(), md5_process(), sha1_process(), sha2_process(), and sha4_process().
#define PUT_UINT32_LE | ( | n, | |||
b, | |||||
i | ) |
Value:
{ \ (b)[(i) ] = (unsigned char) ( (n) ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \ }
Definition at line 50 of file md4.c.
Referenced by md4_finish(), and md5_finish().
#define S | ( | x, | |||
n | ) | ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) |
void md4 | ( | unsigned char * | input, | |
int | ilen, | |||
unsigned char * | output | |||
) |
Output = MD4( input buffer ).
input | buffer holding the data | |
ilen | length of the input data | |
output | MD4 checksum result |
Definition at line 259 of file md4.c.
References md4_finish(), md4_starts(), and md4_update().
Referenced by main(), and x509_hash().
int md4_file | ( | char * | path, | |
unsigned char * | output | |||
) |
Output = MD4( file contents ).
path | input file name | |
output | MD4 checksum result |
Definition at line 274 of file md4.c.
References f, md4_finish(), md4_starts(), and md4_update().
void md4_finish | ( | md4_context * | ctx, | |
unsigned char * | output | |||
) |
MD4 final digest.
ctx | MD4 context | |
output | MD4 checksum result |
Definition at line 231 of file md4.c.
References md4_padding, md4_update(), PUT_UINT32_LE, md4_context::state, and md4_context::total.
Referenced by md4(), md4_file(), and md4_hmac_finish().
void md4_hmac | ( | unsigned char * | key, | |
int | keylen, | |||
unsigned char * | input, | |||
int | ilen, | |||
unsigned char * | output | |||
) |
Output = HMAC-MD4( hmac key, input buffer ).
key | HMAC secret key | |
keylen | length of the HMAC key | |
input | buffer holding the data | |
ilen | length of the input data | |
output | HMAC-MD4 result |
Definition at line 354 of file md4.c.
References md4_hmac_finish(), md4_hmac_starts(), and md4_hmac_update().
void md4_hmac_finish | ( | md4_context * | ctx, | |
unsigned char * | output | |||
) |
MD4 HMAC final digest.
ctx | HMAC context | |
output | MD4 HMAC checksum result |
Definition at line 338 of file md4.c.
References md4_finish(), md4_starts(), md4_update(), and md4_context::opad.
Referenced by md4_hmac().
void md4_hmac_starts | ( | md4_context * | ctx, | |
unsigned char * | key, | |||
int | keylen | |||
) |
MD4 HMAC context setup.
ctx | HMAC context to be initialized | |
key | HMAC secret key | |
keylen | length of the HMAC key |
Definition at line 306 of file md4.c.
References md4_context::ipad, md4_starts(), md4_update(), and md4_context::opad.
Referenced by md4_hmac().
void md4_hmac_update | ( | md4_context * | ctx, | |
unsigned char * | input, | |||
int | ilen | |||
) |
MD4 HMAC process buffer.
ctx | HMAC context | |
input | buffer holding the data | |
ilen | length of the input data |
Definition at line 329 of file md4.c.
References md4_update().
Referenced by md4_hmac().
static void md4_process | ( | md4_context * | ctx, | |
unsigned char | data[64] | |||
) | [static] |
Definition at line 73 of file md4.c.
References GET_UINT32_LE, P, and md4_context::state.
Referenced by md4_update().
void md4_starts | ( | md4_context * | ctx | ) |
MD4 context setup.
ctx | context to be initialized |
Definition at line 62 of file md4.c.
References md4_context::state, and md4_context::total.
Referenced by md4(), md4_file(), md4_hmac_finish(), and md4_hmac_starts().
void md4_update | ( | md4_context * | ctx, | |
unsigned char * | input, | |||
int | ilen | |||
) |
MD4 process buffer.
ctx | MD4 context | |
input | buffer holding the data | |
ilen | length of the input data |
Definition at line 179 of file md4.c.
References md4_context::buffer, md4_process(), and md4_context::total.
Referenced by md4(), md4_file(), md4_finish(), md4_hmac_finish(), md4_hmac_starts(), and md4_hmac_update().
const unsigned char md4_padding[64] [static] |
Initial value:
{ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
Definition at line 220 of file md4.c.
Referenced by md4_finish().