Botan
3.10.0
Crypto and TLS for C&
src
lib
pubkey
classic_mceliece
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
23
namespace
Botan
{
24
25
/**
26
* Classic McEliece Encapsulation Operation
27
*/
28
class
BOTAN_TEST_API
Classic_McEliece_Encryptor
final
:
public
PK_Ops::KEM_Encryption_with_KDF
{
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_
BOTAN_TEST_API
#define BOTAN_TEST_API
Definition
api.h:41
Botan::Classic_McEliece_Encryptor
Definition
cmce_encaps.h:28
Botan::Classic_McEliece_Encryptor::Classic_McEliece_Encryptor
Classic_McEliece_Encryptor(std::shared_ptr< Classic_McEliece_PublicKeyInternal > key, std::string_view kdf)
Definition
cmce_encaps.h:30
Botan::Classic_McEliece_Encryptor::encapsulated_key_length
size_t encapsulated_key_length() const override
Definition
cmce_encaps.h:35
Botan::Classic_McEliece_Encryptor::raw_kem_shared_key_length
size_t raw_kem_shared_key_length() const override
Definition
cmce_encaps.h:33
Botan::Classic_McEliece_Matrix
Representation of the binary Classic McEliece matrix H, with H = (I_mt | T).
Definition
cmce_matrix.h:26
Botan::Classic_McEliece_Parameters
Definition
cmce_parameters.h:29
Botan::PK_Ops::KEM_Encryption_with_KDF
Definition
pk_ops_impl.h:124
Botan::RandomNumberGenerator
Definition
rng.h:30
Botan::Strong
Definition
strong_type.h:198
final
int(* final)(unsigned char *, CTX *)
Definition
commoncrypto_hash.cpp:29
Botan
Definition
alg_id.cpp:13
Generated by
1.12.0