Poly1305KeyGenerator Class

Generates keys for the Poly1305 MAC.

Definition

Namespace: Org.BouncyCastle.Crypto.Generators
Assembly: BouncyCastle.Cryptography (in BouncyCastle.Cryptography.dll) Version: 2.3.0-beta.187+d6da5648ae
public class Poly1305KeyGenerator : CipherKeyGenerator
Inheritance
Object    CipherKeyGenerator    Poly1305KeyGenerator

Remarks

Poly1305 keys are 256 bit keys consisting of a 128 bit secret key used for the underlying block cipher followed by a 128 bit {@code r} value used for the polynomial portion of the Mac.
The {@code r} value has a specific format with some bits required to be cleared, resulting in an effective 106 bit key.
A separately generated 256 bit key can be modified to fit the Poly1305 key format by using the {@link #clamp(byte[])} method to clear the required bits.

Constructors

Poly1305KeyGeneratorInitializes a new instance of the Poly1305KeyGenerator class

Properties

Methods

CheckKey Checks a 32 byte key for compliance with the Poly1305 key requirements, e.g.
C#
k[0] ... k[15], r[0] ... r[15]
with the required bits in
C#
r
cleared as per Clamp(Byte).
Clamp(Byte) Modifies an existing 32 byte key value to comply with the requirements of the Poly1305 key by clearing required bits in the
C#
r
(second 16 bytes) portion of the key.
Specifically:
  • r[3], r[7], r[11], r[15] have top four bits clear (i.e., are {0, 1, . . . , 15})
  • r[4], r[8], r[12] have bottom two bits clear (i.e., are in {0, 4, 8, . . . , 252})
Clamp(SpanByte) 
EngineGenerateKey Generates a 256 bit key in the format required for Poly1305 - e.g.
C#
k[0] ... k[15], r[0] ... r[15]
with the required bits in
C#
r
cleared as per Clamp(Byte).
(Overrides CipherKeyGeneratorEngineGenerateKey)
EngineGenerateKeyParameter
(Overrides CipherKeyGeneratorEngineGenerateKeyParameter)
EngineInit Initialises the key generator.
(Overrides CipherKeyGeneratorEngineInit(KeyGenerationParameters))
EnsureInitialized
(Inherited from CipherKeyGenerator)
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GenerateKey
(Inherited from CipherKeyGenerator)
GenerateKeyParameter
(Inherited from CipherKeyGenerator)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Init
(Inherited from CipherKeyGenerator)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Fields

random
(Inherited from CipherKeyGenerator)
strength
(Inherited from CipherKeyGenerator)

See Also