Expand description
Crypto service provider for smb-server-rs.
One stable API surface, two interchangeable backends selected at compile time:
lib(default) — maintained RustCrypto crates. Hardware acceleration (AES-NI et al.) where available; the production choice.handrolled— the bundled from-scratch implementations. Zero external dependencies, useful for auditing or constrained builds.
cargo build -p smb-server-csp # RustCrypto backend
cargo build -p smb-server-csp --no-default-features --features handrolledBoth backends must produce byte-identical output; the test vectors in this file are asserted for whichever backend is compiled.
Functions§
- aes128_
cmac - AES-CMAC over
dataunderkey([RFC 4493]) — SMB 3.x signing. - aes128_
encrypt_ block - Encrypt one 16-byte AES-128 block.
- aes128ccm_
open - AES-128-CCM open;
ciphertextcarries the trailing 16-byte tag. - aes128ccm_
seal - AES-128-CCM seal with an 11-byte nonce ([MS-SMB2] CCM variant).
- aes128gcm_
open - AES-128-GCM open;
ciphertextcarries the trailing 16-byte tag. - aes128gcm_
seal - AES-128-GCM seal: appends the 16-byte tag to the ciphertext.
nonce= 12 bytes from the transform header’s Nonce field;aad= the 32-byte header tail (MsgSize..SessionId end). - aes256ccm_
open - AES-256-CCM open;
ciphertextcarries the trailing 16-byte tag. - aes256ccm_
seal - AES-256-CCM seal with an 11-byte nonce ([MS-SMB2] CCM variant).
- aes256gcm_
open - AES-256-GCM open;
ciphertextcarries the trailing 16-byte tag. - aes256gcm_
seal - AES-256-GCM seal ([MS-SMB2] AES-256-GCM cipher); appends the 16-byte tag.
- des_
encrypt_ key7 - DES-ECB encrypt one block under a 56-bit NTLM key chunk.
- hmac_
md5 - HMAC-MD5 of
dataunderkey([RFC 2104]). - hmac_
sha256 - HMAC-SHA256 of
dataunderkey. - kdf_
counter_ mode_ hmac_ sha256 - SP800-108 counter-mode KDF with HMAC-SHA256 PRF ([MS-SMB2] §3.1.4.1): K(i) = HMAC-SHA256(key, [i]_32BE || label || 0x00 || context || [L]_32BE)
- md4
- MD4 digest ([RFC 1320]).
- md5
- MD5 digest ([RFC 1321]).
- nt_hash
- NT hash = MD4 of the UTF-16LE encoded password ([MS-NLMP] §3.3.1.1).
- ntlm_
mech_ list_ mic - NTLMSSP MIC for the SPNEGO mechListMIC ([RFC 4178] / [MS-NLMP] §3.4.6), matching samba’s calc_ntlmv2_key + ntlmssp_make_packet_signature:
- ntlmv1_
response - NTLMv1/LM response: three DES encryptions of the challenge under successive 7-byte chunks of the 21-byte expanded hash ([MS-NLMP] §3.3.1).
- rc4
- XOR
datawith the RC4 keystream generated fromkey([MS-NLMP] §3.2.5.1.2 session-key transport). - sha256
- SHA-256 digest ([FIPS 180-4]).
- sha512
- SHA-512 digest ([FIPS 180-4]).