Modifier and Type | Field and Description |
---|---|
protected TlsCryptoParameters |
context |
protected TlsStreamCipherImpl |
decryptCipher |
protected byte[] |
decryptIV |
protected TlsStreamCipherImpl |
encryptCipher |
protected byte[] |
encryptIV |
protected TlsMAC |
readMac |
protected TlsMAC |
writeMac |
Constructor and Description |
---|
ChaCha20Poly1305Cipher(TlsCryptoParameters context,
TlsStreamCipherImpl encryptCipher,
TlsStreamCipherImpl decryptCipher,
TlsMAC writeMac,
TlsMAC readMac) |
Modifier and Type | Method and Description |
---|---|
protected byte[] |
calculateNonce(long seqNo,
byte[] iv) |
protected byte[] |
calculateRecordMAC(TlsMAC mac,
byte[] additionalData,
byte[] buf,
int off,
int len) |
byte[] |
decodeCiphertext(long seqNo,
short type,
byte[] ciphertext,
int offset,
int len)
Validate and decrypt the passed in cipher text using the current cipher suite.
|
byte[] |
encodePlaintext(long seqNo,
short type,
byte[] plaintext,
int offset,
int len)
Encrypt and MAC the passed in plain text using the current cipher suite.
|
protected byte[] |
getAdditionalData(long seqNo,
short type,
int len) |
int |
getPlaintextLimit(int ciphertextLimit)
Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.
|
protected void |
initRecord(TlsStreamCipherImpl cipher,
long seqNo,
byte[] iv) |
protected void |
updateRecordMACLength(TlsMAC mac,
int len) |
protected void |
updateRecordMACText(TlsMAC mac,
byte[] buf,
int off,
int len) |
protected TlsCryptoParameters context
protected TlsMAC writeMac
protected TlsMAC readMac
protected TlsStreamCipherImpl encryptCipher
protected TlsStreamCipherImpl decryptCipher
protected byte[] encryptIV
protected byte[] decryptIV
public ChaCha20Poly1305Cipher(TlsCryptoParameters context, TlsStreamCipherImpl encryptCipher, TlsStreamCipherImpl decryptCipher, TlsMAC writeMac, TlsMAC readMac) throws java.io.IOException
java.io.IOException
public int getPlaintextLimit(int ciphertextLimit)
TlsCipher
getPlaintextLimit
in interface TlsCipher
ciphertextLimit
- the maximum number of bytes of ciphertext.public byte[] encodePlaintext(long seqNo, short type, byte[] plaintext, int offset, int len) throws java.io.IOException
TlsCipher
encodePlaintext
in interface TlsCipher
seqNo
- sequence number of the message represented by plaintext.type
- content type of the message represented by plaintext.plaintext
- array holding input plain text to the cipher.offset
- offset into input array the plain text starts at.len
- length of the plaintext in the array.java.io.IOException
public byte[] decodeCiphertext(long seqNo, short type, byte[] ciphertext, int offset, int len) throws java.io.IOException
TlsCipher
decodeCiphertext
in interface TlsCipher
seqNo
- sequence number of the message represented by ciphertext.type
- content type of the message represented by ciphertext.ciphertext
- array holding input cipher text to the cipher.offset
- offset into input array the cipher text starts at.len
- length of the cipher text in the array.java.io.IOException
protected void initRecord(TlsStreamCipherImpl cipher, long seqNo, byte[] iv) throws java.io.IOException
java.io.IOException
protected byte[] calculateNonce(long seqNo, byte[] iv)
protected byte[] calculateRecordMAC(TlsMAC mac, byte[] additionalData, byte[] buf, int off, int len)
protected void updateRecordMACLength(TlsMAC mac, int len)
protected void updateRecordMACText(TlsMAC mac, byte[] buf, int off, int len)
protected byte[] getAdditionalData(long seqNo, short type, int len) throws java.io.IOException
java.io.IOException