Class SaberAlgorithm
Capabilities
This algorithm exposes two capability families:- KEM: encapsulation with a recipient
PublicKeyand decapsulation with aPrivateKeyusingKemContext. - AGREEMENT: message-based agreement built on top of KEM via a
KemMessageAgreementAdapter, returning aMessageAgreementContextfor both initiator and responder flows.
Key material import and generation
The algorithm registers operation-specific key implementations for:SaberKeyGenSpec: generates SABER key pairs for the requested parameter set usingKeyPairGeneratorfrom 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 Summary
ConstructorsConstructorDescriptionCreates 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. -
Method Summary
Modifier and TypeMethodDescriptionList<ParameterSetDescriptor<? extends AlgorithmKeySpec>> Returns the discoverable parameter sets (or parameterized templates) supported by this algorithm.Methods inherited from class AbstractCryptoAlgorithm
capabilityMethods inherited from class CryptoAlgorithm
addCapability, asymmetricKeyPairGenerator, bindContext, createContext, displayName, id, keyOperations, listCapabilities, priority, privateKeyImporter, providerName, publicKeyImporter, registerAsymmetricKeyPairGenerator, registerPrivateKeyImporter, registerPublicKeyImporter, registerSymmetricKeyGenerator, registerSymmetricKeyImporter, requiresStatefulSigning, roles, supports, symmetricKeyGenerator, symmetricKeyImporter
-
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
KemContextandSaberKemContext. - Registers AGREEMENT capabilities that adapt KEM to
MessageAgreementContextfor initiator and responder roles. - Registers asymmetric key builders for generating SABER key pairs via
SaberKeyGenSpecand importing X.509 and PKCS#8 encodings.
Example
SaberAlgorithm alg = new SaberAlgorithm(); - Registers KEM encapsulate and decapsulate capabilities bound to
-
-
Method Details
-
parameterSets
Description copied from class:CryptoAlgorithmReturns 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 aParameterSetDescriptor.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:
parameterSetsin classCryptoAlgorithm- Returns:
- immutable list of parameter set descriptors; never
null
-