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);
52 std::pair<KyberSharedSecret, KyberEncryptionRandomness>
G(
54 return G_split<KyberSharedSecret, KyberEncryptionRandomness>(msg, pubkey_hash);
62 kdf.update(shared_secret);
63 kdf.update(hashed_ciphertext);
69 const size_t outlen)
const {
70 auto bare_seed_span = std::visit([&](
const auto s) {
return s.get(); }, seed);
75 std::tuple<uint8_t, uint8_t> matrix_position)
const {
80 return get_XOF(seed, matrix_position);
87 std::pair<T1, T2> G_split(InputTs&&... inputs)
const {
89 (g.update(inputs), ...);
93 std::pair<T1, T2> result;
105 virtual std::unique_ptr<Botan::XOF>
get_XOF(std::span<const uint8_t> seed,
106 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 kSeedLength
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
std::unique_ptr< Botan::XOF > XOF(StrongSpan< const KyberSeedRho > seed, std::tuple< uint8_t, uint8_t > matrix_position) 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
std::pair< KyberSeedRho, KyberSeedSigma > G(StrongSpan< const KyberSeedRandomness > seed) const
std::pair< KyberSharedSecret, KyberEncryptionRandomness > G(StrongSpan< const KyberMessage > msg, StrongSpan< const KyberHashedPublicKey > pubkey_hash) const
virtual HashFunction & get_H() const =0
virtual std::unique_ptr< Botan::XOF > get_XOF(std::span< const uint8_t > seed, std::tuple< uint8_t, uint8_t > matrix_position) const =0
virtual HashFunction & get_KDF() const =0
KyberHashedPublicKey H(StrongSpan< const KyberSerializedPublicKey > pk) const
std::variant< StrongSpan< const KyberSeedSigma >, StrongSpan< const KyberEncryptionRandomness > > KyberSigmaOrEncryptionRandomness