aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/pkcs8.h
blob: 383b1604ac28d5621318f86064f76603da94546d (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
/*************************************************
* PKCS #8 Header File                            *
* (C) 1999-2007 Jack Lloyd                       *
*************************************************/

#ifndef BOTAN_PKCS8_H__
#define BOTAN_PKCS8_H__

#include <botan/x509_key.h>
#include <botan/ui.h>
#include <botan/enums.h>

namespace Botan {

/*************************************************
* PKCS #8 Private Key Encoder                    *
*************************************************/
class BOTAN_DLL PKCS8_Encoder
   {
   public:
      virtual AlgorithmIdentifier alg_id() const = 0;
      virtual MemoryVector<byte> key_bits() const = 0;
      virtual ~PKCS8_Encoder() {}
   };

/*************************************************
* PKCS #8 Private Key Decoder                    *
*************************************************/
class BOTAN_DLL PKCS8_Decoder
   {
   public:
      virtual void alg_id(const AlgorithmIdentifier&) = 0;
      virtual void key_bits(const MemoryRegion<byte>&) = 0;
      virtual ~PKCS8_Decoder() {}
   };

/*************************************************
* PKCS #8 General Exception                      *
*************************************************/
struct BOTAN_DLL PKCS8_Exception : public Decoding_Error
   {
   PKCS8_Exception(const std::string& error) :
      Decoding_Error("PKCS #8: " + error) {}
   };

namespace PKCS8 {

/*************************************************
* PKCS #8 Private Key Encoding/Decoding          *
*************************************************/
BOTAN_DLL void encode(const Private_Key&, Pipe&, X509_Encoding = PEM);
BOTAN_DLL std::string PEM_encode(const Private_Key&);

BOTAN_DLL void encrypt_key(const Private_Key&,
                           Pipe&,
                           RandomNumberGenerator&,
                           const std::string&,
                           const std::string& = "",
                           X509_Encoding = PEM);

BOTAN_DLL std::string PEM_encode(const Private_Key&,
                                 RandomNumberGenerator&,
                                 const std::string&,
                                 const std::string& = "");

BOTAN_DLL Private_Key* load_key(DataSource&, RandomNumberGenerator&,
                                const User_Interface&);
BOTAN_DLL Private_Key* load_key(DataSource&, RandomNumberGenerator&,
                                const std::string& = "");

BOTAN_DLL Private_Key* load_key(const std::string&,
                                RandomNumberGenerator&,
                                const User_Interface&);
BOTAN_DLL Private_Key* load_key(const std::string&,
                                RandomNumberGenerator&,
                                const std::string& = "");

BOTAN_DLL Private_Key* copy_key(const Private_Key&,
                                RandomNumberGenerator& rng);

}

}

#endif