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

SMB2 client wire codec (MS-SMB2), PC_ENABLE_SMB - increment 1: the transport frame, the 64-byte sync packet header, and the NEGOTIATE exchange. More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

SMB2 client wire codec (MS-SMB2), PC_ENABLE_SMB - increment 1: the transport frame, the 64-byte sync packet header, and the NEGOTIATE exchange.

Windows-share program storage is a common CNC file path (Fanuc / Haas / Mazak / Heidenhain expose one), so a device can read/write .nc files over SMB2. This is the pure wire layer: build the little-endian SMB2 messages and parse the responses; the TCP socket is the application's. All fields are little-endian (SMB2 is a little-endian protocol).

A client speaks SMB2 over Direct TCP (port 445): each message is prefixed by a 4-byte transport header (0x00 + a 24-bit big-endian length), then the 64-byte SMB2 sync header (MS-SMB2 §2.2.1.2), then the per-command body. The exchange begins with NEGOTIATE (§2.2.3 request / §2.2.4 response): the client offers a dialect list, the server picks one and returns the SPNEGO security token that seeds authentication.

Shipped: the NEGOTIATE exchange; the NTLM crypto (smb_md / ntlm / ntlmssp); the SPNEGO wrapping (spnego); the SESSION_SETUP request/response framing that carries those tokens; and the TREE_CONNECT / CREATE / CLOSE / READ / WRITE file commands - the full read/write-a-file-on-a-share client; SMB 2.x message signing (pc_smb2_sign / pc_smb2_verify, HMAC-SHA256) wired into the client's SigningRequired path; and the SMB 3.1.1 negotiate-context codec (pc_smb2_build_negotiate_311 / pc_smb2_parse_negotiate_contexts - preauth-integrity SHA-512, signing, and encryption capabilities); and the SP800-108 counter-mode KDF (pc_kdf_ctr_hmac_sha256 in src/crypto/kdf, NIST-CAVP-verified) that SMB 3.x uses to derive its keys. SMB 3.1.1 runs end to end: the client offers 2.0.2 .. 3.1.1, chains the preauth-integrity hash (pc_smb_preauth_*) across NEGOTIATE + both SESSION_SETUP rounds, derives the signing key (pc_smb3_derive_signing_key), and signs the session with AES-128-CMAC (pc_smb2_sign_cmac / _verify_cmac; crypto/aes_cmac) - the KDF assembly + CMAC cross-checked byte-for-byte against impacket.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file smb2.h.