Class CmceAlgorithm


public final class CmceAlgorithm extends AbstractCryptoAlgorithm

Classic McEliece (CMCE) algorithm adapter

Integrates the Bouncy Castle PQC CMCE primitives into the ZeroEcho SPI. This algorithm publishes:

  • KEM capabilities:
  • Agreement capability implemented via a KEM-backed adapter:
    • Initiator: constructs an agreement context that encapsulates to the peer public key.
    • Responder: constructs an agreement context that decapsulates with the local private key.
  • Asymmetric key builders:
    • Key generation from CmceKeyGenSpec variants.
    • Public key import from X.509 bytes.
    • Private key import from PKCS#8 bytes.

Provider requirement: the Bouncy Castle provider must be registered under the standard name "BC" before use.

Usage example:

// Register BC once at startup.
Security.addProvider(new BouncyCastleProvider());

// Obtain contexts using the CMCE algorithm id.
CmceAlgorithm alg = new CmceAlgorithm();

// Generate a key pair with a chosen CMCE variant.
KeyPair kp = alg.asymmetricKeyPairGenerator(CmceKeyGenSpec.class)
                .generateKeyPair(CmceKeyGenSpec.mceliece8192128f());

// Create a KEM encapsulation context with the recipient public key.
KemContext enc = alg.createContext(KeyUsage.ENCAPSULATE, kp.getPublic(), VoidSpec.INSTANCE);

// Create an agreement initiator context backed by CMCE KEM.
MessageAgreementContext initiator =
    alg.createContext(KeyUsage.AGREEMENT, kp.getPublic(), VoidSpec.INSTANCE);
Since:
1.0
  • Constructor Details

    • CmceAlgorithm

      public CmceAlgorithm()
      Constructs and registers CMCE capabilities and key builders.

      This constructor registers:

      • KEM roles for ENCAPSULATE and DECAPSULATE.
      • Agreement role wired through a KEM-backed initiator/responder adapter.
      • Asymmetric key builder for CmceKeyGenSpec (generation), X.509 public key import, and PKCS#8 private key import.

      The algorithm id is "CMCE", the display name is "Classic McEliece (CMCE)", and the provider name is taken from the Bouncy Castle provider.

  • 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