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