aboutsummaryrefslogtreecommitdiffstats
path: root/include/pkcs8.h
blob: dc70acbe421e08d1b311942e707a8b6884a3092e (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
/*************************************************
* PKCS #8 Header File                            *
* (C) 1999-2006 The Botan Project                *
*************************************************/

#ifndef BOTAN_PKCS8_H__
#define BOTAN_PKCS8_H__

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

namespace Botan {

/*************************************************
* PKCS #8 Private Key                            *
*************************************************/
class PKCS8_PrivateKey : public virtual X509_PublicKey
   {
   public:
      virtual SecureVector<byte> DER_encode_priv() const = 0;
      virtual void BER_decode_priv(DataSource&) = 0;
      virtual ~PKCS8_PrivateKey() {}
   };

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

namespace PKCS8 {

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

std::string PEM_encode(const PKCS8_PrivateKey&);
std::string PEM_encode(const PKCS8_PrivateKey&, const std::string&,
                       const std::string& = "");

PKCS8_PrivateKey* load_key(DataSource&, const User_Interface&);
PKCS8_PrivateKey* load_key(DataSource&, const std::string& = "");

PKCS8_PrivateKey* load_key(const std::string&, const User_Interface&);
PKCS8_PrivateKey* load_key(const std::string&, const std::string& = "");

PKCS8_PrivateKey* copy_key(const PKCS8_PrivateKey&);

}

}

#endif