ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
ntlmssp.h File Reference

NTLMSSP message codec (MS-NLMP §2.2.1) for the SMB2 client (PROTOCORE_ENABLE_SMB). More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  NtlmChallenge
 Parsed CHALLENGE_MESSAGE (type 2). target_info points INTO the source message. More...
 
struct  NtlmsspNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Macros

#define NTLMSSP_NEGOTIATE_UNICODE   0x00000001
 NTLMSSP NegotiateFlags (MS-NLMP §2.2.2.5), the subset a basic NTLMv2 client uses.
 
#define NTLMSSP_REQUEST_TARGET   0x00000004
 
#define NTLMSSP_NEGOTIATE_NTLM   0x00000200
 
#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN   0x00008000
 
#define NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY   0x00080000
 
#define NTLMSSP_NEGOTIATE_TARGET_INFO   0x00800000
 
#define NTLMSSP_NEGOTIATE_VERSION   0x02000000
 
#define NTLMSSP_NEGOTIATE_128   0x20000000
 
#define NTLMSSP_NEGOTIATE_56   0x80000000
 
#define NTLMSSP_CLIENT_DEFAULT_FLAGS
 The NEGOTIATE flag set an NTLMv2 client sends.
 
#define PROTOCORE_NTLMSSP_MIC_OFFSET   72
 Offset of the 16-byte MIC field within an AUTHENTICATE_MESSAGE built with_mic (MS-NLMP §2.2.1.3): the 64-byte fixed header + the 8-byte Version field. The caller writes the computed MIC here after the message is built and the digest taken over it with these bytes zeroed.
 
#define PROTOCORE_NTLMSSP_MIC_LEN   16
 Length of the AUTHENTICATE MIC field (an HMAC-MD5 digest).
 

Functions

 PROTOCORE_NS_LAYOUT (NtlmsspNs, build_negotiate, parse_challenge, build_authenticate)
 
size_t protocore_ntlmssp_build_negotiate (uint8_t *work, uint8_t *buf, size_t cap, uint32_t flags)
 Build a NEGOTIATE_MESSAGE (type 1) with flags and empty .
 
proto_bool protocore_ntlmssp_parse_challenge (uint8_t *work, const uint8_t *msg, size_t len, NtlmChallenge *out)
 Parse a CHALLENGE_MESSAGE (type 2): extract the flags, the 8-byte .
 
size_t protocore_ntlmssp_build_authenticate (uint8_t *work, uint8_t *buf, size_t cap, const uint8_t *lm_resp, size_t lm_len, const uint8_t *nt_resp, size_t nt_len, const char *domain, const char *user, const char *workstation, uint32_t flags, proto_bool with_mic)
 Build an AUTHENTICATE_MESSAGE (type 3) carrying the LM + NT .
 

Variables

PROTOCORE_NS NtlmsspNs Ntlmssp PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

NTLMSSP message codec (MS-NLMP §2.2.1) for the SMB2 client (PROTOCORE_ENABLE_SMB).

The three-message NTLM handshake tokens that carry the NTLMv2 response (ntlm.h) inside SMB2 SESSION_SETUP: the client sends a NEGOTIATE (type 1), the server replies with a CHALLENGE (type 2) carrying the 8-byte server challenge + the target-info AV_PAIRs, and the client sends an AUTHENTICATE (type 3) carrying the NtChallengeResponse and the user/domain. All fields little-endian; text is UTF-16LE. Pure, zero heap. This builds the raw NTLMSSP tokens; the SPNEGO/GSS wrapping + the SESSION_SETUP framing are the next increment.

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file ntlmssp.h.

Macro Definition Documentation

◆ NTLMSSP_NEGOTIATE_UNICODE

#define NTLMSSP_NEGOTIATE_UNICODE   0x00000001

NTLMSSP NegotiateFlags (MS-NLMP §2.2.2.5), the subset a basic NTLMv2 client uses.

Definition at line 35 of file ntlmssp.h.

◆ NTLMSSP_REQUEST_TARGET

#define NTLMSSP_REQUEST_TARGET   0x00000004

Definition at line 36 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_NTLM

#define NTLMSSP_NEGOTIATE_NTLM   0x00000200

Definition at line 37 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_ALWAYS_SIGN

#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN   0x00008000

Definition at line 38 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY

#define NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY   0x00080000

Definition at line 39 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_TARGET_INFO

#define NTLMSSP_NEGOTIATE_TARGET_INFO   0x00800000

Definition at line 40 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_VERSION

#define NTLMSSP_NEGOTIATE_VERSION   0x02000000

Definition at line 41 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_128

#define NTLMSSP_NEGOTIATE_128   0x20000000

Definition at line 42 of file ntlmssp.h.

◆ NTLMSSP_NEGOTIATE_56

#define NTLMSSP_NEGOTIATE_56   0x80000000

Definition at line 43 of file ntlmssp.h.

