Botan 3.6.1
Crypto and TLS for C&
eme.h
Go to the documentation of this file.
1/*
2* (C) 1999-2007,2024 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_PUBKEY_EME_H_
8#define BOTAN_PUBKEY_EME_H_
9
10#include <botan/types.h>
11#include <botan/internal/ct_utils.h>
12#include <memory>
13#include <span>
14#include <string_view>
15
16namespace Botan {
17
18class RandomNumberGenerator;
19
20/**
21* Encoding Method for Encryption
22*/
24 public:
25 virtual ~EME();
26
27 /**
28 * Factory method for EME (message-encoding methods for encryption) objects
29 * @param algo_spec the name of the EME to create
30 * @return pointer to newly allocated object of that type
31 */
32 static std::unique_ptr<EME> create(std::string_view algo_spec);
33
34 /**
35 * Return the maximum input size in bytes we can support
36 * @param keybits the size of the key in bits
37 * @return upper bound of input in bytes
38 */
39 virtual size_t maximum_input_size(size_t keybits) const = 0;
40
41 /**
42 * Encode an input
43 * @param output buffer that is written to
44 * @param input the plaintext
45 * @param key_length length of the key in bits
46 * @param rng a random number generator
47 * @return number of bytes written to output
48 */
49 virtual size_t pad(std::span<uint8_t> output,
50 std::span<const uint8_t> input,
51 size_t key_length,
52 RandomNumberGenerator& rng) const = 0;
53
54 /**
55 * Decode an input
56 * @param output buffer where output is placed
57 * @param input the encoded plaintext
58 * @return number of bytes written to output if valid,
59 * or an empty option if invalid. If an empty option is
60 * returned the contents of output are undefined
61 */
62 virtual CT::Option<size_t> unpad(std::span<uint8_t> output, std::span<const uint8_t> input) const = 0;
63};
64
65} // namespace Botan
66
67#endif
virtual CT::Option< size_t > unpad(std::span< uint8_t > output, std::span< const uint8_t > input) const =0
virtual size_t maximum_input_size(size_t keybits) const =0
virtual ~EME()
virtual size_t pad(std::span< uint8_t > output, std::span< const uint8_t > input, size_t key_length, RandomNumberGenerator &rng) const =0
#define BOTAN_TEST_API
Definition compiler.h:51