Botan 3.14.1
Crypto and TLS for C&
enc_padding.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_ENCRYPTION_PADDING_H_
8#define BOTAN_PUBKEY_ENCRYPTION_PADDING_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
20
21/**
22* Encoding Method for Encryption
23*/
24class BOTAN_TEST_API EncryptionPaddingScheme /* NOLINT(*-special-member-functions) */ {
25 public:
27
28 /**
29 * Factory method for encryption padding schemes
30 *
31 * @param options the padding scheme and its parameters
32 * @return pointer to newly allocated object of that type, or throws
33 */
34 static std::unique_ptr<EncryptionPaddingScheme> create_or_throw(const PK_Encryption_Options_Reader& options);
35
36 /**
37 * Return the maximum input size in bytes we can support
38 * @param keybits the size of the key in bits
39 * @return upper bound of input in bytes
40 */
41 virtual size_t maximum_input_size(size_t keybits) const = 0;
42
43 /**
44 * Encode an input
45 * @param output buffer that is written to
46 * @param input the plaintext
47 * @param key_length length of the key in bits
48 * @param rng a random number generator
49 * @return number of bytes written to output
50 */
51 virtual size_t pad(std::span<uint8_t> output,
52 std::span<const uint8_t> input,
53 size_t key_length,
54 RandomNumberGenerator& rng) const = 0;
55
56 /**
57 * Decode an input
58 * @param output buffer where output is placed
59 * @param input the encoded plaintext
60 * @return number of bytes written to output if valid,
61 * or an empty option if invalid. If an empty option is
62 * returned the contents of output are undefined
63 */
64 virtual CT::Option<size_t> unpad(std::span<uint8_t> output, std::span<const uint8_t> input) const = 0;
65};
66
67} // namespace Botan
68
69#endif
#define BOTAN_TEST_API
Definition api.h:41
virtual CT::Option< size_t > unpad(std::span< uint8_t > output, std::span< const uint8_t > input) const =0
virtual size_t pad(std::span< uint8_t > output, std::span< const uint8_t > input, size_t key_length, RandomNumberGenerator &rng) const =0
static std::unique_ptr< EncryptionPaddingScheme > create_or_throw(const PK_Encryption_Options_Reader &options)
virtual size_t maximum_input_size(size_t keybits) const =0