java.lang.Object
org.bouncycastle.pqc.crypto.mlkem.Symmetric
org.bouncycastle.pqc.crypto.mlkem.Symmetric.ShakeSymmetric
Enclosing class:
Symmetric

static class Symmetric.ShakeSymmetricextends Symmetric
SHAKE-based symmetric implementation for ML-KEM operations. Uses SHAKE extendable output functions for cryptographic hashing.
  • Nested Class Summary

    Nested classes/interfaces inherited from class Symmetric

    Symmetric.ShakeSymmetric
    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
    private final SHA3Digest
    The hash H', SHA3-256.
    private final SHA3Digest
    The hash H, SHA3-512.
    private final SHAKEDigest
    The extendable output function J.
    private final SHAKEDigest
    The extendable output function G.

    Fields inherited from class Symmetric

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

    Constructors
    Constructor
    Description
    Create shake symmetric.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) void
    hash_g(byte[] out, byte[] in)
    Hash g operation, the spec's G applied to a 128-byte input.
    (package private) void
    hash_h(byte[] out, byte[] in, int outOffset)
    Hash h operation, the spec's H applied to a 64-byte input.
    (package private) void
    kdf(byte[] out, byte[] in)
    KDF operation, deriving out.length bytes from in.
    (package private) void
    prf(byte[] out, byte[] seed, byte nonce)
    PRF operation, producing out.length bytes keyed by key and nonce.
    (package private) void
    xofAbsorb(byte[] seed, byte a, byte b)
    XOF absorb operation, seeding the extendable output function.
    (package private) 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

    • xof

      private final SHAKEDigest xof
      The extendable output function G.
    • sha3Digest512

      private final SHA3Digest sha3Digest512
      The hash H, SHA3-512.
    • sha3Digest256

      private final SHA3Digest sha3Digest256
      The hash H', SHA3-256.
    • shakeDigest

      private final SHAKEDigest shakeDigest
      The extendable output function J.
  • Constructor Details

    • ShakeSymmetric

      ShakeSymmetric()
      Create shake symmetric.
  • Method Details

    • hash_h

      void hash_h(byte[] out, byte[] in, int outOffset)
      Description copied from class: Symmetric
      Hash h operation, the spec's H applied to a 64-byte input.
      Specified by:
      hash_h in class Symmetric
      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

      void hash_g(byte[] out, byte[] in)
      Description copied from class: Symmetric
      Hash g operation, the spec's G applied to a 128-byte input.
      Specified by:
      hash_g in class Symmetric
      Parameters:
      out - the buffer to write the 64-byte hash into
      in - the 128 bytes to hash
    • xofAbsorb

      void xofAbsorb(byte[] seed, byte a, byte b)
      Description copied from class: Symmetric
      XOF absorb operation, seeding the extendable output function.
      Specified by:
      xofAbsorb in class Symmetric
      Parameters:
      seed - the 32-byte seed to absorb
      a - the low public-sample byte to absorb after the seed
      b - the high public-sample byte to absorb after x
    • xofSqueezeBlocks

      void xofSqueezeBlocks(byte[] out, int outOffset, int outLen)
      Description copied from class: Symmetric
      XOF squeeze operation, emitting whole rate-sized blocks at a time.
      Specified by:
      xofSqueezeBlocks in class Symmetric
      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

      void prf(byte[] out, byte[] seed, byte nonce)
      Description copied from class: Symmetric
      PRF operation, producing out.length bytes keyed by key and nonce.
      Specified by:
      prf in class Symmetric
      Parameters:
      out - the buffer to write the pseudorandom bytes into
      seed - the 32-byte pseudorandom key
      nonce - the single-byte nonce distinguishing one output from another
    • kdf

      void kdf(byte[] out, byte[] in)
      Description copied from class: Symmetric
      KDF operation, deriving out.length bytes from in.
      Specified by:
      kdf in class Symmetric
      Parameters:
      out - the buffer to write the derived bytes into
      in - the input keying material