public class CbcBlockCipher extends Object
| Constructor and Description |
|---|
CbcBlockCipher() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkPadding(int padding,
byte[] data,
int offset)
Check padding.
|
static byte[] |
decrypt(CipherSuite suite,
SecretKey key,
SecretKey macKey,
byte[] additionalData,
byte[] ciphertext)
Converts a given TLSCiphertext.fragment to a TLSCompressed.fragment
structure as defined by
RFC 5246,
section 6.2.3.2:
|
static byte[] |
encrypt(CipherSuite suite,
SecretKey key,
SecretKey macKey,
byte[] additionalData,
byte[] payload)
Converts a given TLSCompressed.fragment to a TLSCiphertext.fragment
structure as defined by
RFC 5246,
section 6.2.3.2
|
static byte[] |
getBlockCipherMac(Mac hmac,
SecretKey macKey,
byte[] additionalData,
byte[] content,
int length)
Calculates a MAC for use with CBC block ciphers as specified by
RFC 5246,
section 6.2.3.2.
|
public static byte[] decrypt(CipherSuite suite, SecretKey key, SecretKey macKey, byte[] additionalData, byte[] ciphertext) throws GeneralSecurityException
struct {
opaque IV[SecurityParameters.record_iv_length];
block-ciphered struct {
opaque content[TLSCompressed.length];
opaque MAC[SecurityParameters.mac_length];
uint8 padding[GenericBlockCipher.padding_length];
uint8 padding_length;
};
} GenericBlockCipher;
The particular cipher to use is determined from the negotiated cipher
suite in the current DTLS connection state.suite - used cipher suitekey - encryption keymacKey - mac keyadditionalData - additional data. Note: the TLSCompressed.length is
not available before decryption. Therefore the last two bytes
will be modified with that length after the decryption.ciphertext - encrypted message including initial vectorInvalidMacException - if message authentication failedGeneralSecurityException - if the ciphertext could not be decryptedpublic static byte[] encrypt(CipherSuite suite, SecretKey key, SecretKey macKey, byte[] additionalData, byte[] payload) throws GeneralSecurityException
struct {
opaque IV[SecurityParameters.record_iv_length];
block-ciphered struct {
opaque content[TLSCompressed.length];
opaque MAC[SecurityParameters.mac_length];
uint8 padding[GenericBlockCipher.padding_length];
uint8 padding_length;
};
} GenericBlockCipher;
The particular cipher to use is determined from the negotiated cipher
suite in the current DTLS connection state.suite - used cipher suitekey - encryption keymacKey - mac keyadditionalData - additional datapayload - message to encryptGeneralSecurityException - if the plaintext could not be encryptedpublic static byte[] getBlockCipherMac(Mac hmac, SecretKey macKey, byte[] additionalData, byte[] content, int length) throws InvalidKeyException
hmac - mac functionmacKey - mac keyadditionalData - additional datacontent - payloadlength - length of payload to be usedInvalidKeyException - if the mac keys doesn't fit the macpublic static boolean checkPadding(int padding,
byte[] data,
int offset)
padding - padding to be checkeddata - data to be checked. Must contain at least 256 + 1 bytes from the
offset on. The value of the last byte will be changed!offset - offset of the padding field.true, if padding bytes in data from the offset on
contains the value of the padding byte.IllegalArgumentException - if the data array doesn't contain
257 bytes after the offset.Copyright © 2023 Eclipse Foundation. All rights reserved.