Botan 3.11.0
Crypto and TLS for C&
kyber_round3_impl.h
Go to the documentation of this file.
1/*
2 * Crystals Kyber key encapsulation mechanism and key codec
3 *
4 * (C) 2024 Jack Lloyd
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_R3_ENCAPSULATION_H_
11#define BOTAN_KYBER_R3_ENCAPSULATION_H_
12
13#include <botan/rng.h>
14
15#include <botan/internal/kyber_encaps_base.h>
16#include <botan/internal/kyber_keys.h>
17
18namespace Botan {
19
21 public:
22 Kyber_KEM_Encryptor(std::shared_ptr<const Kyber_PublicKeyInternal> key, std::string_view kdf) :
23 Kyber_KEM_Encryptor_Base(kdf, *key), m_public_key(std::move(key)) {}
24
25 protected:
26 void encapsulate(StrongSpan<KyberCompressedCiphertext> out_encapsulated_key,
27 StrongSpan<KyberSharedSecret> out_shared_key,
28 RandomNumberGenerator& rng) override;
29
30 private:
31 std::shared_ptr<const Kyber_PublicKeyInternal> m_public_key;
32};
33
35 public:
36 Kyber_KEM_Decryptor(std::shared_ptr<const Kyber_PrivateKeyInternal> private_key,
37 std::shared_ptr<const Kyber_PublicKeyInternal> public_key,
38 std::string_view kdf) :
39 Kyber_KEM_Decryptor_Base(kdf, *public_key),
40 m_public_key(std::move(public_key)),
41 m_private_key(std::move(private_key)) {}
42
43 protected:
45 StrongSpan<const KyberCompressedCiphertext> encapsulated_key) override;
46
47 private:
48 std::shared_ptr<const Kyber_PublicKeyInternal> m_public_key;
49 std::shared_ptr<const Kyber_PrivateKeyInternal> m_private_key;
50};
51
52} // namespace Botan
53
54#endif
Kyber_KEM_Decryptor_Base(std::string_view kdf, const Kyber_PublicKeyInternal &pk)
Kyber_KEM_Decryptor(std::shared_ptr< const Kyber_PrivateKeyInternal > private_key, std::shared_ptr< const Kyber_PublicKeyInternal > public_key, std::string_view kdf)
void decapsulate(StrongSpan< KyberSharedSecret > out_shared_key, StrongSpan< const KyberCompressedCiphertext > encapsulated_key) override
Kyber_KEM_Encryptor_Base(std::string_view kdf, const Kyber_PublicKeyInternal &pk)
Kyber_KEM_Encryptor(std::shared_ptr< const Kyber_PublicKeyInternal > key, std::string_view kdf)
void encapsulate(StrongSpan< KyberCompressedCiphertext > out_encapsulated_key, StrongSpan< KyberSharedSecret > out_shared_key, RandomNumberGenerator &rng) override