Botan 3.4.0
Crypto and TLS for C&
eme.h
Go to the documentation of this file.
1/*
2* EME Classes
3* (C) 1999-2007 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H_
9#define BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H_
10
11#include <botan/secmem.h>
12#include <string>
13
14namespace Botan {
15
16class RandomNumberGenerator;
17
18/**
19* Encoding Method for Encryption
20*/
21class EME {
22 public:
23 virtual ~EME() = default;
24
25 /**
26 * Factory method for EME (message-encoding methods for encryption) objects
27 * @param algo_spec the name of the EME to create
28 * @return pointer to newly allocated object of that type
29 */
30 static std::unique_ptr<EME> create(std::string_view algo_spec);
31
32 /**
33 * Return the maximum input size in bytes we can support
34 * @param keybits the size of the key in bits
35 * @return upper bound of input in bytes
36 */
37 virtual size_t maximum_input_size(size_t keybits) const = 0;
38
39 /**
40 * Encode an input
41 * @param in the plaintext
42 * @param in_length length of plaintext in bytes
43 * @param key_length length of the key in bits
44 * @param rng a random number generator
45 * @return encoded plaintext
46 */
47 secure_vector<uint8_t> encode(const uint8_t in[],
48 size_t in_length,
49 size_t key_length,
50 RandomNumberGenerator& rng) const;
51
52 /**
53 * Encode an input
54 * @param in the plaintext
55 * @param key_length length of the key in bits
56 * @param rng a random number generator
57 * @return encoded plaintext
58 */
60 size_t key_length,
61 RandomNumberGenerator& rng) const;
62
63 /**
64 * Decode an input
65 * @param valid_mask written to specifies if output is valid
66 * @param in the encoded plaintext
67 * @param in_len length of encoded plaintext in bytes
68 * @return bytes of out[] written to along with
69 * validity mask (0xFF if valid, else 0x00)
70 */
71 virtual secure_vector<uint8_t> unpad(uint8_t& valid_mask, const uint8_t in[], size_t in_len) const = 0;
72
73 /**
74 * Encode an input
75 * @param in the plaintext
76 * @param in_length length of plaintext in bytes
77 * @param key_length length of the key in bits
78 * @param rng a random number generator
79 * @return encoded plaintext
80 */
81 virtual secure_vector<uint8_t> pad(const uint8_t in[],
82 size_t in_length,
83 size_t key_length,
84 RandomNumberGenerator& rng) const = 0;
85};
86
87} // namespace Botan
88
89#endif
virtual ~EME()=default
secure_vector< uint8_t > encode(const uint8_t in[], size_t in_length, size_t key_length, RandomNumberGenerator &rng) const
Definition eme.cpp:70
virtual size_t maximum_input_size(size_t keybits) const =0
virtual secure_vector< uint8_t > unpad(uint8_t &valid_mask, const uint8_t in[], size_t in_len) const =0
virtual secure_vector< uint8_t > pad(const uint8_t in[], size_t in_length, size_t key_length, RandomNumberGenerator &rng) const =0
static std::unique_ptr< EME > create(std::string_view algo_spec)
Definition eme.cpp:28
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61