Class KCcmBlockCipher
- Namespace
- Org.BouncyCastle.Crypto.Modes
- Assembly
- BouncyCastle.Cryptography.dll
public class KCcmBlockCipher : IAeadBlockCipher, IAeadCipher
- Inheritance
-
KCcmBlockCipher
- Implements
- Inherited Members
Constructors
KCcmBlockCipher(IBlockCipher)
Base constructor. Nb value is set to 4.
public KCcmBlockCipher(IBlockCipher engine)
Parameters
engineIBlockCipherbase cipher to use under CCM.
KCcmBlockCipher(IBlockCipher, int)
Constructor allowing Nb configuration.
Nb is a parameter specified in CCM mode of DSTU7624 standard. This parameter specifies maximum possible length of input.It should be calculated as follows: Nb = 1 / 8 * (-3 + log[2]Nmax) + 1, where Nmax - length of input message in bits.For practical reasons Nmax usually less than 4Gb, e.g. for Nmax = 2^32 - 1, Nb = 4.
public KCcmBlockCipher(IBlockCipher engine, int Nb)
Parameters
engineIBlockCipherbase cipher to use under CCM.
NbintNb value to use.
Properties
AlgorithmName
The name of the algorithm this cipher implements.
public virtual string AlgorithmName { get; }
Property Value
UnderlyingCipher
The block cipher underlying this algorithm.
public virtual IBlockCipher UnderlyingCipher { get; }
Property Value
Methods
DoFinal(byte[], int)
Finish the operation either appending or verifying the MAC at the end of the data.
@param outBytes space for any resulting output data. @param outOff offset into out to start copying the data at. @return number of bytes written into out. @throws InvalidOperationException if the cipher is in an inappropriate state. @throws InvalidCipherTextException if the MAC fails to match.
public virtual int DoFinal(byte[] output, int outOff)
Parameters
Returns
DoFinal(Span<byte>)
public virtual int DoFinal(Span<byte> output)
Parameters
Returns
GetBlockSize()
public virtual int GetBlockSize()
Returns
- int
The block size for this cipher, in bytes.
GetMac()
Return the value of the MAC associated with the last stream processed.
@return MAC for plaintext data.
public virtual byte[] GetMac()
Returns
- byte[]
GetOutputSize(int)
Return the size of the output buffer required for a ProcessBytes plus a DoFinal with an input of len bytes.
@param len the length of the input. @return the space required to accommodate a call to ProcessBytes and DoFinal with len bytes of input.
public virtual int GetOutputSize(int len)
Parameters
lenint
Returns
GetUpdateOutputSize(int)
Return the size of the output buffer required for a ProcessBytes an input of len bytes.
@param len the length of the input. @return the space required to accommodate a call to ProcessBytes with len bytes of input.
public virtual int GetUpdateOutputSize(int len)
Parameters
lenint
Returns
Init(bool, ICipherParameters)
Initialise the cipher.
public virtual void Init(bool forEncryption, ICipherParameters parameters)
Parameters
forEncryptionboolInitialise for encryption if true, for decryption if false.
parametersICipherParametersThe key or other data required by the cipher.
Remarks
Parameter can either be an AeadParameters or a ParametersWithIV object.
ProcessAadByte(byte)
Add a single byte to the associated data check.
public virtual void ProcessAadByte(byte input)
Parameters
inputbyteThe byte to be processed.
Remarks
If the implementation supports it, this will be an online operation and will not retain the associated data.
ProcessAadBytes(byte[], int, int)
Add a sequence of bytes to the associated data check.
public virtual void ProcessAadBytes(byte[] input, int inOff, int len)
Parameters
inputbyte[]inOffintThe offset into the input array where the data to be processed starts.
lenintThe number of bytes to be processed.
Remarks
If the implementation supports it, this will be an online operation and will not retain the associated data.
ProcessAadBytes(ReadOnlySpan<byte>)
Add a span of bytes to the associated data check.
public virtual void ProcessAadBytes(ReadOnlySpan<byte> input)
Parameters
inputReadOnlySpan<byte>the span containing the data.
Remarks
If the implementation supports it, this will be an online operation and will not retain the associated data.
ProcessByte(byte, byte[], int)
Encrypt/decrypt a single byte.
@param input the byte to be processed. @param outBytes the output buffer the processed byte goes into. @param outOff the offset into the output byte array the processed data starts at. @return the number of bytes written to out. @exception DataLengthException if the output buffer is too small.
public virtual int ProcessByte(byte input, byte[] output, int outOff)
Parameters
Returns
ProcessByte(byte, Span<byte>)
public virtual int ProcessByte(byte input, Span<byte> output)
Parameters
Returns
ProcessBytes(byte[], int, int, byte[], int)
Process a block of bytes from in putting the result into out.
@param inBytes the input byte array. @param inOff the offset into the in array where the data to be processed starts. @param len the number of bytes to be processed. @param outBytes the output buffer the processed bytes go into. @param outOff the offset into the output byte array the processed data starts at. @return the number of bytes written to out. @exception DataLengthException if the output buffer is too small.
public virtual int ProcessBytes(byte[] input, int inOff, int inLen, byte[] output, int outOff)
Parameters
Returns
ProcessBytes(ReadOnlySpan<byte>, Span<byte>)
public virtual int ProcessBytes(ReadOnlySpan<byte> input, Span<byte> output)
Parameters
inputReadOnlySpan<byte>outputSpan<byte>
Returns
ProcessPacket(byte[], int, int, byte[], int)
public int ProcessPacket(byte[] input, int inOff, int len, byte[] output, int outOff)
Parameters
Returns
ProcessPacket(ReadOnlySpan<byte>, Span<byte>)
public int ProcessPacket(ReadOnlySpan<byte> input, Span<byte> output)
Parameters
inputReadOnlySpan<byte>outputSpan<byte>
Returns
Reset()
Reset the cipher to the same state as it was after the last init (if there was one).
public virtual void Reset()