Class GMac
- Namespace
- Org.BouncyCastle.Crypto.Macs
- Assembly
- BouncyCastle.Cryptography.dll
The GMAC specialisation of Galois/Counter mode (GCM) detailed in NIST Special Publication 800-38D.
public class GMac : IMac
- Inheritance
-
GMac
- Implements
- Inherited Members
Remarks
GMac is an invocation of the GCM mode where no data is encrypted (i.e. all input data to the Mac is processed as additional authenticated data with the underlying GCM block cipher).
Constructors
GMac(GcmBlockCipher)
Creates a GMAC based on the operation of a block cipher in GCM mode.
public GMac(GcmBlockCipher cipher)
Parameters
cipherGcmBlockCipherthe cipher to be used in GCM mode to generate the MAC.
Remarks
This will produce an authentication code the length of the block size of the cipher.
GMac(GcmBlockCipher, int)
Creates a GMAC based on the operation of a 128 bit block cipher in GCM mode.
public GMac(GcmBlockCipher cipher, int macSizeBits)
Parameters
cipherGcmBlockCipherthe cipher to be used in GCM mode to generate the MAC.
macSizeBitsintthe mac size to generate, in bits. Must be a multiple of 8, between 32 and 128 (inclusive). Sizes less than 96 are not recommended, but are supported for specialized applications.
Remarks
This will produce an authentication code the length of the block size of the cipher.
Properties
AlgorithmName
The algorithm name.
public string AlgorithmName { get; }
Property Value
Methods
BlockUpdate(byte[], int, int)
Update the MAC with a block of bytes.
public void BlockUpdate(byte[] input, int inOff, int len)
Parameters
inputbyte[]the byte array containing the data.
inOffintthe offset into the byte array where the data starts.
lenint
BlockUpdate(ReadOnlySpan<byte>)
Update the MAC with a span of bytes.
public void BlockUpdate(ReadOnlySpan<byte> input)
Parameters
inputReadOnlySpan<byte>the span containing the data.
DoFinal(byte[], int)
Perform final calculations, producing the result MAC.
public int DoFinal(byte[] output, int outOff)
Parameters
outputbyte[]the byte array the MAC is to be copied into.
outOffintthe offset into the byte array the MAC is to start at.
Returns
- int
the number of bytes written
Remarks
This call leaves the MAC reset.
DoFinal(Span<byte>)
Perform final calculations, producing the result MAC.
public int DoFinal(Span<byte> output)
Parameters
Returns
- int
the number of bytes written
Remarks
This call leaves the MAC reset.
GetMacSize()
Return the size, in bytes, of the MAC produced by this implementation.
public int GetMacSize()
Returns
- int
the size, in bytes, of the MAC produced by this implementation.
Init(ICipherParameters)
Initialises the GMAC - requires a ParametersWithIV providing a KeyParameter and a nonce.
public void Init(ICipherParameters parameters)
Parameters
parametersICipherParameters
Reset()
Reset the MAC back to its initial state.
public void Reset()
Update(byte)
Update the MAC with a single byte.
public void Update(byte input)
Parameters
inputbytethe input byte to be entered.