aboutsummaryrefslogtreecommitdiffstats
path: root/include/pk_keys.h
blob: d1f6a22043f1172bfb702108c7360401f060f68a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*************************************************
* PK Key Types Header File                       *
* (C) 1999-2006 The Botan Project                *
*************************************************/

#ifndef BOTAN_PK_KEYS_H__
#define BOTAN_PK_KEYS_H__

#include <botan/base.h>
#include <botan/asn1_oid.h>

namespace Botan {

/*************************************************
* Public Key Base Class                          *
*************************************************/
class Public_Key
   {
   public:
      virtual std::string algo_name() const = 0;
      virtual OID get_oid() const;

      virtual bool check_key(bool) const { return true; }
      virtual u32bit message_parts() const { return 1; }
      virtual u32bit message_part_size() const { return 0; }
      virtual u32bit max_input_bits() const = 0;

      virtual class X509_Encoder* x509_encoder() const { return 0; }
      virtual class X509_Decoder* x509_decoder() { return 0; }

      virtual ~Public_Key() {}
   protected:
      virtual void load_check() const;
   };

/*************************************************
* Private Key Base Class                         *
*************************************************/
class Private_Key : public virtual Public_Key
   {
   public:
      virtual class PKCS8_Encoder* pkcs8_encoder() const { return 0; }
      virtual class PKCS8_Decoder* pkcs8_decoder() { return 0; }
   protected:
      void load_check() const;
      void gen_check() const;
   };

/*************************************************
* PK Encrypting Key                              *
*************************************************/
class PK_Encrypting_Key : public virtual Public_Key
   {
   public:
      virtual SecureVector<byte> encrypt(const byte[], u32bit) const = 0;
      virtual ~PK_Encrypting_Key() {}
   };

/*************************************************
* PK Decrypting Key                              *
*************************************************/
class PK_Decrypting_Key : public virtual Private_Key
   {
   public:
      virtual SecureVector<byte> decrypt(const byte[], u32bit) const = 0;
      virtual ~PK_Decrypting_Key() {}
   };

/*************************************************
* PK Signing Key                                 *
*************************************************/
class PK_Signing_Key : public virtual Private_Key
   {
   public:
      virtual SecureVector<byte> sign(const byte[], u32bit) const = 0;
      virtual ~PK_Signing_Key() {}
   };

/*************************************************
* PK Verifying Key, Message Recovery Version     *
*************************************************/
class PK_Verifying_with_MR_Key : public virtual Public_Key
   {
   public:
      virtual SecureVector<byte> verify(const byte[], u32bit) const = 0;
      virtual ~PK_Verifying_with_MR_Key() {}
   };

/*************************************************
* PK Verifying Key, No Message Recovery Version  *
*************************************************/
class PK_Verifying_wo_MR_Key : public virtual Public_Key
   {
   public:
      virtual bool verify(const byte[], u32bit,
                          const byte[], u32bit) const = 0;
      virtual ~PK_Verifying_wo_MR_Key() {}
   };

/*************************************************
* PK Secret Value Derivation Key                 *
*************************************************/
class PK_Key_Agreement_Key : public virtual Private_Key
   {
   public:
      virtual SecureVector<byte> derive_key(const byte[], u32bit) const = 0;
      virtual MemoryVector<byte> public_value() const = 0;
      virtual ~PK_Key_Agreement_Key() {}
   };

/*************************************************
* Typedefs                                       *
*************************************************/
typedef PK_Key_Agreement_Key PK_KA_Key;
typedef Public_Key X509_PublicKey;
typedef Private_Key PKCS8_PrivateKey;

}

#endif