java.lang.Object
org.codelibs.jcifs.smb.internal.smb2.Smb2TransformHeader
- All Implemented Interfaces:
Encodable
SMB2 Transform Header for encrypted messages
This header is used to encrypt SMB2/SMB3 messages and provides the necessary
cryptographic parameters for decryption including the nonce, session ID, and
authentication tag.
- Author:
- mbechler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSize of the transform header in bytesstatic final intTransform header protocol identifier: 0xFD534D42 (0xFD 'S' 'M' 'B') -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new SMB2 Transform HeaderSmb2TransformHeader(byte[] nonce, int originalMessageSize, int flags, long sessionId) Create a new SMB2 Transform Header with specified parameters -
Method Summary
Modifier and TypeMethodDescriptionstatic Smb2TransformHeaderdecode(byte[] buffer, int bufferIndex) Decode a transform header from byte arrayintencode(byte[] dst, int dstIndex) Encodes this object into the specified byte array.byte[]Get the associated data for AEAD encryption (everything except signature)intgetFlags()Gets the flags field which contains flags in SMB 3.1.1 or encryption algorithm ID in SMB 3.0/3.0.2byte[]getNonce()Gets the nonce used for encryptionintGets the size of the original unencrypted messagelongGets the session ID associated with this encrypted messagebyte[]Gets the signature or authentication tag for the encrypted messagevoidsetFlags(int flags) Sets the flags field which contains flags in SMB 3.1.1 or encryption algorithm ID in SMB 3.0/3.0.2voidsetNonce(byte[] nonce) Sets the nonce for encryptionvoidsetOriginalMessageSize(int originalMessageSize) Sets the size of the original unencrypted messagevoidsetSessionId(long sessionId) Sets the session ID for this encrypted messagevoidsetSignature(byte[] signature) Sets the signature or authentication tag for the encrypted messageintsize()Returns the size in bytes that this object will occupy when encoded.
-
Field Details
-
TRANSFORM_PROTOCOL_ID
public static final int TRANSFORM_PROTOCOL_IDTransform header protocol identifier: 0xFD534D42 (0xFD 'S' 'M' 'B')- See Also:
-
TRANSFORM_HEADER_SIZE
public static final int TRANSFORM_HEADER_SIZESize of the transform header in bytes- See Also:
-
-
Constructor Details
-
Smb2TransformHeader
public Smb2TransformHeader()Create a new SMB2 Transform Header -
Smb2TransformHeader
public Smb2TransformHeader(byte[] nonce, int originalMessageSize, int flags, long sessionId) Create a new SMB2 Transform Header with specified parameters- Parameters:
nonce- 16-byte nonce for encryptionoriginalMessageSize- size of the original unencrypted messageflags- transform flags (SMB 3.1.1) or encryption algorithm (SMB 3.0/3.0.2)sessionId- session identifier
-
-
Method Details
-
getSignature
public byte[] getSignature()Gets the signature or authentication tag for the encrypted message- Returns:
- the signature/authentication tag
-
setSignature
public void setSignature(byte[] signature) Sets the signature or authentication tag for the encrypted message- Parameters:
signature- the signature/authentication tag to set
-
getNonce
public byte[] getNonce()Gets the nonce used for encryption- Returns:
- the nonce
-
setNonce
public void setNonce(byte[] nonce) Sets the nonce for encryption- Parameters:
nonce- the nonce to set
-
getOriginalMessageSize
public int getOriginalMessageSize()Gets the size of the original unencrypted message- Returns:
- the original message size
-
setOriginalMessageSize
public void setOriginalMessageSize(int originalMessageSize) Sets the size of the original unencrypted message- Parameters:
originalMessageSize- the original message size to set
-
getFlags
public int getFlags()Gets the flags field which contains flags in SMB 3.1.1 or encryption algorithm ID in SMB 3.0/3.0.2- Returns:
- the flags (SMB 3.1.1) or encryption algorithm (SMB 3.0/3.0.2)
-
setFlags
public void setFlags(int flags) Sets the flags field which contains flags in SMB 3.1.1 or encryption algorithm ID in SMB 3.0/3.0.2- Parameters:
flags- the flags to set
-
getSessionId
public long getSessionId()Gets the session ID associated with this encrypted message- Returns:
- the session ID
-
setSessionId
public void setSessionId(long sessionId) Sets the session ID for this encrypted message- Parameters:
sessionId- the session ID to set
-
size
public int size()Description copied from interface:EncodableReturns the size in bytes that this object will occupy when encoded. -
encode
public int encode(byte[] dst, int dstIndex) Description copied from interface:EncodableEncodes this object into the specified byte array. -
decode
Decode a transform header from byte array- Parameters:
buffer- buffer to decode frombufferIndex- offset in buffer- Returns:
- new transform header instance
-
getAssociatedData
public byte[] getAssociatedData()Get the associated data for AEAD encryption (everything except signature)- Returns:
- byte array containing associated data
-