14#ifndef BOTAN_KYBER_COMMON_H_
15#define BOTAN_KYBER_COMMON_H_
17#include <botan/asn1_obj.h>
18#include <botan/der_enc.h>
19#include <botan/exceptn.h>
20#include <botan/pk_keys.h>
24#if !defined(BOTAN_HAS_KYBER_90S) && !defined(BOTAN_HAS_KYBER)
25 static_assert(
false,
"botan module 'kyber_common' is useful only when enabling modules 'kyber', 'kyber_90s' or both");
47 OID object_identifier()
const;
48 std::string to_string()
const;
51 bool is_90s()
const {
return m_mode == Kyber512_90s || m_mode == Kyber768_90s || m_mode == Kyber1024_90s; }
61class Kyber_PublicKeyInternal;
62class Kyber_PrivateKeyInternal;
70 std::span<const uint8_t> key_bits);
78 std::string algo_name()
const override;
82 OID object_identifier()
const override;
84 size_t key_length()
const override;
86 size_t estimated_strength()
const override;
88 std::vector<uint8_t> public_key_bits()
const override;
94 return (op == PublicKeyOperation::KeyEncapsulation);
97 std::unique_ptr<PK_Ops::KEM_Encryption> create_kem_encryption_op(
98 std::string_view params,
99 std::string_view provider)
const override;
106 static std::shared_ptr<Kyber_PublicKeyInternal> initialize_from_encoding(std::span<const uint8_t> pub_key,
KyberMode m);
108 const std::vector<uint8_t>& public_key_bits_raw()
const;
109 const std::vector<uint8_t>& H_public_key_bits_raw()
const;
112 friend class Kyber_KEM_Encryptor;
113 friend class Kyber_KEM_Decryptor;
129 std::span<const uint8_t> key_bits);
131 std::unique_ptr<Public_Key> public_key()
const override;
138 std::string_view params,
139 std::string_view provider)
const override;
142 friend class Kyber_KEM_Decryptor;
144 std::shared_ptr<Kyber_PrivateKeyInternal> m_private;
bool operator==(const KyberMode &other) const
bool operator!=(const KyberMode &other) const
virtual ~Kyber_PublicKey()=default
Kyber_PublicKey & operator=(const Kyber_PublicKey &other)=default
std::shared_ptr< Kyber_PublicKeyInternal > m_public
bool supports_operation(PublicKeyOperation op) const override
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
#define BOTAN_DIAGNOSTIC_PUSH
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
#define BOTAN_PUBLIC_API(maj, min)
std::vector< T, secure_allocator< T > > secure_vector