Module jcifs

Class Smb2TransformHeader

java.lang.Object
org.codelibs.jcifs.smb.internal.smb2.Smb2TransformHeader
All Implemented Interfaces:
Encodable

public class Smb2TransformHeader extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Size of the transform header in bytes
    static final int
    Transform header protocol identifier: 0xFD534D42 (0xFD 'S' 'M' 'B')
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new SMB2 Transform Header
    Smb2TransformHeader(byte[] nonce, int originalMessageSize, int flags, long sessionId)
    Create a new SMB2 Transform Header with specified parameters
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(byte[] buffer, int bufferIndex)
    Decode a transform header from byte array
    int
    encode(byte[] dst, int dstIndex)
    Encodes this object into the specified byte array.
    byte[]
    Get the associated data for AEAD encryption (everything except signature)
    int
    Gets the flags field which contains flags in SMB 3.1.1 or encryption algorithm ID in SMB 3.0/3.0.2
    byte[]
    Gets the nonce used for encryption
    int
    Gets the size of the original unencrypted message
    long
    Gets the session ID associated with this encrypted message
    byte[]
    Gets the signature or authentication tag for the encrypted message
    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
    void
    setNonce(byte[] nonce)
    Sets the nonce for encryption
    void
    setOriginalMessageSize(int originalMessageSize)
    Sets the size of the original unencrypted message
    void
    setSessionId(long sessionId)
    Sets the session ID for this encrypted message
    void
    setSignature(byte[] signature)
    Sets the signature or authentication tag for the encrypted message
    int
    Returns the size in bytes that this object will occupy when encoded.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TRANSFORM_PROTOCOL_ID

      public static final int TRANSFORM_PROTOCOL_ID
      Transform header protocol identifier: 0xFD534D42 (0xFD 'S' 'M' 'B')
      See Also:
    • TRANSFORM_HEADER_SIZE

      public static final int TRANSFORM_HEADER_SIZE
      Size 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 encryption
      originalMessageSize - size of the original unencrypted message
      flags - 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: Encodable
      Returns the size in bytes that this object will occupy when encoded.
      Specified by:
      size in interface Encodable
      Returns:
      the encoded size
    • encode

      public int encode(byte[] dst, int dstIndex)
      Description copied from interface: Encodable
      Encodes this object into the specified byte array.
      Specified by:
      encode in interface Encodable
      Parameters:
      dst - the destination byte array to encode into
      dstIndex - the starting index in the destination array
      Returns:
      encoded length
    • decode

      public static Smb2TransformHeader decode(byte[] buffer, int bufferIndex)
      Decode a transform header from byte array
      Parameters:
      buffer - buffer to decode from
      bufferIndex - 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