|
Botan 3.11.0
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 354 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 194 of file kyber_algos.cpp.
References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), and Botan::KyberConstants::k().
Referenced by Botan::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 364 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 48 of file kyber_algos.h.
References encode_polynomial_vector(), and Botan::KyberConstants::polynomial_vector_bytes().
| void Botan::Kyber_Algos::encode_polynomial_vector | ( | std::span< uint8_t > | out, |
| const KyberPolyVecNTT & | vec ) |
Definition at line 186 of file kyber_algos.cpp.
References BOTAN_ASSERT_NOMSG, and Botan::BufferStuffer::full().
Referenced by Botan::Kyber_PublicKey::check_key(), Botan::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 323 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::Seed_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 206 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 214 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 382 of file kyber_algos.cpp.
References BOTAN_ASSERT, Botan::KyberConstants::k(), Botan::KyberConstants::SEED_BYTES, Botan::StrongSpan< T >::size(), and Botan::KyberConstants::symmetric_primitives().
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 407 of file kyber_algos.cpp.
References Botan::KyberConstants::_2, Botan::KyberConstants::_3, and BOTAN_ASSERT_UNREACHABLE.