~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to include/pubkey.h

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*************************************************
2
 
* Public Key Interface Header File               *
3
 
* (C) 1999-2007 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
 
 
13
 
namespace Botan {
14
 
 
15
 
/*************************************************
16
 
* Public Key Encryptor                           *
17
 
*************************************************/
18
 
class 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
 
*************************************************/
32
 
class 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
 
*************************************************/
45
 
class 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
 
*************************************************/
70
 
class 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 std::string&);
87
 
      virtual ~PK_Verifier();
88
 
   protected:
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;
93
 
 
94
 
      Signature_Format sig_format;
95
 
      EMSA* emsa;
96
 
   };
97
 
 
98
 
/*************************************************
99
 
* Key Agreement                                  *
100
 
*************************************************/
101
 
class PK_Key_Agreement
102
 
   {
103
 
   public:
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;
108
 
 
109
 
      PK_Key_Agreement(const PK_Key_Agreement_Key&, const std::string&);
110
 
   private:
111
 
      const PK_Key_Agreement_Key& key;
112
 
      const std::string kdf_name;
113
 
   };
114
 
 
115
 
/*************************************************
116
 
* Encryption with an MR algorithm and an EME     *
117
 
*************************************************/
118
 
class PK_Encryptor_MR_with_EME : public PK_Encryptor
119
 
   {
120
 
   public:
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; }
124
 
   private:
125
 
      SecureVector<byte> enc(const byte[], u32bit) const;
126
 
      const PK_Encrypting_Key& key;
127
 
      const EME* encoder;
128
 
   };
129
 
 
130
 
/*************************************************
131
 
* Decryption with an MR algorithm and an EME     *
132
 
*************************************************/
133
 
class PK_Decryptor_MR_with_EME : public PK_Decryptor
134
 
   {
135
 
   public:
136
 
      PK_Decryptor_MR_with_EME(const PK_Decrypting_Key&, const std::string&);
137
 
      ~PK_Decryptor_MR_with_EME() { delete encoder; }
138
 
   private:
139
 
      SecureVector<byte> dec(const byte[], u32bit) const;
140
 
      const PK_Decrypting_Key& key;
141
 
      const EME* encoder;
142
 
   };
143
 
 
144
 
/*************************************************
145
 
* Public Key Verifier with Message Recovery      *
146
 
*************************************************/
147
 
class PK_Verifier_with_MR : public PK_Verifier
148
 
   {
149
 
   public:
150
 
      PK_Verifier_with_MR(const PK_Verifying_with_MR_Key&, const std::string&);
151
 
   private:
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(); }
155
 
 
156
 
      const PK_Verifying_with_MR_Key& key;
157
 
   };
158
 
 
159
 
/*************************************************
160
 
* Public Key Verifier without Message Recovery   *
161
 
*************************************************/
162
 
class PK_Verifier_wo_MR : public PK_Verifier
163
 
   {
164
 
   public:
165
 
      PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key&, const std::string&);
166
 
   private:
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(); }
170
 
 
171
 
      const PK_Verifying_wo_MR_Key& key;
172
 
   };
173
 
 
174
 
}
175
 
 
176
 
#endif