Botan 3.14.1
Crypto and TLS for C&
dilithium_round3_symmetric_primitives.cpp
Go to the documentation of this file.
1/*
2* Asymmetric primitives for Dilithium round 3
3* (C) 2021-2024 Jack Lloyd
4* 2021-2022 Manuel Glaser and Michael Boric, Rohde & Schwarz Cybersecurity
5* 2021-2022 René Meusel and Hannes Rantzsch, neXenio GmbH
6* 2024 Fabian Albert and René Meusel, Rohde & Schwarz Cybersecurity
7*
8* Botan is released under the Simplified BSD License (see license.txt)
9*/
10
11#include <botan/internal/dilithium_round3_symmetric_primitives.h>
12
13#include <botan/exceptn.h>
14#include <botan/internal/dilithium_algos.h>
15
16namespace Botan {
17
19 MlPrivateKeyFormat format) const {
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}
25
27 DilithiumConstants mode) const {
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 =
36 };
37}
38
39} // namespace Botan
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
size_t private_key_bytes() const
byte length of the encoded private key
bool is_available() const
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
constexpr T & get() &
Definition strong_type.h:81
DilithiumSerializedPrivateKey encode_keypair(const DilithiumInternalKeypair &keypair)
DilithiumInternalKeypair decode_keypair(StrongSpan< const DilithiumSerializedPrivateKey > sk, DilithiumConstants mode)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128
std::pair< std::shared_ptr< const Dilithium_PublicKeyInternal >, std::shared_ptr< const Dilithium_PrivateKeyInternal > > DilithiumInternalKeypair
Internal representation of a Dilithium key pair.
A decoded private key together with the encoding format it was found in.