APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

pack-priv final Class Poly1305

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.security.InvalidKeyException, .Key, java.security.spec.AlgorithmParameterSpec, java.util.Arrays, .Objects, jdk.internal.vm.annotation.ForceInline, .IntrinsicCandidate, sun.security.util.math.IntegerFieldModuloP, .IntegerModuloP, .MutableIntegerModuloP, sun.security.util.math.intpoly.IntegerPolynomial1305

This class represents the Poly1305 function defined in RFC 7539. This function is used in the implementation of ChaCha20/Poly1305 AEAD mode.

Field Summary

Modifier and TypeField and Description
private MutableIntegerModuloP
a

private final byte[]
private static final int
private int
private final boolean
private static final IntegerFieldModuloP
private static final int
private byte[]
private final MutableIntegerModuloP
n

private IntegerModuloP
r

private static final int
private IntegerModuloP
s

private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
Poly1305(boolean checkKey)

Method Summary

Modifier and TypeMethod and Description
pack-priv byte[]

Returns:

the authentication tag as a byte array.
engineDoFinal
()

Finish the authentication operation and reset the MAC for a new authentication operation.

pack-priv int

Returns:

the length of the auth tag, which is always 16 bytes.
engineGetMacLength
()

Returns the length of the MAC (authentication tag).

pack-priv void
engineInit(Key
the Key which will be used for the authentication.
newKey
,
AlgorithmParameterSpec
this parameter is unused.
params
)

Initialize the Poly1305 object

pack-priv void
engineReset()

Reset the Poly1305 object, discarding any current operation but maintaining the same key.

pack-priv void
engineUpdate(ByteBuffer
the ByteBuffer containing the data to be consumed. Upon return the buffer's position will be equal to its limit.
buf
)

Update the MAC with bytes from a ByteBuffer

pack-priv void
engineUpdate(byte[]
the input bytes.
input
,
int
the starting index from which to update the MAC.
offset
,
int
the number of bytes to process.
len
)

Update the MAC with bytes from an array.

pack-priv void
engineUpdate(byte
the byte to update the MAC with.
input
)

Update the MAC with a single byte of input

private void
processBlock(ByteBuffer buf, int len)

Process a single block of data.

private void
processBlock(byte[] block, int offset, int length)

private void
processMultipleBlocks(byte[] input, int offset, int length, long[] aLimbs, long[] rLimbs)

private void
processMultipleBlocks(ByteBuffer buf, int blockMultipleLength)

private static void
processMultipleBlocksCheck(byte[] input, int offset, int length, long[] aLimbs, long[] rLimbs)

private void
setRSVals()

Partition the authentication key into the R and S components, clamp the R value, and instantiate IntegerModuloP objects to R and S's numeric values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aback to summary
private MutableIntegerModuloP a
blockback to summary
private final byte[] block
BLOCK_LENGTHback to summary
private static final int BLOCK_LENGTH
blockOffsetback to summary
private int blockOffset
checkWeakKeyback to summary
private final boolean checkWeakKey
ipl1305back to summary
private static final IntegerFieldModuloP ipl1305
KEY_LENGTHback to summary
private static final int KEY_LENGTH
keyBytesback to summary
private byte[] keyBytes
nback to summary
private final MutableIntegerModuloP n
rback to summary
private IntegerModuloP r
RS_LENGTHback to summary
private static final int RS_LENGTH
sback to summary
private IntegerModuloP s
TAG_LENGTHback to summary
private static final int TAG_LENGTH

Constructor Detail

Poly1305back to summary
pack-priv Poly1305()
Poly1305back to summary
pack-priv Poly1305(boolean checkKey)

Method Detail

engineDoFinalback to summary
pack-priv byte[] engineDoFinal()

Finish the authentication operation and reset the MAC for a new authentication operation.

Returns:byte[]

the authentication tag as a byte array.

engineGetMacLengthback to summary
pack-priv int engineGetMacLength()

Returns the length of the MAC (authentication tag).

Returns:int

the length of the auth tag, which is always 16 bytes.

engineInitback to summary
pack-priv void engineInit(Key newKey, AlgorithmParameterSpec params) throws InvalidKeyException

Initialize the Poly1305 object

Parameters
newKey:Key

the Key which will be used for the authentication.

params:AlgorithmParameterSpec

this parameter is unused.

Exceptions
InvalidKeyException:
if newKey is null or is not 32 bytes in length.
engineResetback to summary
pack-priv void engineReset()

Reset the Poly1305 object, discarding any current operation but maintaining the same key.

engineUpdateback to summary
pack-priv void engineUpdate(ByteBuffer buf)

Update the MAC with bytes from a ByteBuffer

Parameters
buf:ByteBuffer

the ByteBuffer containing the data to be consumed. Upon return the buffer's position will be equal to its limit.

engineUpdateback to summary
pack-priv void engineUpdate(byte[] input, int offset, int len)

Update the MAC with bytes from an array.

Parameters
input:byte[]

the input bytes.

offset:int

the starting index from which to update the MAC.

len:int

the number of bytes to process.

engineUpdateback to summary
pack-priv void engineUpdate(byte input)

Update the MAC with a single byte of input

Parameters
input:byte

the byte to update the MAC with.

processBlockback to summary
private void processBlock(ByteBuffer buf, int len)

Process a single block of data. This should only be called when the block array is complete. That may not necessarily be a full 16 bytes if the last block has less than 16 bytes.

processBlockback to summary
private void processBlock(byte[] block, int offset, int length)
processMultipleBlocksback to summary
private void processMultipleBlocks(byte[] input, int offset, int length, long[] aLimbs, long[] rLimbs)
Annotations
@ForceInline
@IntrinsicCandidate
processMultipleBlocksback to summary
private void processMultipleBlocks(ByteBuffer buf, int blockMultipleLength)
processMultipleBlocksCheckback to summary
private static void processMultipleBlocksCheck(byte[] input, int offset, int length, long[] aLimbs, long[] rLimbs)
setRSValsback to summary
private void setRSVals() throws InvalidKeyException

Partition the authentication key into the R and S components, clamp the R value, and instantiate IntegerModuloP objects to R and S's numeric values.