ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
md.h File Reference

MD4 (RFC 1320), MD5 (RFC 1321), and HMAC-MD5 (RFC 2104) - the legacy digests NTLM needs. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Functions

MdCtxpc_md_wants (void)
 Storage this module wants for one MD4/MD5 context.
 
void pc_md5_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 md5 (const uint8_t *data, size_t len, uint8_t out[16])
 One-shot MD5.
 
void pc_md4_init (MdCtx *c)
 
void pc_md4_update (MdCtx *c, const uint8_t *data, size_t len)
 
void pc_md4_final (MdCtx *c, uint8_t out[16])
 
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.
 

Detailed Description

MD4 (RFC 1320), MD5 (RFC 1321), and HMAC-MD5 (RFC 2104) - the legacy digests NTLM needs.

The shared library home for the MD-family digests. The only consumer is the SMB2 client's NTLMv2 (MS-NLMP): the NT hash is MD4(UTF-16LE(password)); the NTLMv2 response and session key are HMAC-MD5 chains. MD4/MD5 are cryptographically broken and are included ONLY because SMB/NTLM requires them on the wire - do not use them for anything security-new. Zero heap, streaming; verified against the RFC test vectors (see test_smb_crypto).

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file md.h.

Function Documentation

◆ pc_md_wants()

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.

Returns
a context to pass to pc_md4_init() / pc_md5_init(), or nullptr if the pool could not satisfy it.

Definition at line 28 of file md.cpp.

References pc_span::buf, pc_secure_span(), and pc_span_ok().

◆ pc_md5_init()

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().

◆ pc_md5_update()

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().

◆ pc_md5_final()

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().

◆ md5()

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().

◆ pc_md4_init()

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().

◆ pc_md4_update()

void pc_md4_update ( MdCtx c,
const uint8_t *  data,
size_t  len 
)

Definition at line 258 of file md.cpp.

Referenced by md4().

◆ pc_md4_final()

void pc_md4_final ( MdCtx c,
uint8_t  out[16] 
)

Definition at line 262 of file md.cpp.

Referenced by md4().

◆ md4()

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().

◆ pc_hmac_md5()

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().