PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PSSLPrivateKey Class Reference

Private key for SSL. More...

#include <pssl.h>

Inheritance diagram for PSSLPrivateKey:
Collaboration diagram for PSSLPrivateKey:

Public Member Functions

 PSSLPrivateKey ()
 Create an empty private key. More...
 
 PSSLPrivateKey (unsigned modulus, void(*callback)(int, int, void *)=NULL, void *cb_arg=NULL)
 Create a new RSA private key. More...
 
 PSSLPrivateKey (const PFilePath &keyFile, PSSLFileTypes fileType=PSSLFileTypeDEFAULT)
 Create a new private key given the file. More...
 
 PSSLPrivateKey (const BYTE *keyData, PINDEX keySize)
 Create private key from the binary ASN1 DER encoded data specified. More...
 
 PSSLPrivateKey (const PBYTEArray &keyData)
 Create private key from the binary ASN1 DER encoded data specified. More...
 
 PSSLPrivateKey (const PSSLPrivateKey &privKey)
 Create a copy of the private key. More...
 
 PSSLPrivateKey (evp_pkey_st *privKey, bool duplicate=true)
 
PSSLPrivateKeyoperator= (const PSSLPrivateKey &privKay)
 Create a copy of the private key. More...
 
PSSLPrivateKeyoperator= (evp_pkey_st *privKay)
 
 ~PSSLPrivateKey ()
 Destroy and release storage for private key. More...
 
 operator evp_pkey_st * () const
 Get internal OpenSSL private key structure. More...
 
void Attach (evp_pkey_st *key)
 Set internal OpenSSL private key structure. More...
 
PBoolean Create (unsigned modulus, void(*callback)(int, int, void *)=NULL, void *cb_arg=NULL)
 Create a new private key. More...
 
bool IsValid () const
 Return true if is a valid private key. More...
 
bool SetData (const PBYTEArray &data)
 Set the certificate as binary ASN1 DER encoded data. More...
 
PBYTEArray GetData () const
 Get the certificate as binary ASN1 DER encoded data. More...
 
PString AsString () const
 Get the certificate as ASN1 DER base64 encoded data. More...
 
bool Parse (const PString &keyStr)
 Set the certificate from ASN1 DER base64 encoded data. More...
 
PBoolean Load (const PFilePath &keyFile, PSSLFileTypes fileType=PSSLFileTypeDEFAULT, const PSSLPasswordNotifier &notifier=PSSLPasswordNotifier())
 Load private key from file. More...
 
PBoolean Save (const PFilePath &keyFile, PBoolean append=false, PSSLFileTypes fileType=PSSLFileTypeDEFAULT)
 Save private key to file. More...
 
- Public Member Functions inherited from PObject
unsigned GetTraceContextIdentifier () const
 Get PTRACE context identifier. More...
 
void SetTraceContextIdentifier (unsigned id)
 
void GetTraceContextIdentifier (PObject &obj)
 
void GetTraceContextIdentifier (PObject *obj)
 
void SetTraceContextIdentifier (const PObject &obj)
 
void SetTraceContextIdentifier (const PObject *obj)
 
virtual ~PObject ()
 
virtual PObjectClone () const
 Create a copy of the class on the heap. More...
 
template<class CLS >
CLS * CloneAs () const
 As for Clone() but converts to specified type. More...
 
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class. More...
 
virtual const char * GetClass (unsigned ancestor=0) const
 Get the current dynamic type of the object instance. More...
 
PBoolean IsClass (const char *cls) const
 
virtual PBoolean InternalIsDescendant (const char *clsName) const
 Determine if the dynamic type of the current instance is a descendent of the specified class. More...
 
__inline const PObjectPTraceObjectInstance () const
 
virtual Comparison Compare (const PObject &obj) const
 Compare the two objects and return their relative rank. More...
 
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects. More...
 
bool operator== (const PObject &obj) const
 Compare the two objects. More...
 
bool operator!= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator< (const PObject &obj) const
 Compare the two objects. More...
 
bool operator> (const PObject &obj) const
 Compare the two objects. More...
 
bool operator<= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator>= (const PObject &obj) const
 Compare the two objects. More...
 
virtual void PrintOn (ostream &strm) const
 Output the contents of the object to the stream. More...
 
virtual void ReadFrom (istream &strm)
 Input the contents of the object from the stream. More...
 

Protected Member Functions

void FreePrivateKey ()
 
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 

Protected Attributes

evp_pkey_st * m_pkey
 
- Protected Attributes inherited from PObject
unsigned m_traceContextIdentifier
 

Additional Inherited Members

- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 
- Static Public Member Functions inherited from PObject
static const char * Class ()
 Get the name of the class as a C string. More...
 
