monotone

monotone Mtn Source Tree

Root/botan/pubkey.h

1/*************************************************
2* Public Key Interface Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_PUBKEY_H__
7#define BOTAN_PUBKEY_H__
8
9#include <botan/base.h>
10#include <botan/pk_keys.h>
11#include <botan/pk_util.h>
12
13namespace Botan {
14
15/*************************************************
16* Public Key Encryptor *
17*************************************************/
18class PK_Encryptor
19 {
20 public:
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() {}
25 private:
26 virtual SecureVector<byte> enc(const byte[], u32bit) const = 0;
27 };
28
29/*************************************************
30* Public Key Decryptor *
31*************************************************/
32class PK_Decryptor
33 {
34 public:
35 SecureVector<byte> decrypt(const byte[], u32bit) const;
36 SecureVector<byte> decrypt(const MemoryRegion<byte>&) const;
37 virtual ~PK_Decryptor() {}
38 private:
39 virtual SecureVector<byte> dec(const byte[], u32bit) const = 0;
40 };
41
42/*************************************************
43* Public Key Signer *
44*************************************************/
45class PK_Signer
46 {
47 public:
48 SecureVector<byte> sign_message(const byte[], u32bit);
49 SecureVector<byte> sign_message(const MemoryRegion<byte>&);
50
51 void update(byte);
52 void update(const byte[], u32bit);
53 void update(const MemoryRegion<byte>&);
54
55 SecureVector<byte> signature();
56
57 void set_output_format(Signature_Format);
58
59 PK_Signer(const PK_Signing_Key&, const std::string&);
60 ~PK_Signer() { delete emsa; }
61 private:
62 const PK_Signing_Key& key;
63 Signature_Format sig_format;
64 EMSA* emsa;
65 };
66
67/*************************************************
68* Public Key Verifier *
69*************************************************/
70class PK_Verifier
71 {
72 public:
73 bool verify_message(const byte[], u32bit, const byte[], u32bit);
74 bool verify_message(const MemoryRegion<byte>&,
75 const MemoryRegion<byte>&);
76
77 void update(byte);
78 void update(const byte[], u32bit);
79 void update(const MemoryRegion<byte>&);
80
81 bool check_signature(const byte[], u32bit);
82 bool check_signature(const MemoryRegion<byte>&);
83
84 void set_input_format(Signature_Format);
85
86 PK_Verifier(const PK_Key&, const std::string&);
87 virtual ~PK_Verifier() { delete emsa; }
88 protected:
89 virtual bool validate_signature(const MemoryRegion<byte>&,
90 const byte[], u32bit) = 0;
91 Signature_Format sig_format;
92 EMSA* emsa;
93 private:
94 const PK_Key& key;
95 };
96
97/*************************************************
98* Key Agreement *
99*************************************************/
100class PK_Key_Agreement
101 {
102 public:
103 SymmetricKey derive_key(u32bit, const byte[], u32bit,
104 const std::string& = "") const;
105 SymmetricKey derive_key(u32bit, const byte[], u32bit,
106 const byte[], u32bit) const;
107
108 PK_Key_Agreement(const PK_Key_Agreement_Key&, const std::string&);
109 private:
110 const PK_Key_Agreement_Key& key;
111 const std::string kdf_name;
112 };
113
114/*************************************************
115* Encryption with an MR algorithm and an EME *
116*************************************************/
117class PK_Encryptor_MR_with_EME : public PK_Encryptor
118 {
119 public:
120 u32bit maximum_input_size() const;
121 PK_Encryptor_MR_with_EME(const PK_Encrypting_Key&, const std::string&);
122 ~PK_Encryptor_MR_with_EME() { delete encoder; }
123 private:
124 SecureVector<byte> enc(const byte[], u32bit) const;
125 const PK_Encrypting_Key& key;
126 const EME* encoder;
127 };
128
129/*************************************************
130* Decryption with an MR algorithm and an EME *
131*************************************************/
132class PK_Decryptor_MR_with_EME : public PK_Decryptor
133 {
134 public:
135 PK_Decryptor_MR_with_EME(const PK_Decrypting_Key&, const std::string&);
136 ~PK_Decryptor_MR_with_EME() { delete encoder; }
137 private:
138 SecureVector<byte> dec(const byte[], u32bit) const;
139 const PK_Decrypting_Key& key;
140 const EME* encoder;
141 };
142
143/*************************************************
144* Public Key Verifier with Message Recovery *
145*************************************************/
146class PK_Verifier_with_MR : public PK_Verifier
147 {
148 public:
149 PK_Verifier_with_MR(const PK_Verifying_with_MR_Key&, const std::string&);
150 private:
151 bool validate_signature(const MemoryRegion<byte>&, const byte[], u32bit);
152 const PK_Verifying_with_MR_Key& key;
153 };
154
155/*************************************************
156* Public Key Verifier without Message Recovery *
157*************************************************/
158class PK_Verifier_wo_MR : public PK_Verifier
159 {
160 public:
161 PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key&, const std::string&);
162 private:
163 bool validate_signature(const MemoryRegion<byte>&, const byte[], u32bit);
164 const PK_Verifying_wo_MR_Key& key;
165 };
166
167}
168
169#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status