Botan 3.13.0
Crypto and TLS for C&
Botan::McEliece_PublicKeyInternal Class Referencefinal

#include <mce_internal.h>

Public Member Functions

size_t code_length () const
 McEliece_PublicKeyInternal (std::vector< uint8_t > public_matrix, size_t t, size_t code_length)
size_t message_word_bit_length () const
const std::vector< uint8_t > & public_matrix () const
secure_vector< uint8_t > random_plaintext_element (RandomNumberGenerator &rng) const
size_t t () const

Detailed Description

Definition at line 34 of file mce_internal.h.

Constructor & Destructor Documentation

◆ McEliece_PublicKeyInternal()

Botan::McEliece_PublicKeyInternal::McEliece_PublicKeyInternal ( std::vector< uint8_t > public_matrix,
size_t t,
size_t code_length )
inline

Definition at line 36 of file mce_internal.h.

36 :
37 m_public_matrix(std::move(public_matrix)), m_t(t), m_code_length(code_length) {}
const std::vector< uint8_t > & public_matrix() const

References code_length(), public_matrix(), and t().

Member Function Documentation

◆ code_length()

size_t Botan::McEliece_PublicKeyInternal::code_length ( ) const
inline

Definition at line 43 of file mce_internal.h.

43{ return m_code_length; }

Referenced by Botan::mceliece_encrypt(), and McEliece_PublicKeyInternal().

◆ message_word_bit_length()

size_t Botan::McEliece_PublicKeyInternal::message_word_bit_length ( ) const

Definition at line 253 of file mceliece_key.cpp.

253 {
254 const size_t codimension = ceil_log2(m_code_length) * m_t;
255 return m_code_length - codimension;
256}
constexpr uint8_t ceil_log2(T x)
Definition bit_ops.h:140

References Botan::ceil_log2().

Referenced by random_plaintext_element().

◆ public_matrix()

const std::vector< uint8_t > & Botan::McEliece_PublicKeyInternal::public_matrix ( ) const
inline

Definition at line 39 of file mce_internal.h.

39{ return m_public_matrix; }

Referenced by Botan::mceliece_encrypt(), and McEliece_PublicKeyInternal().

◆ random_plaintext_element()

secure_vector< uint8_t > Botan::McEliece_PublicKeyInternal::random_plaintext_element ( RandomNumberGenerator & rng) const

Definition at line 258 of file mceliece_key.cpp.

258 {
259 const size_t bits = message_word_bit_length();
260
261 secure_vector<uint8_t> plaintext((bits + 7) / 8);
262 rng.randomize(plaintext.data(), plaintext.size());
263
264 // unset unused bits in the last plaintext byte
265 if(const uint32_t used = bits % 8) {
266 const uint8_t mask = (1 << used) - 1;
267 plaintext[plaintext.size() - 1] &= mask;
268 }
269
270 return plaintext;
271}
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128

References message_word_bit_length(), and Botan::RandomNumberGenerator::randomize().

◆ t()

size_t Botan::McEliece_PublicKeyInternal::t ( ) const
inline

Definition at line 41 of file mce_internal.h.

41{ return m_t; }

Referenced by Botan::mceliece_encrypt(), and McEliece_PublicKeyInternal().


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