Botan 3.0.0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Botan::ANSI_X919_MAC Class Referencefinal

#include <x919_mac.h>

Inheritance diagram for Botan::ANSI_X919_MAC:
Botan::MessageAuthenticationCode Botan::Buffered_Computation Botan::SymmetricAlgorithm

Public Member Functions

 ANSI_X919_MAC ()
 
 ANSI_X919_MAC (const ANSI_X919_MAC &)=delete
 
void clear () override
 
MessageAuthenticationCodeclone () const
 
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T final ()
 
void final (std::span< uint8_t > out)
 
template<concepts::resizable_byte_buffer T>
void final (T &out)
 
void final (uint8_t out[])
 
std::vector< uint8_t > final_stdvec ()
 
virtual bool fresh_key_required_per_message () const
 
bool has_keying_material () const override
 
Key_Length_Specification key_spec () const override
 
size_t maximum_keylength () const
 
size_t minimum_keylength () const
 
std::string name () const override
 
std::unique_ptr< MessageAuthenticationCodenew_object () const override
 
ANSI_X919_MACoperator= (const ANSI_X919_MAC &)=delete
 
size_t output_length () const override
 
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T process (const uint8_t in[], size_t length)
 
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T process (std::span< const uint8_t > in)
 
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T process (std::string_view in)
 
virtual std::string provider () const
 
void set_key (const SymmetricKey &key)
 
void set_key (const uint8_t key[], size_t length)
 
void set_key (std::span< const uint8_t > key)
 
void start ()
 
void start (const uint8_t nonce[], size_t nonce_len)
 
void start (std::span< const uint8_t > nonce)
 
void update (const uint8_t in[], size_t length)
 
void update (std::span< const uint8_t > in)
 
void update (std::string_view str)
 
void update (uint8_t in)
 
void update_be (uint16_t val)
 
void update_be (uint32_t val)
 
void update_be (uint64_t val)
 
void update_le (uint16_t val)
 
void update_le (uint32_t val)
 
void update_le (uint64_t val)
 
bool valid_keylength (size_t length) const
 
bool verify_mac (const uint8_t in[], size_t length)
 
bool verify_mac (std::span< const uint8_t > in)
 

Static Public Member Functions

static std::unique_ptr< MessageAuthenticationCodecreate (std::string_view algo_spec, std::string_view provider="")
 
static std::unique_ptr< MessageAuthenticationCodecreate_or_throw (std::string_view algo_spec, std::string_view provider="")
 
static std::vector< std::string > providers (std::string_view algo_spec)
 

Protected Member Functions

void assert_key_material_set () const
 
void assert_key_material_set (bool predicate) const
 
virtual void start_msg (const uint8_t nonce[], size_t nonce_len)
 
virtual bool verify_mac_result (const uint8_t in[], size_t length)
 

Detailed Description

DES/3DES-based MAC from ANSI X9.19

Definition at line 19 of file x919_mac.h.

Constructor & Destructor Documentation

◆ ANSI_X919_MAC() [1/2]

Botan::ANSI_X919_MAC::ANSI_X919_MAC ( )

Definition at line 98 of file x919_mac.cpp.

98 :
99 m_des1(BlockCipher::create("DES")),
100 m_des2(m_des1->new_object()),
101 m_position(0)
102 {
103 }
static std::unique_ptr< BlockCipher > create(std::string_view algo_spec, std::string_view provider="")

◆ ANSI_X919_MAC() [2/2]

Botan::ANSI_X919_MAC::ANSI_X919_MAC ( const ANSI_X919_MAC )
delete

Member Function Documentation

◆ assert_key_material_set() [1/2]

void Botan::SymmetricAlgorithm::assert_key_material_set ( ) const
inlineprotectedinherited

Definition at line 182 of file sym_algo.h.

183 {
185 }
virtual bool has_keying_material() const =0
void assert_key_material_set() const
Definition: sym_algo.h:182

