Botan 3.4.0
Crypto and TLS for C&
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Botan::Dilithium_AES_Symmetric_Primitives Class Reference

#include <dilithium_aes.h>

Inheritance diagram for Botan::Dilithium_AES_Symmetric_Primitives:
Botan::Dilithium_Symmetric_Primitives

Public Types

enum class  XofType { k128 , k256 }
 

Public Member Functions

secure_vector< uint8_t > CRH (std::span< const uint8_t > in, size_t out_len) const
 
secure_vector< uint8_t > ExpandMask (std::span< const uint8_t > seed, uint16_t nonce, size_t out_len) const
 
secure_vector< uint8_t > H (std::span< const uint8_t > seed, size_t out_len) const
 
std::unique_ptr< Botan::XOFXOF (XofType, std::span< const uint8_t > seed, uint16_t nonce) const final
 

Static Public Member Functions

static std::unique_ptr< Dilithium_Symmetric_Primitivescreate (DilithiumMode mode)
 

Detailed Description

Definition at line 23 of file dilithium_aes.h.

Member Enumeration Documentation

◆ XofType

Member Function Documentation

◆ create()

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

Definition at line 22 of file dilithium_symmetric_primitives.cpp.

22 {
23#if BOTAN_HAS_DILITHIUM
24 if(mode.is_modern()) {
25 return std::make_unique<Dilithium_Common_Symmetric_Primitives>();
26 }
27#endif
28
29#if BOTAN_HAS_DILITHIUM_AES
30 if(mode.is_aes()) {
31 return std::make_unique<Dilithium_AES_Symmetric_Primitives>();
32 }
33#endif
34
35 throw Not_Implemented("requested Dilithium mode is not enabled in this build");
36}

References Botan::DilithiumMode::is_aes(), and Botan::DilithiumMode::is_modern().

◆ CRH()

secure_vector< uint8_t > Botan::Dilithium_Symmetric_Primitives::CRH ( std::span< const uint8_t > in,
size_t out_len ) const
inlineinherited

Definition at line 43 of file dilithium_symmetric_primitives.h.

43 {
44 return SHAKE_256(out_len * 8).process(in.data(), in.size());
45 }

References Botan::Buffered_Computation::process().

◆ ExpandMask()

secure_vector< uint8_t > Botan::Dilithium_Symmetric_Primitives::ExpandMask ( std::span< const uint8_t > seed,
uint16_t nonce,
size_t out_len ) const
inlineinherited

Definition at line 48 of file dilithium_symmetric_primitives.h.

48 {
49 return XOF(XofType::k256, seed, nonce)->output(out_len);
50 }
virtual std::unique_ptr< Botan::XOF > XOF(XofType type, std::span< const uint8_t > seed, uint16_t nonce) const =0

References Botan::Dilithium_Symmetric_Primitives::k256, and Botan::Dilithium_Symmetric_Primitives::XOF().

◆ H()

secure_vector< uint8_t > Botan::Dilithium_Symmetric_Primitives::H ( std::span< const uint8_t > seed,
size_t out_len ) const
inlineinherited

Definition at line 38 of file dilithium_symmetric_primitives.h.

38 {
39 return SHAKE_256(out_len * 8).process(seed.data(), seed.size());
40 }

References Botan::Buffered_Computation::process().

◆ XOF()

std::unique_ptr< Botan::XOF > Botan::Dilithium_AES_Symmetric_Primitives::XOF ( XofType ,
std::span< const uint8_t > seed,
uint16_t nonce ) const
inlinefinalvirtual

Implements Botan::Dilithium_Symmetric_Primitives.

Definition at line 26 of file dilithium_aes.h.

26 {
27 // Algorithm Spec V. 3.1 Section 5.3
28 // In the AES variant, the first 32 bytes of rhoprime are used as
29 // the key and i is extended to a 12 byte nonce for AES-256 in
30 // counter mode.
31 //
32 // I.e. when the XOF is used in "ExpandS" `seed` (aka rhoprime) will be
33 // 64 bytes long and must be truncated to the 32 most significant bytes.
34 BOTAN_ASSERT_NOMSG(seed.size() >= 32);
35
36 const std::array<uint8_t, 12> iv{get_byte<1>(nonce), get_byte<0>(nonce), 0};
37 const auto key = seed.first(32);
38
39 auto xof = std::make_unique<AES_256_CTR_XOF>();
40 xof->start(iv, key);
41 return xof;
42 }
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59

References BOTAN_ASSERT_NOMSG.


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