Coverage Report

Created: 2021-11-25 09:31

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