Referenced by Botan::Salsa20::cipher_bytes(), Botan::AES_128::decrypt_n(), Botan::AES_192::decrypt_n(), Botan::AES_256::decrypt_n(), Botan::ARIA_128::decrypt_n(), Botan::ARIA_192::decrypt_n(), Botan::ARIA_256::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::Camellia_128::decrypt_n(), Botan::Camellia_192::decrypt_n(), Botan::Camellia_256::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::DES::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::Lion::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::SEED::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::SHACAL2::decrypt_n(), Botan::SM4::decrypt_n(), Botan::Threefish_512::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::AES_128::encrypt_n(), Botan::AES_192::encrypt_n(), Botan::AES_256::encrypt_n(), Botan::ARIA_128::encrypt_n(), Botan::ARIA_192::encrypt_n(), Botan::ARIA_256::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::Camellia_128::encrypt_n(), Botan::Camellia_192::encrypt_n(), Botan::Camellia_256::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::DES::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::Lion::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::SEED::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::SHACAL2::encrypt_n(), Botan::SM4::encrypt_n(), Botan::Threefish_512::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::GHASH::final(), Botan::GHASH::ghash_update(), Botan::ChaCha::seek(), Botan::CTR_BE::seek(), Botan::Salsa20::seek(), Botan::OCB_Mode::set_associated_data_n(), Botan::Salsa20::set_iv_bytes(), Botan::GHASH::update(), and Botan::GHASH::update_associated_data().

◆ assert_key_material_set() [2/2]

void Botan::SymmetricAlgorithm::assert_key_material_set ( bool  predicate) const
inlineprotectedinherited

Definition at line 187 of file sym_algo.h.

188 {
189 if(!predicate)
190 throw_key_not_set_error();
191 }

◆ clear()

void Botan::ANSI_X919_MAC::clear ( )
overridevirtual

Reset the internal state. This includes not just the key, but any partial message that may have been in process.

Implements Botan::SymmetricAlgorithm.

Definition at line 77 of file x919_mac.cpp.

78 {
79 m_des1->clear();
80 m_des2->clear();
81 zap(m_state);
82 m_position = 0;
83 }
void zap(std::vector< T, Alloc > &vec)
Definition: secmem.h:129

References Botan::zap().

◆ clone()

MessageAuthenticationCode * Botan::MessageAuthenticationCode::clone ( ) const
inlineinherited

Get a new object representing the same algorithm as *this

Definition at line 120 of file mac.h.

121 {
122 return this->new_object().release();
123 }
virtual std::unique_ptr< MessageAuthenticationCode > new_object() const =0

◆ create()

std::unique_ptr< MessageAuthenticationCode > Botan::MessageAuthenticationCode::create ( std::string_view  algo_spec,
std::string_view  provider = "" 
)
staticinherited

Create an instance based on a name If provider is empty then best available is chosen.

Parameters
algo_specalgorithm name
providerprovider implementation to use
Returns
a null pointer if the algo/provider combination cannot be found

Definition at line 46 of file mac.cpp.

48 {
49 const SCAN_Name req(algo_spec);
50
51#if defined(BOTAN_HAS_BLAKE2BMAC)
52 if(req.algo_name() == "Blake2b" || req.algo_name() == "BLAKE2b")
53 {
54 return std::make_unique<BLAKE2bMAC>(req.arg_as_integer(0, 512));
55 }
56#endif
57
58#if defined(BOTAN_HAS_GMAC)
59 if(req.algo_name() == "GMAC" && req.arg_count() == 1)
60 {
61 if(provider.empty() || provider == "base")
62 {
63 if(auto bc = BlockCipher::create(req.arg(0)))
64 return std::make_unique<GMAC>(std::move(bc));
65 }
66 }
67#endif
68
69#if defined(BOTAN_HAS_HMAC)
70 if(req.algo_name() == "HMAC" && req.arg_count() == 1)
71 {
72 if(provider.empty() || provider == "base")
73 {
74 if(auto hash = HashFunction::create(req.arg(0)))
75 return std::make_unique<HMAC>(std::move(hash));
76 }
77 }
78#endif
79
80#if defined(BOTAN_HAS_POLY1305)
81 if(req.algo_name() == "Poly1305" && req.arg_count() == 0)
82 {
83 if(provider.empty() || provider == "base")
84 return std::make_unique<Poly1305>();
85 }
86#endif
87
88#if defined(BOTAN_HAS_SIPHASH)
89 if(req.algo_name() == "SipHash")
90 {
91 if(provider.empty() || provider == "base")
92 {
93 return std::make_unique<SipHash>(req.arg_as_integer(0, 2), req.arg_as_integer(1, 4));
94 }
95 }
96#endif
97
98#if defined(BOTAN_HAS_CMAC)
99 if((req.algo_name() == "CMAC" || req.algo_name() == "OMAC") && req.arg_count() == 1)
100 {
101 if(provider.empty() || provider == "base")
102 {
103 if(auto bc = BlockCipher::create(req.arg(0)))
104 return std::make_unique<CMAC>(std::move(bc));
105 }
106 }
107#endif
108
109
110#if defined(BOTAN_HAS_ANSI_X919_MAC)
111 if(req.algo_name() == "X9.19-MAC")
112 {
113 if(provider.empty() || provider == "base")
114 {
115 return std::make_unique<ANSI_X919_MAC>();
116 }
117 }
118#endif
119
120 BOTAN_UNUSED(req);
122
123 return nullptr;
124 }
#define BOTAN_UNUSED(...)
Definition: assert.h:141
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
Definition: hash.cpp:102
virtual std::string provider() const
Definition: mac.h:129

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), BOTAN_UNUSED, Botan::BlockCipher::create(), Botan::HashFunction::create(), and Botan::MessageAuthenticationCode::provider().

