1
/*************************************************
2
* Public Key Interface Header File *
3
* (C) 1999-2007 The Botan Project *
4
*************************************************/
6
#ifndef BOTAN_PUBKEY_H__
7
#define BOTAN_PUBKEY_H__
9
#include <botan/base.h>
10
#include <botan/pk_keys.h>
11
#include <botan/pk_util.h>
15
/*************************************************
16
* Public Key Encryptor *
17
*************************************************/
21
SecureVector<byte> encrypt(const byte[], u32bit) const;
22
SecureVector<byte> encrypt(const MemoryRegion<byte>&) const;
23
virtual u32bit maximum_input_size() const = 0;
24
virtual ~PK_Encryptor() {}
26
virtual SecureVector<byte> enc(const byte[], u32bit) const = 0;
29
/*************************************************
30
* Public Key Decryptor *
31
*************************************************/
35
SecureVector<byte> decrypt(const byte[], u32bit) const;
36
SecureVector<byte> decrypt(const MemoryRegion<byte>&) const;
37
virtual ~PK_Decryptor() {}
39
virtual SecureVector<byte> dec(const byte[], u32bit) const = 0;
42
/*************************************************
44
*************************************************/
48
SecureVector<byte> sign_message(const byte[], u32bit);
49
SecureVector<byte> sign_message(const MemoryRegion<byte>&);
52
void update(const byte[], u32bit);
53
void update(const MemoryRegion<byte>&);
55
SecureVector<byte> signature();
57
void set_output_format(Signature_Format);
59
PK_Signer(const PK_Signing_Key&, const std::string&);
60
~PK_Signer() { delete emsa; }
62
const PK_Signing_Key& key;
63
Signature_Format sig_format;
67
/*************************************************
68
* Public Key Verifier *
69
*************************************************/
73
bool verify_message(const byte[], u32bit, const byte[], u32bit);
74
bool verify_message(const MemoryRegion<byte>&,
75
const MemoryRegion<byte>&);
78
void update(const byte[], u32bit);
79
void update(const MemoryRegion<byte>&);
81
bool check_signature(const byte[], u32bit);
82
bool check_signature(const MemoryRegion<byte>&);
84
void set_input_format(Signature_Format);
86
PK_Verifier(const std::string&);
87
virtual ~PK_Verifier();
89
virtual bool validate_signature(const MemoryRegion<byte>&,
90
const byte[], u32bit) = 0;
91
virtual u32bit key_message_parts() const = 0;
92
virtual u32bit key_message_part_size() const = 0;
94
Signature_Format sig_format;
98
/*************************************************
100
*************************************************/
101
class PK_Key_Agreement
104
SymmetricKey derive_key(u32bit, const byte[], u32bit,
105
const std::string& = "") const;
106
SymmetricKey derive_key(u32bit, const byte[], u32bit,
107
const byte[], u32bit) const;
109
PK_Key_Agreement(const PK_Key_Agreement_Key&, const std::string&);
111
const PK_Key_Agreement_Key& key;
112
const std::string kdf_name;
115
/*************************************************
116
* Encryption with an MR algorithm and an EME *
117
*************************************************/
118
class PK_Encryptor_MR_with_EME : public PK_Encryptor
121
u32bit maximum_input_size() const;
122
PK_Encryptor_MR_with_EME(const PK_Encrypting_Key&, const std::string&);
123
~PK_Encryptor_MR_with_EME() { delete encoder; }
125
SecureVector<byte> enc(const byte[], u32bit) const;
126
const PK_Encrypting_Key& key;
130
/*************************************************
131
* Decryption with an MR algorithm and an EME *
132
*************************************************/
133
class PK_Decryptor_MR_with_EME : public PK_Decryptor
136
PK_Decryptor_MR_with_EME(const PK_Decrypting_Key&, const std::string&);
137
~PK_Decryptor_MR_with_EME() { delete encoder; }
139
SecureVector<byte> dec(const byte[], u32bit) const;
140
const PK_Decrypting_Key& key;
144
/*************************************************
145
* Public Key Verifier with Message Recovery *
146
*************************************************/
147
class PK_Verifier_with_MR : public PK_Verifier
150
PK_Verifier_with_MR(const PK_Verifying_with_MR_Key&, const std::string&);
152
bool validate_signature(const MemoryRegion<byte>&, const byte[], u32bit);
153
u32bit key_message_parts() const { return key.message_parts(); }
154
u32bit key_message_part_size() const { return key.message_part_size(); }
156
const PK_Verifying_with_MR_Key& key;
159
/*************************************************
160
* Public Key Verifier without Message Recovery *
161
*************************************************/
162
class PK_Verifier_wo_MR : public PK_Verifier
165
PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key&, const std::string&);
167
bool validate_signature(const MemoryRegion<byte>&, const byte[], u32bit);
168
u32bit key_message_parts() const { return key.message_parts(); }
169
u32bit key_message_part_size() const { return key.message_part_size(); }
171
const PK_Verifying_wo_MR_Key& key;