|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
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. | |
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.
Definition in file ntlmssp.h.
| #define NTLMSSP_NEGOTIATE_UNICODE 0x00000001 |
| #define NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY 0x00080000 |
| #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 |
| 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 .
| work | PROTOCORE_NTLMSSP_BORROW bytes the caller took. Not held past the call. |
| buf | Buf |
| cap | Cap |
| flags | Flags |
| 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 .
| work | PROTOCORE_NTLMSSP_BORROW bytes the caller took. Not held past the call. |
| msg | Msg |
| len | Len |
| out | Out |
| 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 .
| work | PROTOCORE_NTLMSSP_BORROW bytes the caller took. Not held past the call. |
| buf | Buf |
| cap | Cap |
| lm_resp | / lm_len the LM(v2) response (may be null/0) |
| lm_len | Lm len |
| nt_resp | / nt_len the NtChallengeResponse from protocore_ntlm_v2_response |
| nt_len | Nt len |
| domain | / user / workstation ASCII/UTF-8 identity strings (encoded UTF-16LE); user and domain are |
| user | User |
| workstation | Workstation |
| flags | the NegotiateFlags to echo (usually the server's from the CHALLENGE) |
| with_mic | when true, reserve the 8-byte Version + 16-byte MIC fields between the fixed header and the |
| PROTOCORE_NS NtlmsspNs Ntlmssp PROTOCORE_UNUSED |
Module namespace.