CryptoSys PQC  1.0.0
Classes | Public Types | Static Public Member Functions | List of all members
crsyspqc::Kem Class Reference

Key-Encapsulation Mechanism (KEM) methods. More...

Classes

struct  EncapOutput
 Structure to receive KEM encapsulation output (ss, ct) More...
 
struct  KeyPair
 Structure to receive a key pair (ek, dk) More...
 

Public Types

enum class  Alg
 Key-Encapsulation Mechanism (KEM) algorithm. More...
 

Static Public Member Functions

static KeyPair KeyGen (Alg alg, const std::string &params="")
 Generate an encapsulation/decapsulation key pair (ek, dk). More...
 
static EncapOutput Encaps (Alg alg, bvec_t ek, const std::string &params="")
 Carry out the KEM encapsulation algorithm. More...
 
static bvec_t Decaps (Alg alg, bvec_t ct, bvec_t dk)
 Carry out the KEM decapsulation algorithm. More...
 
static int EncapKeySize (Alg alg)
 Return length of encapulation ("public") key ek in bytes.
 
static int DecapKeySize (Alg alg)
 Return length of expanded decapulation ("private") key dk in bytes.
 
static int CipherTextSize (Alg alg)
 Return length of ciphertext ct in bytes.
 
static int SharedKeySize (Alg alg)
 Return length of shared secret key ss (K) in bytes.
 
static std::string AlgName (Alg alg)
 Get algorithm name from its alg code.
 

Detailed Description

Key-Encapsulation Mechanism (KEM) methods.

Member Enumeration Documentation

◆ Alg

enum crsyspqc::Kem::Alg
strong

Key-Encapsulation Mechanism (KEM) algorithm.

Enumerator
ML_KEM_512 

ML-KEM-512 from FIPS.203 (based on Kyber512)

ML_KEM_768 

ML-KEM-768 from FIPS.203 (based on Kyber768)

ML_KEM_1024 

ML-KEM-1024 from FIPS.203 (based on Kyber1024)

Member Function Documentation

◆ KeyGen()

static KeyPair crsyspqc::Kem::KeyGen ( Alg  alg,
const std::string &  params = "" 
)
static

Generate an encapsulation/decapsulation key pair (ek, dk).

Parameters
algKEM algorithm.
paramsOptional parameters string. Use to pass a known test random value encoded in hexadecimal. [default = add fresh randomness].
Returns
Key pair in Kem::KeyPair structure.

◆ Encaps()

static EncapOutput crsyspqc::Kem::Encaps ( Alg  alg,
bvec_t  ek,
const std::string &  params = "" 
)
static

Carry out the KEM encapsulation algorithm.

Parameters
algKEM algorithm.
ekEncapsulation key.
paramsOptional parameters string. Use to pass a known test random value encoded in hexadecimal. [default = add fresh randomness].
Returns
Shared secret key (ss) and ciphertext (ct) in Kem::EncapOutput structure.

◆ Decaps()

static bvec_t crsyspqc::Kem::Decaps ( Alg  alg,
bvec_t  ct,
bvec_t  dk 
)
static

Carry out the KEM decapsulation algorithm.

Parameters
algKEM algorithm.
ctCiphertext (ct) in a byte array.
dkDecapsulation key.
Returns
Shared secret key (ss) in a byte array. On failure it will contain a pseudo-random value.
Remarks
The decapsulation (private) key dk may be passed in expanded form (1632|2400|3168 bytes) or as a 64-byte seed. The key form is detected automatically by its length.
Copyright (C) 2024-25 D.I. Management Services Pty Limited t/a CryptoSys ABN 78 083 210 584 Australia. All rights reserved. <www.di-mgt.com.au> <www.cryptosys.net>. Generated on Sat May 24 2025 20:58:07 by Doxygen 1.9.1.