|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
MD4 / MD5 / HMAC-MD5 implementation (see md.h). Little-endian word order. More...
#include "crypto/hash/md.h"#include "crypto/crypto_opt.h"#include "server/mmgr/secure.h"#include "shared_primitives/endian.h"#include <string.h>Go to the source code of this file.
Classes | |
| struct | MdCtx |
Macros | |
| #define | F4(X, Y, Z) (((X) & (Y)) | (~(X) & (Z))) |
| #define | G4(X, Y, Z) (((X) & (Y)) | ((X) & (Z)) | ((Y) & (Z))) |
| #define | H4(X, Y, Z) ((X) ^ (Y) ^ (Z)) |
| #define | R1(A, B, C, D, K, S) A = rotl((uint32_t)(A + F4(B, C, D) + x[K]), S) |
| #define | R2(A, B, C, D, K, S) A = rotl((uint32_t)(A + G4(B, C, D) + x[K] + 0x5a827999u), S) |
| #define | R3(A, B, C, D, K, S) A = rotl((uint32_t)(A + H4(B, C, D) + x[K] + 0x6ed9eba1u), S) |
Typedefs | |
| using | md_compress_fn = void(*)(uint32_t[4], const uint8_t[64]) |
Functions | |
| MdCtx * | pc_md_wants (void) |
| Storage this module wants for one MD4/MD5 context. | |
| void | pc_md5_init (MdCtx *c) |
| void | pc_md4_init (MdCtx *c) |
| void | pc_md5_update (MdCtx *c, const uint8_t *data, size_t len) |
| void | pc_md5_final (MdCtx *c, uint8_t out[16]) |
| void | pc_md4_update (MdCtx *c, const uint8_t *data, size_t len) |
| void | pc_md4_final (MdCtx *c, uint8_t out[16]) |
| void | md5 (const uint8_t *data, size_t len, uint8_t out[16]) |
| One-shot MD5. | |
| void | md4 (const uint8_t *data, size_t len, uint8_t out[16]) |
| One-shot MD4 (the NT-hash primitive). | |
| void | pc_hmac_md5 (const uint8_t *key, size_t key_len, const uint8_t *msg, size_t msg_len, uint8_t out[16]) |
| HMAC-MD5 (RFC 2104): the NTLMv2 MAC primitive. | |
MD4 / MD5 / HMAC-MD5 implementation (see md.h). Little-endian word order.
Definition in file md.cpp.
| #define F4 | ( | X, | |
| Y, | |||
| Z | |||
| ) | (((X) & (Y)) | (~(X) & (Z))) |
| #define G4 | ( | X, | |
| Y, | |||
| Z | |||
| ) | (((X) & (Y)) | ((X) & (Z)) | ((Y) & (Z))) |
| #define H4 | ( | X, | |
| Y, | |||
| Z | |||
| ) | ((X) ^ (Y) ^ (Z)) |
| #define R1 | ( | A, | |
| B, | |||
| C, | |||
| D, | |||
| K, | |||
| S | |||
| ) | A = rotl((uint32_t)(A + F4(B, C, D) + x[K]), S) |
| #define R2 | ( | A, | |
| B, | |||
| C, | |||
| D, | |||
| K, | |||
| S | |||
| ) | A = rotl((uint32_t)(A + G4(B, C, D) + x[K] + 0x5a827999u), S) |
| #define R3 | ( | A, | |
| B, | |||
| C, | |||
| D, | |||
| K, | |||
| S | |||
| ) | A = rotl((uint32_t)(A + H4(B, C, D) + x[K] + 0x6ed9eba1u), S) |
| using md_compress_fn = void (*)(uint32_t[4], const uint8_t[64]) |
| MdCtx * pc_md_wants | ( | void | ) |
Storage this module wants for one MD4/MD5 context.
The type is opaque, so a consumer cannot size it - this module owns the definition and therefore owns the allocation. Call inside a SecureScope: the scope states how long the caller needs the resource, and the pool wipes the digest state when that scope ends. MD4/MD5 here carry NTLM password and session-key material, so the storage comes from the secure pool.
Definition at line 28 of file md.cpp.
References pc_span::buf, pc_secure_span(), and pc_span_ok().
| void pc_md5_init | ( | MdCtx * | c | ) |
Definition at line 103 of file md.cpp.
References MdCtx::bits, MdCtx::buf_len, and MdCtx::state.
Referenced by md5(), and pc_hmac_md5().
| void pc_md4_init | ( | MdCtx * | c | ) |
Definition at line 192 of file md.cpp.
References MdCtx::bits, MdCtx::buf_len, and MdCtx::state.
Referenced by md4().
| void pc_md5_update | ( | MdCtx * | c, |
| const uint8_t * | data, | ||
| size_t | len | ||
| ) |
Definition at line 250 of file md.cpp.
Referenced by md5(), and pc_hmac_md5().
| void pc_md5_final | ( | MdCtx * | c, |
| uint8_t | out[16] | ||
| ) |
Definition at line 254 of file md.cpp.
Referenced by md5(), and pc_hmac_md5().
| void pc_md4_update | ( | MdCtx * | c, |
| const uint8_t * | data, | ||
| size_t | len | ||
| ) |
| void pc_md4_final | ( | MdCtx * | c, |
| uint8_t | out[16] | ||
| ) |
| void md5 | ( | const uint8_t * | data, |
| size_t | len, | ||
| uint8_t | out[16] | ||
| ) |
One-shot MD5.
Definition at line 267 of file md.cpp.
References pc_md5_final(), pc_md5_init(), and pc_md5_update().
Referenced by pc_hmac_md5().
| void md4 | ( | const uint8_t * | data, |
| size_t | len, | ||
| uint8_t | out[16] | ||
| ) |
One-shot MD4 (the NT-hash primitive).
Definition at line 274 of file md.cpp.
References pc_md4_final(), pc_md4_init(), and pc_md4_update().
| void pc_hmac_md5 | ( | const uint8_t * | key, |
| size_t | key_len, | ||
| const uint8_t * | msg, | ||
| size_t | msg_len, | ||
| uint8_t | out[16] | ||
| ) |
HMAC-MD5 (RFC 2104): the NTLMv2 MAC primitive.
Definition at line 284 of file md.cpp.
References md5(), pc_md5_final(), pc_md5_init(), and pc_md5_update().