@miguel-cagide/smb2
Version:
A SMB2 implementation in TypeScript
31 lines (30 loc) • 1.31 kB
TypeScript
/// <reference types="node" />
/**
* Signs an SMB2 message buffer **without** the 4-byte NetBIOS transport prefix.
*
* Per MS-SMB2 section 3.1.4.1 (for SMB 2.0.2 / 2.1):
* 1. Set the Signed flag (bit 3) in the Flags field.
* 2. Zero the 16-byte Signature field.
* 3. Compute HMAC-SHA-256(SigningKey, entireMessage).
* 4. Copy the first 16 bytes of the HMAC into the Signature field.
*
* @param sessionKey The 16-byte session signing key.
* @param message The SMB2 message buffer (header + body, no NetBIOS prefix).
* @returns The signed message buffer (modified in place and returned).
*/
export declare function signMessage(sessionKey: Buffer, message: Buffer): Buffer;
/**
* Verifies the signature of an incoming SMB2 message buffer
* **without** the 4-byte NetBIOS transport prefix.
*
* @param sessionKey The 16-byte session signing key.
* @param message The SMB2 message buffer (header + body, no NetBIOS prefix).
* @returns `true` if the signature is valid.
*/
export declare function verifyMessage(sessionKey: Buffer, message: Buffer): boolean;
/**
* Checks whether the Signed flag is set in a message's SMB2 header.
*
* @param message The SMB2 message buffer (no NetBIOS prefix).
*/
export declare function isMessageSigned(message: Buffer): boolean;