java.lang.Object
org.bouncycastle.pqc.crypto.mlkem.Symmetric
- Direct Known Subclasses:
Symmetric.ShakeSymmetric
Abstract base class for symmetric cryptographic primitives in ML-KEM. Provides hash function interfaces for different symmetric operations.
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classSHAKE-based symmetric implementation for ML-KEM operations.Field Summary
FieldsModifier and TypeFieldDescription(package private) final intBytes produced per call to the XOF squeeze, i.e.Constructor Summary
ConstructorsConstructorDescriptionSymmetric(int blockBytes) Create a symmetric primitive set with the given XOF rate.Method Summary
All MethodsModifier and TypeMethodDescription(package private) abstract voidhash_g(byte[] out, byte[] in) Hash g operation, the spec's G applied to a 128-byte input.(package private) abstract voidhash_h(byte[] out, byte[] in, int outOffset) Hash h operation, the spec's H applied to a 64-byte input.(package private) abstract voidkdf(byte[] out, byte[] in) KDF operation, deriving out.length bytes from in.(package private) abstract voidprf(byte[] out, byte[] key, byte nonce) PRF operation, producing out.length bytes keyed by key and nonce.(package private) abstract voidxofAbsorb(byte[] seed, byte x, byte y) XOF absorb operation, seeding the extendable output function.(package private) abstract voidxofSqueezeBlocks(byte[] out, int outOffset, int outLen) XOF squeeze operation, emitting whole rate-sized blocks at a time.
Field Details
xofBlockBytes
final int xofBlockBytesBytes produced per call to the XOF squeeze, i.e. the SHAKE rate.
Constructor Details
Symmetric
Symmetric(int blockBytes) Create a symmetric primitive set with the given XOF rate.- Parameters:
blockBytes- the XOF rate in bytes, the granularity of each squeeze
Method Details
hash_h
abstract void hash_h(byte[] out, byte[] in, int outOffset) Hash h operation, the spec's H applied to a 64-byte input.- Parameters:
out- the buffer to write the 32-byte hash intoin- the 64 bytes to hashoutOffset- the offset into out at which to write the hash
hash_g
abstract void hash_g(byte[] out, byte[] in) Hash g operation, the spec's G applied to a 128-byte input.- Parameters:
out- the buffer to write the 64-byte hash intoin- the 128 bytes to hash
xofAbsorb
abstract void xofAbsorb(byte[] seed, byte x, byte y) XOF absorb operation, seeding the extendable output function.- Parameters:
seed- the 32-byte seed to absorbx- the low public-sample byte to absorb after the seedy- the high public-sample byte to absorb after x
xofSqueezeBlocks
abstract void xofSqueezeBlocks(byte[] out, int outOffset, int outLen) XOF squeeze operation, emitting whole rate-sized blocks at a time.- Parameters:
out- the buffer to write the expanded bytes intooutOffset- the offset into out at which to writeoutLen- the number of bytes to write, a multiple of xofBlockBytes
prf
abstract void prf(byte[] out, byte[] key, byte nonce) PRF operation, producing out.length bytes keyed by key and nonce.- Parameters:
out- the buffer to write the pseudorandom bytes intokey- the 32-byte pseudorandom keynonce- the single-byte nonce distinguishing one output from another
kdf
abstract void kdf(byte[] out, byte[] in) KDF operation, deriving out.length bytes from in.- Parameters:
out- the buffer to write the derived bytes intoin- the input keying material