◆ NTLMSSP_CLIENT_DEFAULT_FLAGS

#define NTLMSSP_CLIENT_DEFAULT_FLAGS
Value:
#define NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY
Definition ntlmssp.h:39
#define NTLMSSP_REQUEST_TARGET
Definition ntlmssp.h:36
#define NTLMSSP_NEGOTIATE_NTLM
Definition ntlmssp.h:37
#define NTLMSSP_NEGOTIATE_UNICODE
NTLMSSP NegotiateFlags (MS-NLMP §2.2.2.5), the subset a basic NTLMv2 client uses.
Definition ntlmssp.h:35
#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN
Definition ntlmssp.h:38

The NEGOTIATE flag set an NTLMv2 client sends.

Definition at line 46 of file ntlmssp.h.

◆ PROTOCORE_NTLMSSP_MIC_OFFSET

#define PROTOCORE_NTLMSSP_MIC_OFFSET   72

Offset of the 16-byte MIC field within an AUTHENTICATE_MESSAGE built with_mic (MS-NLMP §2.2.1.3): the 64-byte fixed header + the 8-byte Version field. The caller writes the computed MIC here after the message is built and the digest taken over it with these bytes zeroed.

Definition at line 55 of file ntlmssp.h.

◆ PROTOCORE_NTLMSSP_MIC_LEN

#define PROTOCORE_NTLMSSP_MIC_LEN   16

Length of the AUTHENTICATE MIC field (an HMAC-MD5 digest).

Definition at line 58 of file ntlmssp.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( NtlmsspNs  ,
build_negotiate  ,
parse_challenge  ,
build_authenticate   
)

◆ protocore_ntlmssp_build_negotiate()

size_t protocore_ntlmssp_build_negotiate ( uint8_t *  work,
uint8_t *  buf,
size_t  cap,
uint32_t  flags 
)

Build a NEGOTIATE_MESSAGE (type 1) with flags and empty .

Parameters
workPROTOCORE_NTLMSSP_BORROW bytes the caller took. Not held past the call.
bufBuf
capCap
flagsFlags
Returns
The size_t.

◆ protocore_ntlmssp_parse_challenge()

proto_bool protocore_ntlmssp_parse_challenge ( uint8_t *  work,
const uint8_t *  msg,
size_t  len,
NtlmChallenge *  out 
)

Parse a CHALLENGE_MESSAGE (type 2): extract the flags, the 8-byte .

Parameters
workPROTOCORE_NTLMSSP_BORROW bytes the caller took. Not held past the call.
msgMsg
lenLen
outOut
Returns
PROTO_TRUE on success.

◆ protocore_ntlmssp_build_authenticate()

size_t protocore_ntlmssp_build_authenticate ( uint8_t *  work,
uint8_t *  buf,
size_t  cap,
const uint8_t *  lm_resp,
size_t  lm_len,
const uint8_t *  nt_resp,
size_t  nt_len,
const char *  domain,
const char *  user,
const char *  workstation,
uint32_t  flags,
proto_bool  with_mic 
)

Build an AUTHENTICATE_MESSAGE (type 3) carrying the LM + NT .

Parameters
workPROTOCORE_NTLMSSP_BORROW bytes the caller took. Not held past the call.
bufBuf
capCap
lm_resp/ lm_len the LM(v2) response (may be null/0)
lm_lenLm len
nt_resp/ nt_len the NtChallengeResponse from protocore_ntlm_v2_response
nt_lenNt len
domain/ user / workstation ASCII/UTF-8 identity strings (encoded UTF-16LE); user and domain are
userUser
workstationWorkstation
flagsthe NegotiateFlags to echo (usually the server's from the CHALLENGE)
with_micwhen true, reserve the 8-byte Version + 16-byte MIC fields between the fixed header and the
Returns
The size_t.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS NtlmsspNs Ntlmssp PROTOCORE_UNUSED
Initial value:
= {.build_negotiate = protocore_ntlmssp_build_negotiate,
.build_authenticate = protocore_ntlmssp_build_authenticate}
proto_bool protocore_ntlmssp_parse_challenge(uint8_t *work, const uint8_t *msg, size_t len, NtlmChallenge *out)
Parse a CHALLENGE_MESSAGE (type 2): extract the flags, the 8-byte .
size_t protocore_ntlmssp_build_authenticate(uint8_t *work, uint8_t *buf, size_t cap, const uint8_t *lm_resp, size_t lm_len, const uint8_t *nt_resp, size_t nt_len, const char *domain, const char *user, const char *workstation, uint32_t flags, proto_bool with_mic)
Build an AUTHENTICATE_MESSAGE (type 3) carrying the LM + NT .
size_t protocore_ntlmssp_build_negotiate(uint8_t *work, uint8_t *buf, size_t cap, uint32_t flags)
Build a NEGOTIATE_MESSAGE (type 1) with flags and empty .

Module namespace.

Definition at line 119 of file ntlmssp.h.