Top Description Fields Constructors Methods
org.bouncycastle.crypto.macs

public Class KGMac

extends Object
implements Mac
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.Mac
Imports
org.bouncycastle.crypto.CipherParameters, .DataLengthException, .InvalidCipherTextException, .Mac, org.bouncycastle.crypto.modes.KGCMBlockCipher, org.bouncycastle.crypto.params.AEADParameters, .KeyParameter, .ParametersWithIV

The GMAC specialisation of Galois/Counter mode (GCM) detailed in NIST Special Publication 800-38D as adapted for the Kalyna version of GCM.

KGMac is an invocation of the KGCM mode where no data is encrypted (i.e. all input data to the Mac is processed as additional authenticated data with the underlying KGCM block cipher).

Field Summary

Modifier and TypeField and Description
private final KGCMBlockCipher
private final int

Constructor Summary

AccessConstructor and Description
public
KGMac(final KGCMBlockCipher
the cipher to be used in GCM mode to generate the MAC.
cipher
)

Creates a KGMAC based on the operation of a block cipher in GCM mode.

public
KGMac(final KGCMBlockCipher
the cipher to be used in GCM mode to generate the MAC.
cipher
,
final int
the mac size to generate, in bits. Must be a multiple of 8 and >= 32 and <= 128. Sizes less than 96 are not recommended, but are supported for specialized applications.
macSizeBits
)

Creates a GMAC based on the operation of a 128 bit block cipher in GCM mode.

Method Summary

Modifier and TypeMethod and Description
public int
doFinal(byte[]
the array the MAC is to be output to.
out
,
int
the offset into the out buffer the output is to start at.
outOff
)

Implements org.bouncycastle.crypto.Mac.doFinal.

Compute the final stage of the MAC writing the output to the out parameter.
public String
getAlgorithmName()

Implements org.bouncycastle.crypto.Mac.getAlgorithmName.

Return the name of the algorithm the MAC implements.
public int
getMacSize()

Implements org.bouncycastle.crypto.Mac.getMacSize.

Return the block size for this MAC (in bytes).
public void
init(final CipherParameters
the key and other data required by the MAC.
params
)

Implements org.bouncycastle.crypto.Mac.init.

Initialises the GMAC - requires a ParametersWithIV providing a KeyParameter and a nonce.
public void
reset()

Implements org.bouncycastle.crypto.Mac.reset.

Reset the MAC.
public void
update(byte
the byte to be processed.
in
)

Implements org.bouncycastle.crypto.Mac.update.

add a single byte to the mac for processing.
public void
update(byte[]
the array containing the input.
in
,
int
the index in the array the data begins at.
inOff
,
int
the length of the input starting at inOff.
len
)

Implements org.bouncycastle.crypto.Mac.update.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cipherback to summary
private final KGCMBlockCipher cipher
macSizeBitsback to summary
private final int macSizeBits

Constructor Detail

KGMacback to summary
public KGMac(final KGCMBlockCipher cipher)

Creates a KGMAC based on the operation of a block cipher in GCM mode.

This will produce an authentication code the length of the block size of the cipher.

Parameters
cipher:KGCMBlockCipher

the cipher to be used in GCM mode to generate the MAC.

KGMacback to summary
public KGMac(final KGCMBlockCipher cipher, final int macSizeBits)

Creates a GMAC based on the operation of a 128 bit block cipher in GCM mode.

Parameters
cipher:KGCMBlockCipher

the cipher to be used in GCM mode to generate the MAC.

macSizeBits:int

the mac size to generate, in bits. Must be a multiple of 8 and >= 32 and <= 128. Sizes less than 96 are not recommended, but are supported for specialized applications.

Method Detail

doFinalback to summary
public int doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException

Implements org.bouncycastle.crypto.Mac.doFinal.

Doc from org.bouncycastle.crypto.Mac.doFinal.

Compute the final stage of the MAC writing the output to the out parameter.

doFinal leaves the MAC in the same state it was after the last init.

Parameters
out:byte[]

the array the MAC is to be output to.

outOff:int

the offset into the out buffer the output is to start at.

Exceptions
DataLengthException:
if there isn't enough space in out.
IllegalStateException:
if the MAC is not initialised.
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.Mac.getAlgorithmName.

Doc from org.bouncycastle.crypto.Mac.getAlgorithmName.

Return the name of the algorithm the MAC implements.

Returns:String

the name of the algorithm the MAC implements.

getMacSizeback to summary
public int getMacSize()

Implements org.bouncycastle.crypto.Mac.getMacSize.

Doc from org.bouncycastle.crypto.Mac.getMacSize.

Return the block size for this MAC (in bytes).

Returns:int

the block size for this MAC in bytes.

initback to summary
public void init(final CipherParameters params) throws IllegalArgumentException

Implements org.bouncycastle.crypto.Mac.init.

Initialises the GMAC - requires a ParametersWithIV providing a KeyParameter and a nonce.

Parameters
params:CipherParameters

Doc from org.bouncycastle.crypto.Mac.init.

the key and other data required by the MAC.

Exceptions
IllegalArgumentException:

Doc from org.bouncycastle.crypto.Mac.init.

if the params argument is inappropriate.

resetback to summary
public void reset()

Implements org.bouncycastle.crypto.Mac.reset.

Doc from org.bouncycastle.crypto.Mac.reset.

Reset the MAC. At the end of resetting the MAC should be in the in the same state it was after the last init (if there was one).

updateback to summary
public void update(byte in) throws IllegalStateException

Implements org.bouncycastle.crypto.Mac.update.

Doc from org.bouncycastle.crypto.Mac.update.

add a single byte to the mac for processing.

Parameters
in:byte

the byte to be processed.

Exceptions
IllegalStateException:
if the MAC is not initialised.
updateback to summary
public void update(byte[] in, int inOff, int len) throws DataLengthException, IllegalStateException

Implements org.bouncycastle.crypto.Mac.update.

Parameters
in:byte[]

Doc from org.bouncycastle.crypto.Mac.update.

the array containing the input.

inOff:int

Doc from org.bouncycastle.crypto.Mac.update.

the index in the array the data begins at.

len:int

Doc from org.bouncycastle.crypto.Mac.update.

the length of the input starting at inOff.

Exceptions
DataLengthException:

Doc from org.bouncycastle.crypto.Mac.update.

if there isn't enough data in in.

IllegalStateException:

Doc from org.bouncycastle.crypto.Mac.update.

if the MAC is not initialised.