Top Description Fields Constructors Methods
org.bouncycastle.tls.crypto.impl.jcajce

public Class JceAEADCipherImpl

extends Object
implements TlsAEADCipherImpl
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl
Imports
java.io.IOException, java.security.AccessController, .AlgorithmParameters, .GeneralSecurityException, .PrivilegedAction, .SecureRandom, javax.crypto.Cipher, .SecretKey, javax.crypto.spec.SecretKeySpec, org.bouncycastle.asn1.cms.GCMParameters, org.bouncycastle.jcajce.spec.AEADParameterSpec, org.bouncycastle.jcajce.util.JcaJceHelper, org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl, org.bouncycastle.util.Arrays

A basic wrapper for a JCE Cipher class to provide the needed AEAD cipher functionality for TLS.

Field Summary

Modifier and TypeField and Description
private final String
private final String
private static final boolean
private final Cipher
private final int
private final JcaTlsCrypto
private final JcaJceHelper
private SecretKey
private final int
private int
private byte[]

Constructor Summary

AccessConstructor and Description
public
JceAEADCipherImpl(JcaTlsCrypto crypto, JcaJceHelper helper, String cipherName, String algorithm, int keySize, boolean isEncrypting)

Method Summary

Modifier and TypeMethod and Description
private static boolean
public int
doFinal(byte[]
any additional data to be included in the MAC calculation.
additionalData
,
byte[]
array holding input data to the cipher.
input
,
int
offset into input array data starts at.
inputOffset
,
int
length of the input data in the array.
inputLength
,
byte[]
array to hold the cipher output.
output
,
int
offset into output array to start saving output.
outputOffset
)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.doFinal.

Perform the cipher encryption/decryption returning the output in output.
private static String
getAlgParamsName(JcaJceHelper helper, String cipherName)

public int
getOutputSize(int
the length (in bytes) of the proposed input.
inputLength
)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.getOutputSize.

Return the maximum size of the output for input of inputLength bytes.
public void
init(byte[]
the nonce.
nonce
,
int
MAC size in bytes.
macSize
)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.init.

Initialise the parameters for the AEAD operator.
public void
setKey(byte[]
array holding the AEAD cipher key.
key
,
int
offset into the array the key starts at.
keyOff
,
int
length of the key in the array.
keyLen
)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.setKey.

Set the key to be used by the AEAD cipher implementation supporting this service.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
algorithmParamsNameback to summary
private final String algorithmParamsName
canDoAEADback to summary
private static final boolean canDoAEAD
cipherback to summary
private final Cipher cipher
cipherModeback to summary
private final int cipherMode
cryptoback to summary
private final JcaTlsCrypto crypto
helperback to summary
private final JcaJceHelper helper
keyback to summary
private SecretKey key
keySizeback to summary
private final int keySize
macSizeback to summary
private int macSize
nonceback to summary
private byte[] nonce

Constructor Detail

JceAEADCipherImplback to summary
public JceAEADCipherImpl(JcaTlsCrypto crypto, JcaJceHelper helper, String cipherName, String algorithm, int keySize, boolean isEncrypting) throws GeneralSecurityException

Method Detail

checkForAEADback to summary
private static boolean checkForAEAD()
Annotations
@SuppressWarnings:rawtypes, unchecked
doFinalback to summary
public int doFinal(byte[] additionalData, byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.doFinal.

Doc from org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.doFinal.

Perform the cipher encryption/decryption returning the output in output.

Note

we have to use doFinal() here as it is the only way to guarantee output from the underlying cipher.

Parameters
additionalData:byte[]

any additional data to be included in the MAC calculation.

input:byte[]

array holding input data to the cipher.

inputOffset:int

offset into input array data starts at.

inputLength:int

length of the input data in the array.

output:byte[]

array to hold the cipher output.

outputOffset:int

offset into output array to start saving output.

Returns:int

the amount of data written to output.

Exceptions
IOException:
in case of failure.
getAlgParamsNameback to summary
private static String getAlgParamsName(JcaJceHelper helper, String cipherName)
getOutputSizeback to summary
public int getOutputSize(int inputLength)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.getOutputSize.

Doc from org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.getOutputSize.

Return the maximum size of the output for input of inputLength bytes.

Parameters
inputLength:int

the length (in bytes) of the proposed input.

Returns:int

the maximum size of the output.

initback to summary
public void init(byte[] nonce, int macSize)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.init.

Doc from org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.init.

Initialise the parameters for the AEAD operator.

Parameters
nonce:byte[]

the nonce.

macSize:int

MAC size in bytes.

setKeyback to summary
public void setKey(byte[] key, int keyOff, int keyLen)

Implements org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.setKey.

Doc from org.bouncycastle.tls.crypto.impl.TlsAEADCipherImpl.setKey.

Set the key to be used by the AEAD cipher implementation supporting this service.

Parameters
key:byte[]

array holding the AEAD cipher key.

keyOff:int

offset into the array the key starts at.

keyLen:int

length of the key in the array.