Table of Contents

Class Grain128AeadEngine

Namespace
Org.BouncyCastle.Crypto.Engines
Assembly
BouncyCastle.Cryptography.dll
public sealed class Grain128AeadEngine : IAeadCipher
Inheritance
Grain128AeadEngine
Implements
Inherited Members

Constructors

Grain128AeadEngine()

public Grain128AeadEngine()

Properties

AlgorithmName

The name of the algorithm this cipher implements.

public string AlgorithmName { get; }

Property Value

string

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 int DoFinal(byte[] output, int outOff)

Parameters

output byte[]
outOff int

Returns

int

DoFinal(Span<byte>)

public int DoFinal(Span<byte> output)

Parameters

output Span<byte>

Returns

int

GetMac()

Return the value of the MAC associated with the last stream processed.

@return MAC for plaintext data.

public 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 int GetOutputSize(int len)

Parameters

len int

Returns

int

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 int GetUpdateOutputSize(int len)

Parameters

len int

Returns

int

Init(bool, ICipherParameters)

public void Init(bool forEncryption, ICipherParameters param)

Parameters

forEncryption bool
param ICipherParameters

ProcessAadByte(byte)

Add a single byte to the associated data check.

public void ProcessAadByte(byte input)

Parameters

input byte

The 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 void ProcessAadBytes(byte[] input, int inOff, int len)

Parameters

input byte[]
inOff int

The offset into the input array where the data to be processed starts.

len int

The 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 void ProcessAadBytes(ReadOnlySpan<byte> input)

Parameters

input ReadOnlySpan<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 int ProcessByte(byte input, byte[] output, int outOff)

Parameters

input byte
output byte[]
outOff int

Returns

int

ProcessByte(byte, Span<byte>)

public int ProcessByte(byte input, Span<byte> output)

Parameters

input byte
output Span<byte>

Returns

int

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 int ProcessBytes(byte[] input, int inOff, int len, byte[] output, int outOff)

Parameters

input byte[]
inOff int
len int
output byte[]
outOff int

Returns

int

ProcessBytes(ReadOnlySpan<byte>, Span<byte>)

public int ProcessBytes(ReadOnlySpan<byte> input, Span<byte> output)

Parameters

input ReadOnlySpan<byte>
output Span<byte>

Returns

int

Reset()

Reset the cipher to the same state as it was after the last init (if there was one).

public void Reset()

ReturnByte(byte)

[Obsolete("Incompatible with the AEAD API; throws NotImplementedException")]
public byte ReturnByte(byte input)

Parameters

input byte

Returns

byte