2
* (C) 2010,2015 Jack Lloyd
4
* Botan is released under the Simplified BSD License (see license.txt)
7
#ifndef BOTAN_PK_OPERATIONS_H_
8
#define BOTAN_PK_OPERATIONS_H_
11
* Ordinary applications should never need to include or use this
12
* header. It is exposed only for specialized applications which want
13
* to implement new versions of public key crypto without merging them
14
* as changes to the library. One actual example of such usage is an
15
* application which creates RSA signatures using a custom TPM library.
16
* Unless you're doing something like that, you don't need anything
17
* here. Instead use pubkey.h which wraps these types safely and
18
* provides a stable application-oriented API.
21
#include <botan/pk_keys.h>
22
#include <botan/secmem.h>
26
class RandomNumberGenerator;
34
* Public key encryption interface
36
class BOTAN_PUBLIC_API(2,0) Encryption
39
virtual secure_vector<uint8_t> encrypt(const uint8_t msg[],
41
RandomNumberGenerator& rng) = 0;
43
virtual size_t max_input_bits() const = 0;
45
virtual ~Encryption() = default;
49
* Public key decryption interface
51
class BOTAN_PUBLIC_API(2,0) Decryption
54
virtual secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
55
const uint8_t ciphertext[],
56
size_t ciphertext_len) = 0;
58
virtual ~Decryption() = default;
62
* Public key signature verification interface
64
class BOTAN_PUBLIC_API(2,0) Verification
68
* Add more data to the message currently being signed
69
* @param msg the message
70
* @param msg_len the length of msg in bytes
72
virtual void update(const uint8_t msg[], size_t msg_len) = 0;
75
* Perform a verification operation
76
* @param rng a random number generator
78
virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len) = 0;
80
virtual ~Verification() = default;
84
* Public key signature creation interface
86
class BOTAN_PUBLIC_API(2,0) Signature
90
* Add more data to the message currently being signed
91
* @param msg the message
92
* @param msg_len the length of msg in bytes
94
virtual void update(const uint8_t msg[], size_t msg_len) = 0;
97
* Perform a signature operation
98
* @param rng a random number generator
100
virtual secure_vector<uint8_t> sign(RandomNumberGenerator& rng) = 0;
102
virtual ~Signature() = default;
106
* A generic key agreement operation (eg DH or ECDH)
108
class BOTAN_PUBLIC_API(2,0) Key_Agreement
111
virtual secure_vector<uint8_t> agree(size_t key_len,
112
const uint8_t other_key[], size_t other_key_len,
113
const uint8_t salt[], size_t salt_len) = 0;
115
virtual ~Key_Agreement() = default;
119
* KEM (key encapsulation)
121
class BOTAN_PUBLIC_API(2,0) KEM_Encryption
124
virtual void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
125
secure_vector<uint8_t>& out_shared_key,
126
size_t desired_shared_key_len,
127
Botan::RandomNumberGenerator& rng,
128
const uint8_t salt[],
129
size_t salt_len) = 0;
131
virtual ~KEM_Encryption() = default;
134
class BOTAN_PUBLIC_API(2,0) KEM_Decryption
137
virtual secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
139
size_t desired_shared_key_len,
140
const uint8_t salt[],
141
size_t salt_len) = 0;
143
virtual ~KEM_Decryption() = default;