Coverage Report

Created: 2020-06-30 13:58

/src/botan/build/include/botan/eme.h
Line
Count
Source
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
14
BOTAN_FUTURE_INTERNAL_HEADER(eme.h)
15
16
namespace Botan {
17
18
class RandomNumberGenerator;
19
20
/**
21
* Encoding Method for Encryption
22
*/
23
class BOTAN_PUBLIC_API(2,0) EME
24
   {
25
   public:
26
64
      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
      */
55
      secure_vector<uint8_t> encode(const secure_vector<uint8_t>& in,
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
*/
90
BOTAN_PUBLIC_API(2,0) EME*  get_eme(const std::string& algo_spec);
91
92
}
93
94
#endif