/*************************************************
* PKCS #8 Header File                            *
* (C) 1999-2003 The Botan Project                *
*************************************************/

#ifndef BOTAN_PKCS8_H__
#define BOTAN_PKCS8_H__

#include <botan/x509_key.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() {}
   };

namespace PKCS8 {

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

void encrypt_key(const PKCS8_PrivateKey&, Pipe&, const std::string&,
                 const std::string& = "PBE-PKCS5v20(SHA-160,TripleDES/CBC)",
                 X509_Encoding = PEM);
void decrypt_key(PKCS8_PrivateKey&, DataSource&, const std::string&,
                 X509_Encoding = PEM);

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

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


}

}

#endif
