10#ifndef BOTAN_KYBER_SYMMETRIC_PRIMITIVES_H_
11#define BOTAN_KYBER_SYMMETRIC_PRIMITIVES_H_
13#include <botan/hash.h>
14#include <botan/secmem.h>
17#include <botan/internal/kyber_constants.h>
18#include <botan/internal/kyber_types.h>
19#include <botan/internal/stl_util.h>
49 return G_split<KyberSeedRho, KyberSeedSigma>(seed, *domsep);
51 return G_split<KyberSeedRho, KyberSeedSigma>(seed);
55 std::pair<KyberSharedSecret, KyberEncryptionRandomness>
G(
57 return G_split<KyberSharedSecret, KyberEncryptionRandomness>(msg, pubkey_hash);
63 j.update(rejection_value);
73 kdf.update(shared_secret);
74 kdf.update(hashed_ciphertext);
80 const size_t outlen)
const {
81 auto bare_seed_span = std::visit([&](
const auto s) {
return s.get(); }, seed);
86 return get_XOF(seed, matrix_position);
93 std::pair<T1, T2> G_split(InputTs&&... inputs)
const {
95 (g.update(inputs), ...);
99 std::pair<T1, T2> result;
116 std::tuple<uint8_t, uint8_t> matrix_position)
const = 0;
#define BOTAN_ASSERT_NOMSG(expr)
T process(const uint8_t in[], size_t length)
static constexpr size_t SEED_BYTES
virtual Botan::XOF & get_XOF(std::span< const uint8_t > seed, std::tuple< uint8_t, uint8_t > matrix_position) const =0
virtual ~Kyber_Symmetric_Primitives()=default
KyberMessage H(StrongSpan< const KyberMessage > m) const
virtual Botan::XOF & get_PRF(std::span< const uint8_t > seed, uint8_t nonce) const =0
KyberHashedCiphertext H(StrongSpan< const KyberCompressedCiphertext > r) const
virtual HashFunction & get_G() const =0
void KDF(StrongSpan< KyberSharedSecret > out, StrongSpan< const KyberSharedSecret > shared_secret, StrongSpan< const KyberHashedCiphertext > hashed_ciphertext) const
KyberSamplingRandomness PRF(KyberSigmaOrEncryptionRandomness seed, const uint8_t nonce, const size_t outlen) const
Botan::XOF & XOF(StrongSpan< const KyberSeedRho > seed, std::tuple< uint8_t, uint8_t > matrix_position) const
virtual HashFunction & get_J() const =0
std::pair< KyberSharedSecret, KyberEncryptionRandomness > G(StrongSpan< const KyberMessage > msg, StrongSpan< const KyberHashedPublicKey > pubkey_hash) const
KyberSharedSecret J(StrongSpan< const KyberImplicitRejectionValue > rejection_value, StrongSpan< const KyberCompressedCiphertext > ciphertext) const
virtual HashFunction & get_H() const =0
std::pair< KyberSeedRho, KyberSeedSigma > G(StrongSpan< const KyberSeedRandomness > seed, const KyberConstants &mode) const
virtual HashFunction & get_KDF() const =0
KyberHashedPublicKey H(StrongSpan< const KyberSerializedPublicKey > pk) const
virtual std::optional< std::array< uint8_t, 1 > > seed_expansion_domain_separator(const KyberConstants &mode) const =0
std::variant< StrongSpan< const KyberSeedSigma >, StrongSpan< const KyberEncryptionRandomness > > KyberSigmaOrEncryptionRandomness
Variant value of either a KyberSeedSigma or a KyberEncryptionRandomness.