Botan 2.19.5 Crypto and TLS for C&

pk_ops.h
Go to the documentation of this file.
1/*
2* (C) 2010,2015 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_PK_OPERATIONS_H_
8#define BOTAN_PK_OPERATIONS_H_
9
10/**
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.
19*/
20
21#include <botan/pk_keys.h>
22#include <botan/secmem.h>
23
24 namespace Botan {
25
26 class RandomNumberGenerator;
27 class EME;
28 class KDF;
29 class EMSA;
30
31 namespace PK_Ops {
32
33/**
34* Public key encryption interface
35*/
36 class BOTAN_PUBLIC_API(2,0) Encryption
37 {
38 public:
39 virtual secure_vector<uint8_t> encrypt(const uint8_t msg[],
40 size_t msg_len,
41 RandomNumberGenerator& rng) = 0;
42
43 virtual size_t max_input_bits() const = 0;
44
45 virtual size_t ciphertext_length(size_t ptext_len) const = 0;
46
47 virtual ~Encryption() {}
48 };
49
50/**
51* Public key decryption interface
52*/
53 class BOTAN_PUBLIC_API(2,0) Decryption
54 {
55 public:
56 virtual secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
57 const uint8_t ciphertext[],
58 size_t ciphertext_len) = 0;
59
60 virtual size_t plaintext_length(size_t ctext_len) const = 0;
61
62 virtual ~Decryption() {}
63 };
64
65/**
66* Public key signature verification interface
67*/
68 class BOTAN_PUBLIC_API(2,0) Verification
69 {
70 public:
71 /*
72 * Add more data to the message currently being signed
73 * @param msg the message
74 * @param msg_len the length of msg in bytes
75 */
76 virtual void update(const uint8_t msg[], size_t msg_len) = 0;
77
78 /*
79 * Perform a verification operation
80 * @param rng a random number generator
81 */
82 virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len) = 0;
83
84 virtual ~Verification() {}
85 };
86
87/**
88* Public key signature creation interface
89*/
90 class BOTAN_PUBLIC_API(2,0) Signature
91 {
92 public:
93 /*
94 * Add more data to the message currently being signed
95 * @param msg the message
96 * @param msg_len the length of msg in bytes
97 */
98 virtual void update(const uint8_t msg[], size_t msg_len) = 0;
99
100 /*
101 * Perform a signature operation
102 * @param rng a random number generator
103 */
104 virtual secure_vector<uint8_t> sign(RandomNumberGenerator& rng) = 0;
105
106 /*
107 * Return an upper bound on the length of the output signature
108 */
109 virtual size_t signature_length() const = 0;
110
111 virtual ~Signature() {}
112 };
113
114/**
115* A generic key agreement operation (eg DH or ECDH)
116*/
117 class BOTAN_PUBLIC_API(2,0) Key_Agreement
118 {
119 public:
120 virtual secure_vector<uint8_t> agree(size_t key_len,
121 const uint8_t other_key[], size_t other_key_len,
122 const uint8_t salt[], size_t salt_len) = 0;
123
124 virtual size_t agreed_value_size() const = 0;
125
126 virtual ~Key_Agreement() {}
127 };
128
129/**
130* KEM (key encapsulation)
131*/
132 class BOTAN_PUBLIC_API(2,0) KEM_Encryption
133 {
134 public:
135 virtual void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
136 secure_vector<uint8_t>& out_shared_key,
137 size_t desired_shared_key_len,
138 Botan::RandomNumberGenerator& rng,
139 const uint8_t salt[],
140 size_t salt_len) = 0;
141
142 virtual ~KEM_Encryption() {}
143 };
144
145 class BOTAN_PUBLIC_API(2,0) KEM_Decryption
146 {
147 public:
148 virtual secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
149 size_t len,
150 size_t desired_shared_key_len,
151 const uint8_t salt[],
152 size_t salt_len) = 0;
153
154 virtual ~KEM_Decryption() {}
155 };
156
157}
158
159}
160
161#endif
Botan::PK_Ops::Decryption
Definition: pk_ops.h:54
Botan::PK_Ops::Decryption::decrypt
virtual secure_vector< uint8_t > decrypt(uint8_t &valid_mask, const uint8_t ciphertext[], size_t ciphertext_len)=0
Botan::PK_Ops::Decryption::plaintext_length
virtual size_t plaintext_length(size_t ctext_len) const =0
Botan::PK_Ops::Decryption::~Decryption
virtual ~Decryption()
Definition: pk_ops.h:62
Botan::PK_Ops::Encryption
Definition: pk_ops.h:37
Botan::PK_Ops::Encryption::ciphertext_length
virtual size_t ciphertext_length(size_t ptext_len) const =0
Botan::PK_Ops::Encryption::~Encryption
virtual ~Encryption()
Definition: pk_ops.h:47
Botan::PK_Ops::Encryption::encrypt
virtual secure_vector< uint8_t > encrypt(const uint8_t msg[], size_t msg_len, RandomNumberGenerator &rng)=0
Botan::PK_Ops::Encryption::max_input_bits
virtual size_t max_input_bits() const =0
Botan::PK_Ops::KEM_Decryption
Definition: pk_ops.h:146
Botan::PK_Ops::KEM_Decryption::kem_decrypt
virtual secure_vector< uint8_t > kem_decrypt(const uint8_t encap_key[], size_t len, size_t desired_shared_key_len, const uint8_t salt[], size_t salt_len)=0
Botan::PK_Ops::KEM_Decryption::~KEM_Decryption
virtual ~KEM_Decryption()
Definition: pk_ops.h:154
Botan::PK_Ops::KEM_Encryption
Definition: pk_ops.h:133
Botan::PK_Ops::KEM_Encryption::~KEM_Encryption
virtual ~KEM_Encryption()
Definition: pk_ops.h:142
Botan::PK_Ops::KEM_Encryption::kem_encrypt
virtual void kem_encrypt(secure_vector< uint8_t > &out_encapsulated_key, secure_vector< uint8_t > &out_shared_key, size_t desired_shared_key_len, Botan::RandomNumberGenerator &rng, const uint8_t salt[], size_t salt_len)=0
Botan::PK_Ops::Key_Agreement
Definition: pk_ops.h:118
Botan::PK_Ops::Key_Agreement::agree
virtual secure_vector< uint8_t > agree(size_t key_len, const uint8_t other_key[], size_t other_key_len, const uint8_t salt[], size_t salt_len)=0
Botan::PK_Ops::Key_Agreement::~Key_Agreement
virtual ~Key_Agreement()
Definition: pk_ops.h:126
Botan::PK_Ops::Key_Agreement::agreed_value_size
virtual size_t agreed_value_size() const =0
Botan::PK_Ops::Signature
Definition: pk_ops.h:91
Botan::PK_Ops::Signature::~Signature
virtual ~Signature()
Definition: pk_ops.h:111
Botan::PK_Ops::Signature::signature_length
virtual size_t signature_length() const =0
Botan::PK_Ops::Signature::sign
virtual secure_vector< uint8_t > sign(RandomNumberGenerator &rng)=0
Botan::PK_Ops::Signature::update
virtual void update(const uint8_t msg[], size_t msg_len)=0
Botan::PK_Ops::Verification
Definition: pk_ops.h:69
Botan::PK_Ops::Verification::update
virtual void update(const uint8_t msg[], size_t msg_len)=0
Botan::PK_Ops::Verification::is_valid_signature
virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len)=0
Botan::PK_Ops::Verification::~Verification
virtual ~Verification()
Definition: pk_ops.h:84
Botan::RandomNumberGenerator
Definition: rng.h:26
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
salt_len
size_t salt_len
Definition: x509_obj.cpp:25