Botan 3.14.1
Crypto and TLS for C&
oaep.h
Go to the documentation of this file.
1/*
2* OAEP
3* (C) 1999-2007,2018,2024 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_OAEP_H_
9#define BOTAN_OAEP_H_
10
11#include <botan/internal/enc_padding.h>
12
13#include <botan/hash.h>
14#include <botan/internal/ct_utils.h>
15
16namespace Botan {
17
19
20/**
21* OAEP (called EME1 in IEEE 1363 and in earlier versions of the library)
22* as specified in PKCS#1 v2.0 (RFC 2437) or PKCS#1 v2.1 (RFC 3447)
23*/
24class OAEP final : public EncryptionPaddingScheme {
25 public:
26 size_t maximum_input_size(size_t keybits) const override;
27
28 /**
29 * @param options must specify the hash; may specify a distinct MGF1 hash
30 * and a label (as the context)
31 */
32 explicit OAEP(const PK_Encryption_Options_Reader& options);
33
34 /**
35 * @param hash function to use for hashing (takes ownership)
36 * @param P an optional label. Normally empty.
37 */
38 explicit OAEP(std::unique_ptr<HashFunction> hash, std::string_view P = "");
39
40 /**
41 * @param hash function to use for hashing (takes ownership)
42 * @param mgf1_hash function to use for MGF1 (takes ownership)
43 * @param P an optional label. Normally empty.
44 */
45 OAEP(std::unique_ptr<HashFunction> hash, std::unique_ptr<HashFunction> mgf1_hash, std::string_view P = "");
46
47 private:
48 size_t pad(std::span<uint8_t> output,
49 std::span<const uint8_t> input,
50 size_t key_length,
51 RandomNumberGenerator& rng) const override;
52
53 CT::Option<size_t> unpad(std::span<uint8_t> output, std::span<const uint8_t> input) const override;
54
56 std::unique_ptr<HashFunction> m_mgf1_hash;
57};
58
59BOTAN_FUZZER_API CT::Option<size_t> oaep_find_delim(std::span<const uint8_t> input, std::span<const uint8_t> phash);
60
61} // namespace Botan
62
63#endif
#define BOTAN_FUZZER_API
Definition api.h:65
OAEP(const PK_Encryption_Options_Reader &options)
Definition oaep.cpp:150
size_t maximum_input_size(size_t keybits) const override
Definition oaep.cpp:142
CT::Option< size_t > oaep_find_delim(std::span< const uint8_t > input, std::span< const uint8_t > phash)
Definition oaep.cpp:103
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128