Module jcifs

Class Smb2EncryptionContext

java.lang.Object
org.codelibs.jcifs.smb.internal.smb2.Smb2EncryptionContext

public class Smb2EncryptionContext extends Object
SMB2/SMB3 Encryption Context Manages encryption and decryption operations for SMB2/SMB3 sessions. Handles both AES-CCM (SMB 3.0/3.0.2) and AES-GCM (SMB 3.1.1) cipher suites.
Author:
mbechler
  • Field Details

    • CIPHER_AES_128_CCM

      public static final int CIPHER_AES_128_CCM
      AES-128-CCM cipher identifier for SMB3 encryption
      See Also:
    • CIPHER_AES_128_GCM

      public static final int CIPHER_AES_128_GCM
      AES-128-GCM cipher identifier for SMB3.1.1 encryption
      See Also:
    • TRANSFORM_FLAG_ENCRYPTED

      public static final int TRANSFORM_FLAG_ENCRYPTED
      Transform header flag indicating the message is encrypted
      See Also:
  • Constructor Details

    • Smb2EncryptionContext

      public Smb2EncryptionContext(int cipherId, DialectVersion dialect, byte[] encryptionKey, byte[] decryptionKey)
      Create encryption context
      Parameters:
      cipherId - negotiated cipher identifier
      dialect - SMB dialect version
      encryptionKey - key for client->server encryption
      decryptionKey - key for server->client decryption
  • Method Details

    • getCipherId

      public int getCipherId()
      Get the negotiated cipher identifier
      Returns:
      the negotiated cipher ID
    • getDialect

      public DialectVersion getDialect()
      Get the SMB dialect version
      Returns:
      the SMB dialect version
    • generateNonce

      public byte[] generateNonce()
      Generate a unique nonce for encryption
      Returns:
      16-byte nonce
    • encryptMessage

      public byte[] encryptMessage(byte[] message, long sessionId) throws CIFSException
      Encrypt an SMB2 message
      Parameters:
      message - plaintext message to encrypt
      sessionId - session identifier
      Returns:
      encrypted message with transform header
      Throws:
      CIFSException - if encryption fails
    • decryptMessage

      public byte[] decryptMessage(byte[] encryptedMessage) throws CIFSException
      Decrypt an SMB2 message
      Parameters:
      encryptedMessage - encrypted message with transform header
      Returns:
      decrypted plaintext message
      Throws:
      CIFSException - if decryption fails