Referenced by botan_mac_init(), Botan::KDF::create(), Botan::PBKDF::create(), Botan::PasswordHashFamily::create(), and Botan::MessageAuthenticationCode::create_or_throw().

◆ create_or_throw()

std::unique_ptr< MessageAuthenticationCode > Botan::MessageAuthenticationCode::create_or_throw ( std::string_view  algo_spec,
std::string_view  provider = "" 
)
staticinherited

◆ final() [1/4]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::final ( )
inlineinherited

Complete the computation and retrieve the final result as a container of your choice.

Returns
a contiguous container holding the result

Definition at line 84 of file buf_comp.h.

85 {
86 T output(output_length());
87 final_result(output.data());
88 return output;
89 }
virtual size_t output_length() const =0
FE_25519 T
Definition: ge.cpp:36

References T.

◆ final() [2/4]

void Botan::Buffered_Computation::final ( std::span< uint8_t >  out)
inlineinherited

Definition at line 96 of file buf_comp.h.

97 {
98 BOTAN_ASSERT_NOMSG(out.size() >= output_length());
99 final_result(out.data());
100 }
#define BOTAN_ASSERT_NOMSG(expr)
Definition: assert.h:67

References BOTAN_ASSERT_NOMSG.

◆ final() [3/4]

template<concepts::resizable_byte_buffer T>
void Botan::Buffered_Computation::final ( T out)
inlineinherited

Definition at line 103 of file buf_comp.h.

104 {
105 out.resize(output_length());
106 final_result(out.data());
107 }

◆ final() [4/4]

void Botan::Buffered_Computation::final ( uint8_t  out[])
inlineinherited

Complete the computation and retrieve the final result.

Parameters
outThe byte array to be filled with the result. Must be of length output_length()

Definition at line 76 of file buf_comp.h.

76{ final_result(out); }

Referenced by Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::mgf1_mask(), Botan::pbkdf2(), Botan::Dilithium::Polynomial::poly_challenge(), Botan::Kyber_Modern_Symmetric_Primitives::PRF(), and Botan::sm2_compute_za().

◆ final_stdvec()

std::vector< uint8_t > Botan::Buffered_Computation::final_stdvec ( )
inlineinherited

Definition at line 91 of file buf_comp.h.

92 {
93 return final<std::vector<uint8_t>>();
94 }

◆ fresh_key_required_per_message()

virtual bool Botan::MessageAuthenticationCode::fresh_key_required_per_message ( ) const
inlinevirtualinherited
Returns
if a fresh key must be set for each message that is processed.

This is required for certain polynomial-based MACs which are insecure if a key is ever reused for two different messages.

Reimplemented in Botan::Poly1305.

Definition at line 137 of file mac.h.

137{ return false; }

◆ has_keying_material()

bool Botan::ANSI_X919_MAC::has_keying_material ( ) const
overridevirtual
Returns
true if a key has been set on this object

Implements Botan::SymmetricAlgorithm.

