Botan
3.5.0
Crypto and TLS for C&
src
lib
pubkey
kyber
kyber_round3
kyber_90s
kyber_90s.h
Go to the documentation of this file.
1
/*
2
* Symmetric primitives for Kyber (90s mode)
3
* (C) 2022 Jack Lloyd
4
* (C) 2022 Hannes Rantzsch, René Meusel, neXenio GmbH
5
* (C) 2024 René Meusel, Rohde & Schwarz Cybersecurity
6
*
7
* Botan is released under the Simplified BSD License (see license.txt)
8
*/
9
10
#ifndef BOTAN_KYBER_90S_H_
11
#define BOTAN_KYBER_90S_H_
12
13
#include <botan/hash.h>
14
#include <botan/internal/aes_crystals_xof.h>
15
16
#include <botan/internal/kyber_symmetric_primitives.h>
17
18
#include <array>
19
#include <memory>
20
21
namespace
Botan
{
22
23
class
Kyber_90s_Symmetric_Primitives
:
public
Kyber_Symmetric_Primitives
{
24
public
:
25
Kyber_90s_Symmetric_Primitives
() :
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
>()) {}
29
30
protected
:
31
HashFunction
&
get_G
()
const override
{
return
*m_sha512; }
32
33
HashFunction
&
get_H
()
const override
{
return
*m_sha256; }
34
35
HashFunction
&
get_KDF
()
const override
{
return
*m_sha256; }
36
37
Botan::XOF
&
get_PRF
(std::span<const uint8_t> seed,
const
uint8_t nonce)
const override
{
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
}
43
44
std::unique_ptr<Botan::XOF>
get_XOF
(std::span<const uint8_t> seed,
45
std::tuple<uint8_t, uint8_t> mpos)
const override
{
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
}
51
52
private
:
53
std::unique_ptr<HashFunction> m_sha512;
54
std::unique_ptr<HashFunction> m_sha256;
55
std::unique_ptr<AES_256_CTR_XOF> m_aes256_xof;
56
};
57
58
}
// namespace Botan
59
60
#endif
Botan::AES_256_CTR_XOF
Definition
aes_crystals_xof.h:26
Botan::HashFunction
Definition
hash.h:21
Botan::Kyber_90s_Symmetric_Primitives
Definition
kyber_90s.h:23
Botan::Kyber_90s_Symmetric_Primitives::get_G
HashFunction & get_G() const override
Definition
kyber_90s.h:31
Botan::Kyber_90s_Symmetric_Primitives::get_KDF
HashFunction & get_KDF() const override
Definition
kyber_90s.h:35
Botan::Kyber_90s_Symmetric_Primitives::Kyber_90s_Symmetric_Primitives
Kyber_90s_Symmetric_Primitives()
Definition
kyber_90s.h:25
Botan::Kyber_90s_Symmetric_Primitives::get_H
HashFunction & get_H() const override
Definition
kyber_90s.h:33
Botan::Kyber_90s_Symmetric_Primitives::get_XOF
std::unique_ptr< Botan::XOF > get_XOF(std::span< const uint8_t > seed, std::tuple< uint8_t, uint8_t > mpos) const override
Definition
kyber_90s.h:44
Botan::Kyber_90s_Symmetric_Primitives::get_PRF
Botan::XOF & get_PRF(std::span< const uint8_t > seed, const uint8_t nonce) const override
Definition
kyber_90s.h:37
Botan::Kyber_Symmetric_Primitives
Definition
kyber_symmetric_primitives.h:32
Botan::XOF
Definition
xof.h:29
Botan
Definition
alg_id.cpp:13
Generated by
1.11.0