Botan 2.19.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
15
16namespace Botan {
17
18class RandomNumberGenerator;
19
20/**
21* Encoding Method for Encryption
22*/
24 {
25 public:
26 virtual ~EME() = default;
27
28 /**
29 * Return the maximum input size in bytes we can support
30 * @param keybits the size of the key in bits
31 * @return upper bound of input in bytes
32 */
33 virtual size_t maximum_input_size(size_t keybits) const = 0;
34
35 /**
36 * Encode an input
37 * @param in the plaintext
38 * @param in_length length of plaintext in bytes
39 * @param key_length length of the key in bits
40 * @param rng a random number generator
41 * @return encoded plaintext
42 */
43 secure_vector<uint8_t> encode(const uint8_t in[],
44 size_t in_length,
45 size_t key_length,
46 RandomNumberGenerator& rng) const;
47
48 /**
49 * Encode an input
50 * @param in the plaintext
51 * @param key_length length of the key in bits
52 * @param rng a random number generator
53 * @return encoded plaintext
54 */
56 size_t key_length,
57 RandomNumberGenerator& rng) const;
58
59 /**
60 * Decode an input
61 * @param valid_mask written to specifies if output is valid
62 * @param in the encoded plaintext
63 * @param in_len length of encoded plaintext in bytes
64 * @return bytes of out[] written to along with
65 * validity mask (0xFF if valid, else 0x00)
66 */
67 virtual secure_vector<uint8_t> unpad(uint8_t& valid_mask,
68 const uint8_t in[],
69 size_t in_len) const = 0;
70
71 /**
72 * Encode an input
73 * @param in the plaintext
74 * @param in_length length of plaintext in bytes
75 * @param key_length length of the key in bits
76 * @param rng a random number generator
77 * @return encoded plaintext
78 */
79 virtual secure_vector<uint8_t> pad(const uint8_t in[],
80 size_t in_length,
81 size_t key_length,
82 RandomNumberGenerator& rng) const = 0;
83 };
84
85/**
86* Factory method for EME (message-encoding methods for encryption) objects
87* @param algo_spec the name of the EME to create
88* @return pointer to newly allocated object of that type
89*/
90BOTAN_PUBLIC_API(2,0) EME* get_eme(const std::string& algo_spec);
91
92}
93
94#endif
Definition: eme.h:24
virtual ~EME()=default
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
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
Definition: alg_id.cpp:13
EME * get_eme(const std::string &algo_spec)
Definition: eme.cpp:27
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
Definition: bigint.h:1143