Botan 3.14.1
Crypto and TLS for C&
Botan::Dilithium_Expanded_Keypair_Codec Class Referencefinal

#include <dilithium_round3_symmetric_primitives.h>

Inheritance diagram for Botan::Dilithium_Expanded_Keypair_Codec:
Botan::Dilithium_Keypair_Codec

Public Member Functions

DilithiumDecodedKeypair decode_keypair (std::span< const uint8_t > private_key, DilithiumConstants mode) const override
secure_vector< uint8_t > encode_keypair (const DilithiumInternalKeypair &keypair, MlPrivateKeyFormat format) const override

Static Public Member Functions

static std::unique_ptr< Dilithium_Keypair_Codec > create (DilithiumMode mode)

Detailed Description

Definition at line 20 of file dilithium_round3_symmetric_primitives.h.

Member Function Documentation

◆ create()

std::unique_ptr< Dilithium_Keypair_Codec > Botan::Dilithium_Keypair_Codec::create ( DilithiumMode mode)
staticinherited

Definition at line 22 of file dilithium_keys.cpp.

22 {
23#if defined(BOTAN_HAS_DILITHIUM) || defined(BOTAN_HAS_DILITHIUM_AES)
24 if(mode.is_dilithium_round3()) {
25 return std::make_unique<Dilithium_Expanded_Keypair_Codec>();
26 }
27#endif
28
29#if defined(BOTAN_HAS_ML_DSA)
30 if(mode.is_ml_dsa()) {
31 return std::make_unique<ML_DSA_Expanding_Keypair_Codec>();
32 }
33#endif
34
35 throw Not_Implemented("requested ML-DSA/Dilithium mode is not implemented in this build");
36}

References Botan::DilithiumMode::is_dilithium_round3(), and Botan::DilithiumMode::is_ml_dsa().

Referenced by Botan::DilithiumConstants::DilithiumConstants().

◆ decode_keypair()

DilithiumDecodedKeypair Botan::Dilithium_Expanded_Keypair_Codec::decode_keypair ( std::span< const uint8_t > private_key,
DilithiumConstants mode ) const
overridevirtual

Decodes any supported private key encoding and reports the format that was detected.

Implements Botan::Dilithium_Keypair_Codec.

Definition at line 26 of file dilithium_round3_symmetric_primitives.cpp.

27 {
28 BOTAN_ARG_CHECK(mode.mode().is_available(), "Dilithium/ML-DSA mode is not available in this build");
29 if(private_key.size() != mode.private_key_bytes()) {
30 throw Decoding_Error("Dilithium: Invalid private key length");
31 }
32 return {
33 .keypair =
34 Dilithium_Algos::decode_keypair(StrongSpan<const DilithiumSerializedPrivateKey>(private_key), std::move(mode)),
36 };
37}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
DilithiumInternalKeypair decode_keypair(StrongSpan< const DilithiumSerializedPrivateKey > sk, DilithiumConstants mode)

References BOTAN_ARG_CHECK, Botan::Dilithium_Algos::decode_keypair(), Botan::Expanded, Botan::DilithiumMode::is_available(), Botan::DilithiumConstants::mode(), and Botan::DilithiumConstants::private_key_bytes().

◆ encode_keypair()

secure_vector< uint8_t > Botan::Dilithium_Expanded_Keypair_Codec::encode_keypair ( const DilithiumInternalKeypair & keypair,
MlPrivateKeyFormat format ) const
overridevirtual

Encodes the private key in the given format as content of the PKCS#8 privateKey field.

Exceptions
Encoding_Errorif the key cannot be encoded in format

Implements Botan::Dilithium_Keypair_Codec.

Definition at line 18 of file dilithium_round3_symmetric_primitives.cpp.

19 {
20 if(format != MlPrivateKeyFormat::Expanded) {
21 throw Encoding_Error("Dilithium round 3 private keys only support the expanded format");
22 }
23 return Dilithium_Algos::encode_keypair(keypair).get();
24}
constexpr T & get() &
Definition strong_type.h:81
DilithiumSerializedPrivateKey encode_keypair(const DilithiumInternalKeypair &keypair)

References Botan::Dilithium_Algos::encode_keypair(), Botan::Expanded, and Botan::detail::Strong_Base< T >::get().


The documentation for this class was generated from the following files: