Class SaberAlgorithm


public final class SaberAlgorithm extends AbstractCryptoAlgorithm
Implements the SABER post-quantum key encapsulation mechanism for the crypto catalog and wires it to the Bouncy Castle PQC provider.

Capabilities

This algorithm exposes two capability families:
  • KEM: encapsulation with a recipient PublicKey and decapsulation with a PrivateKey using KemContext.
  • AGREEMENT: message-based agreement built on top of KEM via a KemMessageAgreementAdapter, returning a MessageAgreementContext for both initiator and responder flows.
The agreement capability simply adapts the underlying KEM operation into a message-oriented interface suitable for one-pass key agreement.

Key material import and generation

The algorithm registers operation-specific key implementations for:
  • SaberKeyGenSpec: generates SABER key pairs for the requested parameter set using KeyPairGenerator from the provider.
  • zeroecho.core.alg.saber.SaberPublicKeySpec: imports an X.509-encoded SABER public key.
  • zeroecho.core.alg.saber.SaberPrivateKeySpec: imports a PKCS#8-encoded SABER private key.

Instances of this class are lightweight and stateless after construction. All provider lookups are performed on demand.

Example

CryptoAlgorithm saber = new SaberAlgorithm();

// Generate a key pair for a specific SABER variant
KeyPair kp = saber.asymmetricKeyPairGenerator(SaberKeyGenSpec.class)
                   .generateKeyPair(SaberKeyGenSpec.saberkem256r3());

// Encapsulation (initiator)
KemContext enc = saber.createContext(KeyUsage.ENCAPSULATE, kp.getPublic(), VoidSpec.INSTANCE);
KemResult out = enc.encapsulate();

// Decapsulation (responder)
KemContext dec = saber.createContext(KeyUsage.DECAPSULATE, kp.getPrivate(), VoidSpec.INSTANCE);
SecretKey k = dec.decapsulate(out.ciphertext());
  • Constructor Details

    • SaberAlgorithm

      public SaberAlgorithm()
      Creates a SABER algorithm instance backed by the Bouncy Castle PQC provider and registers KEM and AGREEMENT capabilities, along with key generation and key import builders for SABER public and private keys.

      The constructor:

      • Registers KEM encapsulate and decapsulate capabilities bound to KemContext and SaberKemContext.
      • Registers AGREEMENT capabilities that adapt KEM to MessageAgreementContext for initiator and responder roles.
      • Registers asymmetric key builders for generating SABER key pairs via SaberKeyGenSpec and importing X.509 and PKCS#8 encodings.

      Example

      SaberAlgorithm alg = new SaberAlgorithm();
      
  • Method Details

    • parameterSets

      public List<ParameterSetDescriptor<? extends AlgorithmKeySpec>> parameterSets()
      Description copied from class: CryptoAlgorithm
      Returns the discoverable parameter sets (or parameterized templates) supported by this algorithm.

      Callers (UIs, provisioning tools, policy engines) use this list to present users with valid, named key-generation options without prior knowledge of the concrete algorithm. Each entry is either a pre-built ParameterSetDescriptor.Concrete (ready spec) or a ParameterSetDescriptor.Template (user-supplied arguments produce the spec).

      The default implementation returns an empty list. Algorithms with finite, enumerable parameter sets should override this method. Overrides must return immutable lists in stable order, with unique nonblank descriptor identifiers. Registry loading validates a snapshot; external providers remain responsible for maintaining the contract on subsequent calls. Implementations may use ParameterSetDescriptor.snapshot(List) to validate and copy their list.

      Overrides:
      parameterSets in class CryptoAlgorithm
      Returns:
      immutable list of parameter set descriptors; never null