DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
smb_md.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file smb_md.h
6 * @brief MD4 (RFC 1320), MD5 (RFC 1321), and HMAC-MD5 (RFC 2104) - the legacy digests NTLM
7 * needs, for the SMB2 client (DETWS_ENABLE_SMB). Not used anywhere else in the library.
8 *
9 * NTLMv2 (MS-NLMP) builds on these: the NT hash is MD4(UTF-16LE(password)); the NTLMv2 response
10 * and the session key are HMAC-MD5 chains. MD4/MD5 are cryptographically broken and are included
11 * ONLY because SMB/NTLM requires them on the wire - do not use them for anything security-new.
12 * Zero heap, streaming; verified against the RFC test vectors (see test_smb_crypto).
13 *
14 * @author Douglas Quigg (dstroy0)
15 * @date 2026
16 */
17
18#ifndef DETERMINISTICESPASYNCWEBSERVER_SMB_MD_H
19#define DETERMINISTICESPASYNCWEBSERVER_SMB_MD_H
20
21#include "ServerConfig.h"
22
23#if DETWS_ENABLE_SMB
24
25#include <stddef.h>
26#include <stdint.h>
27
28/** @brief Streaming digest context (shared by MD4 and MD5; both are 16-byte, 64-byte-block). */
29struct MdCtx
30{
31 uint32_t state[4];
32 uint64_t bits; ///< total message length in bits
33 uint8_t buf[64]; ///< partial block
34 uint32_t buf_len; ///< bytes currently in @ref buf
35};
36
37void md5_init(MdCtx *c);
38void md5_update(MdCtx *c, const uint8_t *data, size_t len);
39void md5_final(MdCtx *c, uint8_t out[16]);
40/** @brief One-shot MD5. */
41void md5(const uint8_t *data, size_t len, uint8_t out[16]);
42
43void md4_init(MdCtx *c);
44void md4_update(MdCtx *c, const uint8_t *data, size_t len);
45void md4_final(MdCtx *c, uint8_t out[16]);
46/** @brief One-shot MD4 (the NT-hash primitive). */
47void md4(const uint8_t *data, size_t len, uint8_t out[16]);
48
49/** @brief HMAC-MD5 (RFC 2104): the NTLMv2 MAC primitive. */
50void hmac_md5(const uint8_t *key, size_t key_len, const uint8_t *msg, size_t msg_len, uint8_t out[16]);
51
52#endif // DETWS_ENABLE_SMB
53
54#endif // DETERMINISTICESPASYNCWEBSERVER_SMB_MD_H
User-facing configuration for DeterministicESPAsyncWebServer.