java.lang.Object
org.bouncycastle.pqc.crypto.mlkem.Symmetric
Direct Known Subclasses:
Symmetric.ShakeSymmetric

abstract class Symmetricextends Object
Abstract base class for symmetric cryptographic primitives in ML-KEM. Provides hash function interfaces for different symmetric operations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    SHAKE-based symmetric implementation for ML-KEM operations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final int
    Bytes produced per call to the XOF squeeze, i.e.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Symmetric(int blockBytes)
    Create a symmetric primitive set with the given XOF rate.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) abstract void
    hash_g(byte[] out, byte[] in)
    Hash g operation, the spec's G applied to a 128-byte input.
    (package private) abstract void
    hash_h(byte[] out, byte[] in, int outOffset)
    Hash h operation, the spec's H applied to a 64-byte input.
    (package private) abstract void
    kdf(byte[] out, byte[] in)
    KDF operation, deriving out.length bytes from in.
    (package private) abstract void
    prf(byte[] out, byte[] key, byte nonce)
    PRF operation, producing out.length bytes keyed by key and nonce.
    (package private) abstract void
    xofAbsorb(byte[] seed, byte x, byte y)
    XOF absorb operation, seeding the extendable output function.
    (package private) abstract void
    xofSqueezeBlocks(byte[] out, int outOffset, int outLen)
    XOF squeeze operation, emitting whole rate-sized blocks at a time.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • xofBlockBytes

      final int xofBlockBytes
      Bytes 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 into
      in - the 64 bytes to hash
      outOffset - 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 into
      in - 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 absorb
      x - the low public-sample byte to absorb after the seed
      y - 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 into
      outOffset - the offset into out at which to write
      outLen - 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 into
      key - the 32-byte pseudorandom key
      nonce - 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 into
      in - the input keying material