static __inline const PObjectPTraceObjectInstance (const char *)
 
static __inline const PObjectPTraceObjectInstance (const PObject *obj)
 
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect() More...
 
- Friends inherited from PObject

Detailed Description

Private key for SSL.

This class embodies a common environment for all private keys used by the PSSLContext and PSSLChannel classes.

Constructor & Destructor Documentation

PSSLPrivateKey::PSSLPrivateKey ( )

Create an empty private key.

PSSLPrivateKey::PSSLPrivateKey ( unsigned  modulus,
void(*)(int, int, void *)  callback = NULL,
void *  cb_arg = NULL 
)

Create a new RSA private key.

Parameters
modulusNumber of bits
callbackProgress callback function
cb_argArgument passed to callback
PSSLPrivateKey::PSSLPrivateKey ( const PFilePath keyFile,
PSSLFileTypes  fileType = PSSLFileTypeDEFAULT 
)

Create a new private key given the file.

The type of the private key can be specified explicitly, or if PSSLFileTypeDEFAULT it will be determined from the file extension, ".pem" is a text file, anything else eg ".der" is a binary ASN1 file.

Parameters
keyFilePrivate key file
fileTypeType of file to read
PSSLPrivateKey::PSSLPrivateKey ( const BYTE *  keyData,
PINDEX  keySize 
)

Create private key from the binary ASN1 DER encoded data specified.

Parameters
keyDataPrivate key data
keySizeSize of private key data
PSSLPrivateKey::PSSLPrivateKey ( const PBYTEArray keyData)

Create private key from the binary ASN1 DER encoded data specified.

Parameters
keyDataPrivate key data
PSSLPrivateKey::PSSLPrivateKey ( const PSSLPrivateKey privKey)

Create a copy of the private key.

PSSLPrivateKey::PSSLPrivateKey ( evp_pkey_st *  privKey,
bool  duplicate = true 
)
PSSLPrivateKey::~PSSLPrivateKey ( )

Destroy and release storage for private key.

Member Function Documentation

PString PSSLPrivateKey::AsString ( ) const

Get the certificate as ASN1 DER base64 encoded data.

void PSSLPrivateKey::Attach ( evp_pkey_st *  key)

Set internal OpenSSL private key structure.

PBoolean PSSLPrivateKey::Create ( unsigned  modulus,
void(*)(int, int, void *)  callback = NULL,
void *  cb_arg = NULL 
)

Create a new private key.

Parameters
modulusNumber of bits
callbackProgress callback function
cb_argArgument passed to callback
void PSSLPrivateKey::FreePrivateKey ( )
protected
PBYTEArray PSSLPrivateKey::GetData ( ) const

Get the certificate as binary ASN1 DER encoded data.

bool PSSLPrivateKey::IsValid ( ) const
inline

Return true if is a valid private key.

References m_pkey.

PBoolean PSSLPrivateKey::Load ( const PFilePath keyFile,
PSSLFileTypes  fileType = PSSLFileTypeDEFAULT,
const PSSLPasswordNotifier notifier = PSSLPasswordNotifier() 
)

Load private key from file.

The type of the private key can be specified explicitly, or if PSSLFileTypeDEFAULT it will be determined from the file extension, ".pem" is a text file, anything else eg ".der" is a binary ASN1 file.

Parameters
keyFilePrivate key file
fileTypeType of file to read
notifierCall back for asking of password
PSSLPrivateKey::operator evp_pkey_st * ( ) const
inline

Get internal OpenSSL private key structure.

References m_pkey.

PSSLPrivateKey& PSSLPrivateKey::operator= ( const PSSLPrivateKey privKay)

Create a copy of the private key.

PSSLPrivateKey& PSSLPrivateKey::operator= ( evp_pkey_st *  privKay)
bool PSSLPrivateKey::Parse ( const PString keyStr)

Set the certificate from ASN1 DER base64 encoded data.

PBoolean PSSLPrivateKey::Save ( const PFilePath keyFile,
PBoolean  append = false,
PSSLFileTypes  fileType = PSSLFileTypeDEFAULT 
)

Save private key to file.

The type of the private key can be specified explicitly, or if PSSLFileTypeDEFAULT it will be determined from the file extension, ".pem" is a text file, anything else eg ".der" is a binary ASN1 file.

Parameters
keyFilePrivate key file
appendAppend to file
fileTypeType of file to write
bool PSSLPrivateKey::SetData ( const PBYTEArray data)

Set the certificate as binary ASN1 DER encoded data.

Member Data Documentation

evp_pkey_st* PSSLPrivateKey::m_pkey
protected

Referenced by IsValid(), and operator evp_pkey_st *().


The documentation for this class was generated from the following file: