Class BcChaCha20Poly1305
public sealed class BcChaCha20Poly1305 : TlsAeadCipherImpl
- Inheritance
-
BcChaCha20Poly1305
- Implements
- Inherited Members
Constructors
BcChaCha20Poly1305(bool)
public BcChaCha20Poly1305(bool isEncrypting)
Parameters
isEncryptingbool
Methods
DoFinal(byte[], byte[], int, int, byte[], int)
Perform the cipher encryption/decryption returning the output in output.
public int DoFinal(byte[] additionalData, byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
Parameters
additionalDatabyte[]any additional data to be included in the MAC calculation.
inputbyte[]array holding input data to the cipher.
inputOffsetintoffset into input array data starts at.
inputLengthintlength of the input data in the array.
outputbyte[]array to hold the cipher output.
outputOffsetintoffset into output array to start saving output.
Returns
- int
the amount of data written to output.
Remarks
Note: we have to use DoFinal() here as it is the only way to guarantee output from the underlying cipher.
Exceptions
- IOException
in case of failure.
DoFinal(byte[], int, int, byte[], int)
Perform the cipher encryption/decryption returning the output in output.
public int DoFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)
Parameters
inputbyte[]array holding input data to the cipher.
inputOffsetintoffset into input array data starts at.
inputLengthintlength of the input data in the array.
outputbyte[]array to hold the cipher output.
outputOffsetintoffset into output array to start saving output.
Returns
- int
the amount of data written to output.
Remarks
Note: we have to use DoFinal() here as it is the only way to guarantee output from the underlying cipher.
Exceptions
- IOException
in case of failure.
GetOutputSize(int)
Return the maximum size of the output for input of inputLength bytes.
public int GetOutputSize(int inputLength)
Parameters
inputLengthintthe length (in bytes) of the proposed input.
Returns
- int
the maximum size of the output.
Init(byte[], int, byte[])
Initialise the parameters for the AEAD operator.
public void Init(byte[] nonce, int macSize, byte[] additionalData)
Parameters
noncebyte[]the nonce.
macSizeintMAC size in bytes.
additionalDatabyte[]any additional data to be included in the MAC calculation.
Exceptions
- IOException
if the parameters are inappropriate.
Reset()
public void Reset()
SetKey(byte[], int, int)
Set the key to be used by the AEAD cipher implementation supporting this service.
public void SetKey(byte[] key, int keyOff, int keyLen)
Parameters
keybyte[]array holding the AEAD cipher key.
keyOffintoffset into the array the key starts at.
keyLenintlength of the key in the array.
Exceptions
SetKey(ReadOnlySpan<byte>)
public void SetKey(ReadOnlySpan<byte> key)
Parameters
keyReadOnlySpan<byte>