Definition at line 53 of file x919_mac.cpp.

54 {
55 return m_des1->has_keying_material() &&
56 m_des2->has_keying_material();
57 }

◆ key_spec()

Key_Length_Specification Botan::ANSI_X919_MAC::key_spec ( ) const
inlineoverridevirtual
Returns
object describing limits on key size

Implements Botan::SymmetricAlgorithm.

Definition at line 28 of file x919_mac.h.

29 {
30 return Key_Length_Specification(8, 16, 8);
31 }

◆ maximum_keylength()

size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const
inlineinherited
Returns
maximum allowed key length

Definition at line 123 of file sym_algo.h.

124 {
125 return key_spec().maximum_keylength();
126 }
size_t maximum_keylength() const
Definition: sym_algo.h:72
virtual Key_Length_Specification key_spec() const =0

◆ minimum_keylength()

size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const
inlineinherited
Returns
minimum allowed key length

Definition at line 131 of file sym_algo.h.

132 {
133 return key_spec().minimum_keylength();
134 }
size_t minimum_keylength() const
Definition: sym_algo.h:64

◆ name()

std::string Botan::ANSI_X919_MAC::name ( ) const
overridevirtual
Returns
the algorithm name

Implements Botan::SymmetricAlgorithm.

Definition at line 85 of file x919_mac.cpp.

86 {
87 return "X9.19-MAC";
88 }

◆ new_object()

std::unique_ptr< MessageAuthenticationCode > Botan::ANSI_X919_MAC::new_object ( ) const
overridevirtual
Returns
new object representing the same algorithm as *this

Implements Botan::MessageAuthenticationCode.

Definition at line 90 of file x919_mac.cpp.

91 {
92 return std::make_unique<ANSI_X919_MAC>();
93 }

◆ operator=()

ANSI_X919_MAC & Botan::ANSI_X919_MAC::operator= ( const ANSI_X919_MAC )
delete

◆ output_length()

size_t Botan::ANSI_X919_MAC::output_length ( ) const
inlineoverridevirtual
Returns
length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 24 of file x919_mac.h.

24{ return 8; }

◆ process() [1/3]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::process ( const uint8_t  in[],
size_t  length 
)
inlineinherited

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a byte array
lengththe length of the byte array
Returns
the result of the call to final()

Definition at line 117 of file buf_comp.h.

118 {
119 update(in, length);
120 return final<T>();
121 }
int(* update)(CTX *, const void *, CC_LONG len)

References update.

Referenced by Botan::Dilithium_Symmetric_Primitives::CRH(), and Botan::Dilithium_Symmetric_Primitives::H().

◆ process() [2/3]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::process ( std::span< const uint8_t >  in)
inlineinherited

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a contiguous container
Returns
the result of the call to final()

Definition at line 143 of file buf_comp.h.

144 {
145 update(in);
146 return final<T>();
147 }

References update.

◆ process() [3/3]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::process ( std::string_view  in)
inlineinherited

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a string
Returns
the result of the call to final()

Definition at line 130 of file buf_comp.h.

131 {
132 update(in);
133 return final<T>();
134 }

References update.

◆ provider()

virtual std::string Botan::MessageAuthenticationCode::provider ( ) const
inlinevirtualinherited
Returns
provider information about this implementation. Default is "base", might also return "sse2", "avx2", "openssl", or some other arbitrary string.

Definition at line 129 of file mac.h.

129{ return "base"; }

Referenced by Botan::MessageAuthenticationCode::create(), and Botan::MessageAuthenticationCode::create_or_throw().

◆ providers()

std::vector< std::string > Botan::MessageAuthenticationCode::providers ( std::string_view  algo_spec)
staticinherited
Returns
list of available providers for this algorithm, empty if not available

Definition at line 127 of file mac.cpp.

128 {
129 return probe_providers_of<MessageAuthenticationCode>(algo_spec);
130 }

◆ set_key() [1/3]

void Botan::SymmetricAlgorithm::set_key ( const SymmetricKey key)
inlineinherited

◆ set_key() [2/3]

void Botan::SymmetricAlgorithm::set_key ( const uint8_t  key[],
size_t  length 
)
inherited

Set the symmetric key of this object.

Parameters
keythe to be set as a byte array.
lengthin bytes of key param

