java.lang.Object
org.codelibs.jcifs.smb.internal.smb2.Smb2SigningDigest
- All Implemented Interfaces:
SMBSigningDigest
SMB2/SMB3 message signing digest implementation.
This class handles cryptographic signing of SMB2/SMB3 messages to ensure
message integrity and authenticity. It supports different signing algorithms
used in various SMB2/SMB3 dialect versions.
- Author:
- mbechler
-
Constructor Summary
ConstructorsConstructorDescriptionSmb2SigningDigest(byte[] sessionKey, int dialect, byte[] preauthIntegrityHash) Constructs a SMB2 signing digest with the specified session key and dialect -
Method Summary
Modifier and TypeMethodDescriptionvoidsign(byte[] data, int offset, int length, CommonServerMessageBlock request, CommonServerMessageBlock response) Performs MAC signing of the SMB.booleanverify(byte[] data, int offset, int length, int extraPad, CommonServerMessageBlock msg) Performs MAC signature verification.
-
Constructor Details
-
Smb2SigningDigest
public Smb2SigningDigest(byte[] sessionKey, int dialect, byte[] preauthIntegrityHash) throws GeneralSecurityException Constructs a SMB2 signing digest with the specified session key and dialect- Parameters:
sessionKey- the session key for signingdialect- the SMB2 dialect versionpreauthIntegrityHash- the pre-authentication integrity hash (for SMB 3.1.1)- Throws:
GeneralSecurityException- if the signing algorithm cannot be initialized
-
-
Method Details
-
sign
public void sign(byte[] data, int offset, int length, CommonServerMessageBlock request, CommonServerMessageBlock response) Performs MAC signing of the SMB. This is done as follows. The signature field of the SMB is overwritten with the sequence number; The MD5 digest of the MAC signing key + the entire SMB is taken; The first 8 bytes of this are placed in the signature field.- Specified by:
signin interfaceSMBSigningDigest- Parameters:
data- The data.offset- The starting offset at which the SMB header begins.length- The length of the SMB data starting at offset.request- request messageresponse- response message- See Also:
-
verify
public boolean verify(byte[] data, int offset, int length, int extraPad, CommonServerMessageBlock msg) Performs MAC signature verification. This calculates the signature of the SMB and compares it to the signature field on the SMB itself.- Specified by:
verifyin interfaceSMBSigningDigest- Parameters:
data- The data.offset- The starting offset at which the SMB header begins.length- The length of the data to verifyextraPad- extra padding to include in signaturemsg- The message to verify- Returns:
- whether verification was unsuccessful
- See Also:
-