Botan 3.5.0
Crypto and TLS for C&
Botan::Kyber_90s_Symmetric_Primitives Class Reference

#include <kyber_90s.h>

Inheritance diagram for Botan::Kyber_90s_Symmetric_Primitives:
Botan::Kyber_Symmetric_Primitives

Public Member Functions

std::pair< KyberSharedSecret, KyberEncryptionRandomnessG (StrongSpan< const KyberMessage > msg, StrongSpan< const KyberHashedPublicKey > pubkey_hash) const
 
std::pair< KyberSeedRho, KyberSeedSigmaG (StrongSpan< const KyberSeedRandomness > seed) const
 
KyberHashedCiphertext H (StrongSpan< const KyberCompressedCiphertext > r) const
 
KyberMessage H (StrongSpan< const KyberMessage > m) const
 
KyberHashedPublicKey H (StrongSpan< const KyberSerializedPublicKey > pk) const
 
void KDF (StrongSpan< KyberSharedSecret > out, StrongSpan< const KyberSharedSecret > shared_secret, StrongSpan< const KyberHashedCiphertext > hashed_ciphertext) const
 
 Kyber_90s_Symmetric_Primitives ()
 
KyberSamplingRandomness PRF (KyberSigmaOrEncryptionRandomness seed, const uint8_t nonce, const size_t outlen) const
 
std::unique_ptr< Botan::XOFXOF (StrongSpan< const KyberSeedRho > seed, std::tuple< uint8_t, uint8_t > matrix_position) const
 

Protected Member Functions

HashFunctionget_G () const override
 
HashFunctionget_H () const override
 
HashFunctionget_KDF () const override
 
Botan::XOFget_PRF (std::span< const uint8_t > seed, const uint8_t nonce) const override
 
std::unique_ptr< Botan::XOFget_XOF (std::span< const uint8_t > seed, std::tuple< uint8_t, uint8_t > mpos) const override
 

Detailed Description

Definition at line 23 of file kyber_90s.h.

Constructor & Destructor Documentation

◆ Kyber_90s_Symmetric_Primitives()

Botan::Kyber_90s_Symmetric_Primitives::Kyber_90s_Symmetric_Primitives ( )
inline

Definition at line 25 of file kyber_90s.h.

25 :
26 m_sha512(HashFunction::create_or_throw("SHA-512")),
27 m_sha256(HashFunction::create_or_throw("SHA-256")),
28 m_aes256_xof(std::make_unique<AES_256_CTR_XOF>()) {}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:298

Member Function Documentation

◆ G() [1/2]

std::pair< KyberSharedSecret, KyberEncryptionRandomness > Botan::Kyber_Symmetric_Primitives::G ( StrongSpan< const KyberMessage > msg,
StrongSpan< const KyberHashedPublicKey > pubkey_hash ) const
inlineinherited

Definition at line 52 of file kyber_symmetric_primitives.h.

53 {
54 return G_split<KyberSharedSecret, KyberEncryptionRandomness>(msg, pubkey_hash);
55 }

◆ G() [2/2]

std::pair< KyberSeedRho, KyberSeedSigma > Botan::Kyber_Symmetric_Primitives::G ( StrongSpan< const KyberSeedRandomness > seed) const
inlineinherited

Definition at line 48 of file kyber_symmetric_primitives.h.

48 {
49 return G_split<KyberSeedRho, KyberSeedSigma>(seed);
50 }

◆ get_G()

HashFunction & Botan::Kyber_90s_Symmetric_Primitives::get_G ( ) const
inlineoverrideprotectedvirtual

Implements Botan::Kyber_Symmetric_Primitives.

Definition at line 31 of file kyber_90s.h.

31{ return *m_sha512; }

◆ get_H()

HashFunction & Botan::Kyber_90s_Symmetric_Primitives::get_H ( ) const
inlineoverrideprotectedvirtual

Implements Botan::Kyber_Symmetric_Primitives.

Definition at line 33 of file kyber_90s.h.

33{ return *m_sha256; }

◆ get_KDF()

HashFunction & Botan::Kyber_90s_Symmetric_Primitives::get_KDF ( ) const
inlineoverrideprotectedvirtual

Implements Botan::Kyber_Symmetric_Primitives.

Definition at line 35 of file kyber_90s.h.

35{ return *m_sha256; }

◆ get_PRF()

Botan::XOF & Botan::Kyber_90s_Symmetric_Primitives::get_PRF ( std::span< const uint8_t > seed,
const uint8_t nonce ) const
inlineoverrideprotectedvirtual

Implements Botan::Kyber_Symmetric_Primitives.

Definition at line 37 of file kyber_90s.h.

37 {
38 m_aes256_xof->clear();
39 const std::array<uint8_t, 12> nonce_buffer{nonce, 0};
40 m_aes256_xof->start(nonce_buffer, seed);
41 return *m_aes256_xof;
42 }

◆ get_XOF()

