Botan 3.7.1
Crypto and TLS for C&
cmce_encaps.h
Go to the documentation of this file.
1/*
2* Classic McEliece Encapsulation
3* (C) 2023 Jack Lloyd
4* 2023,2024 Fabian Albert, Amos Treiber - Rohde & Schwarz Cybersecurity
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7**/
8
9#ifndef BOTAN_CMCE_ENCAPS_H_
10#define BOTAN_CMCE_ENCAPS_H_
11
12#include <botan/cmce.h>
13#include <botan/pk_keys.h>
14#include <botan/pk_ops.h>
15#include <botan/internal/cmce_field_ordering.h>
16#include <botan/internal/cmce_keys_internal.h>
17#include <botan/internal/cmce_matrix.h>
18#include <botan/internal/cmce_parameters.h>
19#include <botan/internal/cmce_poly.h>
20#include <botan/internal/cmce_types.h>
21#include <botan/internal/pk_ops_impl.h>
22
23namespace Botan {
24
25/**
26 * Classic McEliece Encapsulation Operation
27 */
29 public:
30 Classic_McEliece_Encryptor(std::shared_ptr<Classic_McEliece_PublicKeyInternal> key, std::string_view kdf) :
31 KEM_Encryption_with_KDF(kdf), m_key(std::move(key)) {}
32
33 size_t raw_kem_shared_key_length() const override { return m_key->params().hash_out_bytes(); }
34
35 size_t encapsulated_key_length() const override { return m_key->params().ciphertext_size(); }
36
37 void raw_kem_encrypt(std::span<uint8_t> out_encapsulated_key,
38 std::span<uint8_t> out_shared_key,
39 RandomNumberGenerator& rng) override;
40
41 private:
42 std::shared_ptr<Classic_McEliece_PublicKeyInternal> m_key;
43
44 /**
45 * @brief Encodes an error vector by multiplying it with the Classic McEliece matrix.
46 */
47 CmceCodeWord encode(const Classic_McEliece_Parameters& params,
48 const CmceErrorVector& e,
49 const Classic_McEliece_Matrix& mat) const;
50
51 /**
52 * @brief Fixed-weight-vector generation algorithm according to ISO McEliece.
53 */
54 std::optional<CmceErrorVector> fixed_weight_vector_gen(const Classic_McEliece_Parameters& params,
55 RandomNumberGenerator& rng) const;
56};
57
58} // namespace Botan
59
60#endif // BOTAN_CMCE_ENCAPS_H_
#define BOTAN_TEST_API
Definition api.h:39
Classic_McEliece_Encryptor(std::shared_ptr< Classic_McEliece_PublicKeyInternal > key, std::string_view kdf)
Definition cmce_encaps.h:30
size_t encapsulated_key_length() const override
Definition cmce_encaps.h:35
size_t raw_kem_shared_key_length() const override
Definition cmce_encaps.h:33
Representation of the binary Classic McEliece matrix H, with H = (I_mt | T).
Definition cmce_matrix.h:26
int(* final)(unsigned char *, CTX *)