Definition at line 17 of file sym_algo.cpp.

18 {
19 if(!valid_keylength(length))
20 throw Invalid_Key_Length(name(), length);
21 key_schedule(key, length);
22 }
bool valid_keylength(size_t length) const
Definition: sym_algo.h:141
virtual std::string name() const =0

References Botan::SymmetricAlgorithm::name(), and Botan::SymmetricAlgorithm::valid_keylength().

◆ set_key() [3/3]

void Botan::SymmetricAlgorithm::set_key ( std::span< const uint8_t >  key)
inlineinherited

Set the symmetric key of this object.

Parameters
keythe contiguous byte range to be set.

Definition at line 159 of file sym_algo.h.

160 {
161 set_key(key.data(), key.size());
162 }

◆ start() [1/3]

void Botan::MessageAuthenticationCode::start ( )
inlineinherited

Begin processing a message.

Definition at line 86 of file mac.h.

87 {
88 return start_msg(nullptr, 0);
89 }
virtual void start_msg(const uint8_t nonce[], size_t nonce_len)
Definition: mac.cpp:144

◆ start() [2/3]

void Botan::MessageAuthenticationCode::start ( const uint8_t  nonce[],
size_t  nonce_len 
)
inlineinherited

Begin processing a message.

Parameters
noncethe per message nonce
nonce_lenlength of nonce

Definition at line 78 of file mac.h.

79 {
80 start_msg(nonce, nonce_len);
81 }

◆ start() [3/3]

void Botan::MessageAuthenticationCode::start ( std::span< const uint8_t >  nonce)
inlineinherited

Prepare for processing a message under the specified nonce

Most MACs neither require nor support a nonce; for these algorithms calling start_msg is optional and calling it with anything other than an empty string is an error. One MAC which requires a per-message nonce be specified is GMAC.

Default implementation simply rejects all non-empty nonces since most hash/MAC algorithms do not support randomization

Parameters
noncethe message nonce bytes

Definition at line 68 of file mac.h.

69 {
70 start_msg(nonce.data(), nonce.size());
71 }

◆ start_msg()

void Botan::MessageAuthenticationCode::start_msg ( const uint8_t  nonce[],
size_t  nonce_len 
)
protectedvirtualinherited

Prepare for processing a message under the specified nonce

If the MAC does not support nonces, it should not override the default implementation.

Definition at line 144 of file mac.cpp.

145 {
146 BOTAN_UNUSED(nonce);
147 if(nonce_len > 0)
148 throw Invalid_IV_Length(name(), nonce_len);
149 }

References BOTAN_UNUSED, and Botan::SymmetricAlgorithm::name().

◆ update() [1/4]

void Botan::Buffered_Computation::update ( const uint8_t  in[],
size_t  length 
)
inlineinherited

Add new input to process.

Parameters
inthe input to process as a byte array
lengthof param in in bytes

Definition at line 35 of file buf_comp.h.

35{ add_data(in, length); }

Referenced by Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::mgf1_mask(), Botan::pbkdf2(), Botan::Dilithium::Polynomial::poly_challenge(), Botan::Kyber_Modern_Symmetric_Primitives::PRF(), and Botan::sm2_compute_za().

◆ update() [2/4]

void Botan::Buffered_Computation::update ( std::span< const uint8_t >  in)
inlineinherited

Add new input to process.

Parameters
inthe input to process as a contiguous data range

Definition at line 41 of file buf_comp.h.

42 {
43 add_data(in.data(), in.size());
44 }

◆ update() [3/4]

void Botan::Buffered_Computation::update ( std::string_view  str)
inlineinherited

Add new input to process.

Parameters
strthe input to process as a std::string_view. Will be interpreted as a byte array based on the strings encoding.

Definition at line 59 of file buf_comp.h.

60 {
61 add_data(cast_char_ptr_to_uint8(str.data()), str.size());
62 }
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:183

References Botan::cast_char_ptr_to_uint8().

◆ update() [4/4]

void Botan::Buffered_Computation::update ( uint8_t  in)
inlineinherited

Process a single byte.

Parameters
inthe byte to process

Definition at line 68 of file buf_comp.h.

68{ add_data(&in, 1); }