std::unique_ptr< Botan::XOF > Botan::Kyber_90s_Symmetric_Primitives::get_XOF ( std::span< const uint8_t > seed,
std::tuple< uint8_t, uint8_t > mpos ) const
inlineoverrideprotectedvirtual

Implements Botan::Kyber_Symmetric_Primitives.

Definition at line 44 of file kyber_90s.h.

45 {
46 auto xof = m_aes256_xof->new_object();
47 const std::array<uint8_t, 12> iv{std::get<0>(mpos), std::get<1>(mpos), 0};
48 xof->start(iv, seed);
49 return xof;
50 }

◆ H() [1/3]

KyberHashedCiphertext Botan::Kyber_Symmetric_Primitives::H ( StrongSpan< const KyberCompressedCiphertext > r) const
inlineinherited

Definition at line 40 of file kyber_symmetric_primitives.h.

40 {
42 }
T process(const uint8_t in[], size_t length)
Definition buf_comp.h:105
virtual HashFunction & get_H() const =0
Strong< std::vector< uint8_t >, struct KyberHashedCiphertext_ > KyberHashedCiphertext
Definition kyber_types.h:58

References Botan::Kyber_Symmetric_Primitives::get_H(), and Botan::Buffered_Computation::process().

◆ H() [2/3]

KyberMessage Botan::Kyber_Symmetric_Primitives::H ( StrongSpan< const KyberMessage > m) const
inlineinherited

Definition at line 37 of file kyber_symmetric_primitives.h.

37{ return get_H().process<KyberMessage>(m); }
Strong< secure_vector< uint8_t >, struct KyberMessage_ > KyberMessage
Random message value to be encrypted by the CPA-secure Kyber encryption scheme.
Definition kyber_types.h:36

References Botan::Kyber_Symmetric_Primitives::get_H(), and Botan::Buffered_Computation::process().

◆ H() [3/3]

KyberHashedPublicKey Botan::Kyber_Symmetric_Primitives::H ( StrongSpan< const KyberSerializedPublicKey > pk) const
inlineinherited

Definition at line 44 of file kyber_symmetric_primitives.h.

44 {
46 }
Strong< std::vector< uint8_t >, struct KyberHashedPublicKey_ > KyberHashedPublicKey
Definition kyber_types.h:51

References Botan::Kyber_Symmetric_Primitives::get_H(), and Botan::Buffered_Computation::process().

◆ KDF()

void Botan::Kyber_Symmetric_Primitives::KDF ( StrongSpan< KyberSharedSecret > out,
StrongSpan< const KyberSharedSecret > shared_secret,
StrongSpan< const KyberHashedCiphertext > hashed_ciphertext ) const
inlineinherited

Definition at line 58 of file kyber_symmetric_primitives.h.

60 {
61 auto& kdf = get_KDF();
62 kdf.update(shared_secret);
63 kdf.update(hashed_ciphertext);
64 kdf.final(out);
65 }
virtual HashFunction & get_KDF() const =0

References Botan::Kyber_Symmetric_Primitives::get_KDF().

◆ PRF()

KyberSamplingRandomness Botan::Kyber_Symmetric_Primitives::PRF ( KyberSigmaOrEncryptionRandomness seed,
const uint8_t nonce,
const size_t outlen ) const
inlineinherited

Definition at line 67 of file kyber_symmetric_primitives.h.

69 {
70 auto bare_seed_span = std::visit([&](const auto s) { return s.get(); }, seed);
71 return get_PRF(bare_seed_span, nonce).output<KyberSamplingRandomness>(outlen);
72 }
virtual Botan::XOF & get_PRF(std::span< const uint8_t > seed, uint8_t nonce) const =0
T output(size_t bytes)
Definition xof.h:155
Strong< secure_vector< uint8_t >, struct KyberSamplingRandomness_ > KyberSamplingRandomness
PRF value used for sampling of error polynomials.
Definition kyber_types.h:42

References Botan::Kyber_Symmetric_Primitives::get_PRF(), and Botan::XOF::output().

Referenced by Botan::Polynomial::getnoise_eta1(), and Botan::Polynomial::getnoise_eta2().

◆ XOF()

std::unique_ptr< Botan::XOF > Botan::Kyber_Symmetric_Primitives::XOF ( StrongSpan< const KyberSeedRho > seed,
std::tuple< uint8_t, uint8_t > matrix_position ) const
inlineinherited

Definition at line 74 of file kyber_symmetric_primitives.h.

75 {
76 // TODO: once we remove Kyber 90s, we should make `get_XOF()` return a
77 // reference instead of a unique pointer (for consistency), and
78 // call `get_XOF().copy_state()` here. The AES-CTR XOF doesn't
79 // support this.
80 return get_XOF(seed, matrix_position);
81 }
virtual std::unique_ptr< Botan::XOF > get_XOF(std::span< const uint8_t > seed, std::tuple< uint8_t, uint8_t > matrix_position) const =0

References Botan::Kyber_Symmetric_Primitives::get_XOF().

Referenced by Botan::PolynomialMatrix::generate().


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