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

« back to all changes in this revision

Viewing changes to src/lib/pubkey/pk_ops.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
* (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 ~Encryption() = default;
 
46
   };
 
47
 
 
48
/**
 
49
* Public key decryption interface
 
50
*/
 
51
class BOTAN_PUBLIC_API(2,0) Decryption
 
52
   {
 
53
   public:
 
54
      virtual secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
 
55
                                          const uint8_t ciphertext[],
 
56
                                          size_t ciphertext_len) = 0;
 
57
 
 
58
      virtual ~Decryption() = default;
 
59
   };
 
60
 
 
61
/**
 
62
* Public key signature verification interface
 
63
*/
 
64
class BOTAN_PUBLIC_API(2,0) Verification
 
65
   {
 
66
   public:
 
67
      /*
 
68
      * Add more data to the message currently being signed
 
69
      * @param msg the message
 
70
      * @param msg_len the length of msg in bytes
 
71
      */
 
72
      virtual void update(const uint8_t msg[], size_t msg_len) = 0;
 
73
 
 
74
      /*
 
75
      * Perform a verification operation
 
76
      * @param rng a random number generator
 
77
      */
 
78
      virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len) = 0;
 
79
 
 
80
      virtual ~Verification() = default;
 
81
   };
 
82
 
 
83
/**
 
84
* Public key signature creation interface
 
85
*/
 
86
class BOTAN_PUBLIC_API(2,0) Signature
 
87
   {
 
88
   public:
 
89
      /*
 
90
      * Add more data to the message currently being signed
 
91
      * @param msg the message
 
92
      * @param msg_len the length of msg in bytes
 
93
      */
 
94
      virtual void update(const uint8_t msg[], size_t msg_len) = 0;
 
95
 
 
96
      /*
 
97
      * Perform a signature operation
 
98
      * @param rng a random number generator
 
99
      */
 
100
      virtual secure_vector<uint8_t> sign(RandomNumberGenerator& rng) = 0;
 
101
 
 
102
      virtual ~Signature() = default;
 
103
   };
 
104
 
 
105
/**
 
106
* A generic key agreement operation (eg DH or ECDH)
 
107
*/
 
108
class BOTAN_PUBLIC_API(2,0) Key_Agreement
 
109
   {
 
110
   public:
 
111
      virtual secure_vector<uint8_t> agree(size_t key_len,
 
112
                                        const uint8_t other_key[], size_t other_key_len,
 
113
                                        const uint8_t salt[], size_t salt_len) = 0;
 
114
 
 
115
      virtual ~Key_Agreement() = default;
 
116
   };
 
117
 
 
118
/**
 
119
* KEM (key encapsulation)
 
120
*/
 
121
class BOTAN_PUBLIC_API(2,0) KEM_Encryption
 
122
   {
 
123
   public:
 
124
      virtual void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
 
125
                               secure_vector<uint8_t>& out_shared_key,
 
126
                               size_t desired_shared_key_len,
 
127
                               Botan::RandomNumberGenerator& rng,
 
128
                               const uint8_t salt[],
 
129
                               size_t salt_len) = 0;
 
130
 
 
131
      virtual ~KEM_Encryption() = default;
 
132
   };
 
133
 
 
134
class BOTAN_PUBLIC_API(2,0) KEM_Decryption
 
135
   {
 
136
   public:
 
137
      virtual secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
 
138
                                              size_t len,
 
139
                                              size_t desired_shared_key_len,
 
140
                                              const uint8_t salt[],
 
141
                                              size_t salt_len) = 0;
 
142
 
 
143
      virtual ~KEM_Decryption() = default;
 
144
   };
 
145
 
 
146
}
 
147
 
 
148
}
 
149
 
 
150
#endif