java.lang.Object
org.codelibs.jcifs.smb.internal.smb2.Smb2EncryptionContext
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intAES-128-CCM cipher identifier for SMB3 encryptionstatic final intAES-128-GCM cipher identifier for SMB3.1.1 encryptionstatic final intTransform header flag indicating the message is encrypted -
Constructor Summary
ConstructorsConstructorDescriptionSmb2EncryptionContext(int cipherId, DialectVersion dialect, byte[] encryptionKey, byte[] decryptionKey) Create encryption context -
Method Summary
Modifier and TypeMethodDescriptionbyte[]decryptMessage(byte[] encryptedMessage) Decrypt an SMB2 messagebyte[]encryptMessage(byte[] message, long sessionId) Encrypt an SMB2 messagebyte[]Generate a unique nonce for encryptionintGet the negotiated cipher identifierGet the SMB dialect version
-
Field Details
-
CIPHER_AES_128_CCM
public static final int CIPHER_AES_128_CCMAES-128-CCM cipher identifier for SMB3 encryption- See Also:
-
CIPHER_AES_128_GCM
public static final int CIPHER_AES_128_GCMAES-128-GCM cipher identifier for SMB3.1.1 encryption- See Also:
-
TRANSFORM_FLAG_ENCRYPTED
public static final int TRANSFORM_FLAG_ENCRYPTEDTransform 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 identifierdialect- SMB dialect versionencryptionKey- key for client->server encryptiondecryptionKey- key for server->client decryption
-
-
Method Details
-
getCipherId
public int getCipherId()Get the negotiated cipher identifier- Returns:
- the negotiated cipher ID
-
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
Encrypt an SMB2 message- Parameters:
message- plaintext message to encryptsessionId- session identifier- Returns:
- encrypted message with transform header
- Throws:
CIFSException- if encryption fails
-
decryptMessage
Decrypt an SMB2 message- Parameters:
encryptedMessage- encrypted message with transform header- Returns:
- decrypted plaintext message
- Throws:
CIFSException- if decryption fails
-