Botan 3.6.1
Crypto and TLS for C&
|
Classes | |
class | PolynomialSampler |
|
constexpr |
NIST FIPS 203, Formula 4.7 (Compress)
Definition at line 33 of file kyber_helpers.h.
References BOTAN_DEBUG_ASSERT, and Botan::KyberConstants::Q.
void Botan::Kyber_Algos::compress_ciphertext | ( | StrongSpan< KyberCompressedCiphertext > | out, |
const KyberPolyVec & | u, | ||
const KyberPoly & | v, | ||
const KyberConstants & | m_mode ) |
Definition at line 352 of file kyber_algos.cpp.
References BOTAN_ASSERT_NOMSG, Botan::BufferStuffer::full(), Botan::BufferStuffer::next(), Botan::KyberConstants::polynomial_compressed_bytes(), and Botan::KyberConstants::polynomial_vector_compressed_bytes().
Referenced by Botan::Kyber_PublicKeyInternal::indcpa_encrypt().
KyberPolyVecNTT Botan::Kyber_Algos::decode_polynomial_vector | ( | std::span< const uint8_t > | a, |
const KyberConstants & | mode ) |
Definition at line 192 of file kyber_algos.cpp.
References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), and Botan::KyberConstants::k().
Referenced by Botan::Kyber_Expanded_Keypair_Codec::decode_keypair().
|
constexpr |
NIST FIPS 203, Formula 4.8 (Decompress)
Definition at line 64 of file kyber_helpers.h.
References BOTAN_DEBUG_ASSERT, and Botan::KyberConstants::Q.
std::pair< KyberPolyVec, KyberPoly > Botan::Kyber_Algos::decompress_ciphertext | ( | StrongSpan< const KyberCompressedCiphertext > | ct, |
const KyberConstants & | mode ) |
Definition at line 362 of file kyber_algos.cpp.
References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), Botan::KyberConstants::polynomial_compressed_bytes(), Botan::KyberConstants::polynomial_vector_compressed_bytes(), Botan::StrongSpan< T >::size(), and Botan::BufferSlicer::take().
Referenced by Botan::Kyber_PrivateKeyInternal::indcpa_decrypt().
T Botan::Kyber_Algos::encode_polynomial_vector | ( | const KyberPolyVecNTT & | vec, |
const KyberConstants & | mode ) |
Definition at line 51 of file kyber_algos.h.
References encode_polynomial_vector(), Botan::KyberConstants::polynomial_vector_bytes(), and T.
void Botan::Kyber_Algos::encode_polynomial_vector | ( | std::span< uint8_t > | out, |
const KyberPolyVecNTT & | vec ) |
Definition at line 184 of file kyber_algos.cpp.
References BOTAN_ASSERT_NOMSG, and Botan::BufferStuffer::full().
Referenced by Botan::Kyber_PublicKey::check_key(), Botan::Kyber_Expanded_Keypair_Codec::encode_keypair(), and encode_polynomial_vector().
KyberInternalKeypair Botan::Kyber_Algos::expand_keypair | ( | KyberPrivateKeySeed | seed, |
KyberConstants | mode ) |
NIST FIPS 203, Algorithms 16 (ML-KEM.KeyGen_internal), and 13 (K-PKE.KeyGen)
In contrast to the specification, the expansion of rho and sigma is inlined with the actual PKE key generation. The sampling loops spelled out in FIPS 203 are hidden in the sample_* functions. The keys are kept in memory without serialization, which is deferred until requested.
Definition at line 321 of file kyber_algos.cpp.
References BOTAN_ARG_CHECK, Botan::KyberPrivateKeySeed::d, Botan::Kyber_Symmetric_Primitives::G(), Botan::CT::poison(), Botan::rho(), sample_matrix(), Botan::Kyber_Algos::PolynomialSampler< SeedT >::sample_polynomial_vector_cbd_eta1(), Botan::sigma(), Botan::KyberConstants::symmetric_primitives(), Botan::CT::unpoison(), and Botan::CT::unpoison_all().
Referenced by Botan::ML_KEM_Expanding_Keypair_Codec::decode_keypair(), and Botan::Kyber_PrivateKey::Kyber_PrivateKey().
|
inline |
Special load_le<> that takes 3 bytes and returns a 32-bit integer.
Definition at line 24 of file kyber_helpers.h.
References Botan::load_le().
KyberPoly Botan::Kyber_Algos::polynomial_from_message | ( | StrongSpan< const KyberMessage > | msg | ) |
Definition at line 204 of file kyber_algos.cpp.
References BOTAN_ASSERT, Botan::KyberConstants::N, and Botan::StrongSpan< T >::size().
Referenced by Botan::Kyber_PublicKeyInternal::indcpa_encrypt().
KyberMessage Botan::Kyber_Algos::polynomial_to_message | ( | const KyberPoly & | p | ) |
Definition at line 212 of file kyber_algos.cpp.
References Botan::CRYSTALS::Polynomial< Trait, D >::size().
Referenced by Botan::Kyber_PrivateKeyInternal::indcpa_decrypt().
Botan::Kyber_Algos::PolynomialSampler | ( | T | , |
const KyberConstants & | ) -> PolynomialSampler< T > |
KyberPolyMat Botan::Kyber_Algos::sample_matrix | ( | StrongSpan< const KyberSeedRho > | seed, |
bool | transposed, | ||
const KyberConstants & | mode ) |
Definition at line 380 of file kyber_algos.cpp.
References BOTAN_ASSERT, Botan::KyberConstants::k(), Botan::KyberConstants::SEED_BYTES, Botan::StrongSpan< T >::size(), Botan::KyberConstants::symmetric_primitives(), and Botan::Kyber_Symmetric_Primitives::XOF().
Referenced by expand_keypair().
void Botan::Kyber_Algos::sample_polynomial_from_cbd | ( | KyberPoly & | poly, |
KyberConstants::KyberEta | eta, | ||
const KyberSamplingRandomness & | randomness ) |
NIST FIPS 203, Algorithm 8 (SamplePolyCBD)
The actual implementation is above. This just dispatches to the correct specialization based on the eta of the chosen mode.
Definition at line 401 of file kyber_algos.cpp.
References Botan::KyberConstants::_2, Botan::KyberConstants::_3, and BOTAN_ASSERT_UNREACHABLE.