◆ update_be() [1/3]

void Botan::Buffered_Computation::update_be ( uint16_t  val)
inherited

Definition at line 12 of file buf_comp.cpp.

13 {
14 uint8_t inb[sizeof(val)];
15 store_be(val, inb);
16 add_data(inb, sizeof(inb));
17 }
constexpr void store_be(uint16_t in, uint8_t out[2])
Definition: loadstor.h:449

References Botan::store_be().

Referenced by Botan::mgf1_mask(), and Botan::pbkdf2().

◆ update_be() [2/3]

void Botan::Buffered_Computation::update_be ( uint32_t  val)
inherited

Definition at line 19 of file buf_comp.cpp.

20 {
21 uint8_t inb[sizeof(val)];
22 store_be(val, inb);
23 add_data(inb, sizeof(inb));
24 }

References Botan::store_be().

◆ update_be() [3/3]

void Botan::Buffered_Computation::update_be ( uint64_t  val)
inherited

Definition at line 26 of file buf_comp.cpp.

27 {
28 uint8_t inb[sizeof(val)];
29 store_be(val, inb);
30 add_data(inb, sizeof(inb));
31 }

References Botan::store_be().

◆ update_le() [1/3]

void Botan::Buffered_Computation::update_le ( uint16_t  val)
inherited

Definition at line 33 of file buf_comp.cpp.

34 {
35 uint8_t inb[sizeof(val)];
36 store_le(val, inb);
37 add_data(inb, sizeof(inb));
38 }
constexpr void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:465

References Botan::store_le().

◆ update_le() [2/3]

void Botan::Buffered_Computation::update_le ( uint32_t  val)
inherited

Definition at line 40 of file buf_comp.cpp.

41 {
42 uint8_t inb[sizeof(val)];
43 store_le(val, inb);
44 add_data(inb, sizeof(inb));
45 }

References Botan::store_le().

◆ update_le() [3/3]

void Botan::Buffered_Computation::update_le ( uint64_t  val)
inherited

Definition at line 47 of file buf_comp.cpp.

48 {
49 uint8_t inb[sizeof(val)];
50 store_le(val, inb);
51 add_data(inb, sizeof(inb));
52 }

References Botan::store_le().

◆ valid_keylength()

bool Botan::SymmetricAlgorithm::valid_keylength ( size_t  length) const
inlineinherited

Check whether a given key length is valid for this algorithm.

Parameters
lengththe key length to be checked.
Returns
true if the key length is valid.

Definition at line 141 of file sym_algo.h.

142 {
143 return key_spec().valid_keylength(length);
144 }
bool valid_keylength(size_t length) const
Definition: sym_algo.h:54

Referenced by Botan::SymmetricAlgorithm::set_key().

◆ verify_mac() [1/2]

bool Botan::MessageAuthenticationCode::verify_mac ( const uint8_t  in[],
size_t  length 
)
inlineinherited

Verify a MAC.

Parameters
inthe MAC to verify as a byte array
lengththe length of param in
Returns
true if the MAC is valid, false otherwise

Definition at line 97 of file mac.h.

98 {
99 return verify_mac_result(in, length);
100 }
virtual bool verify_mac_result(const uint8_t in[], size_t length)
Definition: mac.cpp:154

◆ verify_mac() [2/2]

bool Botan::MessageAuthenticationCode::verify_mac ( std::span< const uint8_t >  in)
inlineinherited

Verify a MAC.

Parameters
inthe MAC to verify as a byte array
Returns
true if the MAC is valid, false otherwise

Definition at line 107 of file mac.h.

108 {
109 return verify_mac_result(in.data(), in.size());
110 }

◆ verify_mac_result()

bool Botan::MessageAuthenticationCode::verify_mac_result ( const uint8_t  in[],
size_t  length 
)
protectedvirtualinherited

Verify the MACs final result

Definition at line 154 of file mac.cpp.

155 {
156 secure_vector<uint8_t> our_mac = final();
157
158 if(our_mac.size() != length)
159 return false;
160
161 return constant_time_compare(our_mac.data(), mac, length);
162 }
bool constant_time_compare(const uint8_t x[], const uint8_t y[], size_t len)
Definition: mem_ops.h:82

References Botan::constant_time_compare().


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