Skip to content

IKemKeyBase

Jay edited this page Oct 3, 2026 · 2 revisions

IKemKeyBase

#include <certpp/crypto/keys.hpp> --- certpp::crypto --- implements IKeyBase

Key base for KEM algorithms (see EKems's own doc comment for why this doesn't reuse IAsymmetricKeyBase).

Methods

IKemKeyBase()

virtual ~IKemKeyBase() = default

Virtual destructor.

virtual SKeySize keySize() const = 0

Returns: The key size, in the algorithm's natural unit -- for a fixed-parameter-set algorithm like ML-KEM, its nominal parameter-set label (e.g. 512/768/1024), the same way ESYM_AES's keySize() reports 128/192/256 rather than a continuously variable size.

inline EKems algorithm() const

Returns: Which built-in algorithm produced this key -- e.g. to pick the right SubjectPublicKeyInfo/ciphertext OID when embedding it in a certificate/CMS structure, without the caller having to separately track which IKem it came from.

Example

Reads what a KEM key is, through the base both halves share. The algorithm travels with the key so an encoder can pick the right OID, and keySize() reports the parameter-set label (512/768/1024) rather than a bit count.

// given: const crypto::IKemKeyBasePtr& key
if (key->algorithm() == crypto::EKEM_UNKNOWN) {
    return; // never came out of an IKem factory
}

if (key->keySize() < 768) {
    return; // ML-KEM-512 is below this deployment's floor
}

COctet encoded;
if (key->serialize(encoded) != ERET_OK) {
    return;
}

Reference generated from certpp/crypto/keys.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.

Clone this wiki locally