| Qore Programming Language Reference Manual 2.2.0

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Qore::SSLPrivateKey Class Reference

This class implements a container for private key data. More...

`#include <QC_SSLPrivateKey.dox.h>`

Inheritance diagram for Qore::SSLPrivateKey:
[legend]

## Public Member Functions
| constructor (string pem, *string pass)
| Creates the SSLPrivateKey object from the PEM-encoded text representation of the private key passed.
| constructor (binary der)
| Creates the SSLPrivateKey object from the data argument passed.
| copy ()
| Returns a copy of the private key object.
int | getBitLength ()
| Returns the bit length of the private key.
binary | getDER ()
| Returns a binary object in DER format representing the private key.
hash< auto > | getInfo ()
| Returns a hash of all information for the private key.
string | getPEM ()
| Returns a string in PEM format representing the private key.
string | getType ()
| Returns a string giving the algorithm used for the private key.
int | getVersion ()
| Returns a constant value of 1; do not use; only included for backwards-compatibility.
Public Member Functions inherited from Qore::Serializable
| constructor ()
| The constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class.
| copy ()
| The copy constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class.
| serialize (OutputStream stream, *int flags)
| converts the object to binary data representing the object
binary | serialize (*int flags)
| converts the object to binary data representing the object
hash< SerializationInfo > | serializeToData (*int flags)
| converts the object to a serialization hash representing the object

## Additional Inherited Members
Static Public Member Functions inherited from Qore::Serializable
static auto | deserialize (InputStream stream, *int flags)
| Deserializes data produced with serialize() and returns the value represented by the data.
static auto | deserialize (binary bin, *int flags)
| Deserializes data produced with serialize() and returns the value represented by the data.
static auto | deserialize (string bin, *int flags)
| Deserializes data produced with serialize() and returns the value represented by the data.
static auto | deserialize (hash< SerializationInfo > data, *int flags)
| Deserializes data produced with serializeToData() and returns the value represented by the data.
static hash< SerializationInfo > | deserializeToData (InputStream stream, *int flags)
| Deserializes data produced with serialize() and returns the value represented by the data.
static hash< SerializationInfo > | deserializeToData (binary bin, *int flags)
| Deserializes data produced with serialize() and returns the value represented by the data.
static | serialize (auto val, OutputStream stream, *int flags)
| serializes the data and writes the serialized data to the given output stream
static binary | serialize (auto val, *int flags)
| serializes the data and returns the serialized data as a binary object
static hash< SerializationInfo > | serializeToData (auto val, *int flags)
| converts the value to a serialization hash representing the value

## Detailed Description

This class implements a container for private key data.

The SSLPrivateKey class supports data serialization; note that the serialized data is a representation of the data that does not require a password, so for source data that requires a password to use, the serialized representation of the private key should be protected carefully (transmitted only in an encrypted stream)

## Member Function Documentation

## ◆ constructor() [1/2]

Qore::SSLPrivateKey::constructor | ( | binary | der | ) |

Creates the SSLPrivateKey object from the data argument passed.

Parameters

  der | The DER-encoded binary representation of the private key

Example:
  SSLPrivateKey key(der);

Exceptions

  SSLPRIVATEKEY-CONSTRUCTOR-ERROR | error in private key data

## ◆ constructor() [2/2]

Qore::SSLPrivateKey::constructor | ( | string | pem,
|  | *string | pass )

Creates the SSLPrivateKey object from the PEM-encoded text representation of the private key passed.

Parameters

  pem | The PEM-encoded text representation of the private key
  pass | The optional password or passphrase for the private key

Example:
  SSLPrivateKey key(pem);

Exceptions

  SSLPRIVATEKEY-CONSTRUCTOR-ERROR | error in private key data

Since
  0.8.4: the deprecated functionality where the if the string passed was less than 200 bytes long, it was assumed to be a file name has been removed; the string is assumed to be the PEM-encoded private key itself

## ◆ copy()

Qore::SSLPrivateKey::copy | ( |  | ) |

Returns a copy of the private key object.

Since
  Qore 0.9

## ◆ getBitLength()

int Qore::SSLPrivateKey::getBitLength | ( |  | ) |

Returns the bit length of the private key.

Returns
  the bit length of the private key

Code Flags:
  CONSTANT

Example:
  int len = key.getBitLength();

## ◆ getDER()

binary Qore::SSLPrivateKey::getDER | ( |  | ) |

Returns a binary object in DER format representing the private key.

Code Flags:
  RET_VALUE_ONLY

Example:
  binary der = key.getDER();

Returns
  a binary object in DER format representing the private key

Note
  No password is required to use the DER data produced even if the object was originally created with a password

Exceptions

  SSLPRIVATEKEY-ERROR | could not create DER data from private key data

Since
  Qore 0.9

## ◆ getInfo()

hash< auto > Qore::SSLPrivateKey::getInfo | ( |  | ) |

Returns a hash of all information for the private key.

Returns
  a hash of all information for the private key with the following keys:
  - `"type"`: The type of private key (see SSLPrivateKey::getType())
  - `"version"`: The version of the private key (see SSLPrivateKey::getVersion())
  - `"bitLength"`: The bit length of the private key (see SSLPrivateKey::getBitLength())

Code Flags:
  CONSTANT

Example:
  hash<auto> h = key.getInfo();

## ◆ getPEM()

string Qore::SSLPrivateKey::getPEM | ( |  | ) |

Returns a string in PEM format representing the private key.

Returns
  a string in PEM format representing the private key

Code Flags:
  RET_VALUE_ONLY

Example:
  string pem = key.getPEM();

Note
  No password is required to use the PEM data produced even if the object was originally created with a password

Exceptions

  SSLPRIVATEKEY-ERROR | could not create PEM string from private key data

## ◆ getType()

string Qore::SSLPrivateKey::getType | ( |  | ) |

Returns a string giving the algorithm used for the private key.

Returns
  a string giving the algorithm used for the private key (ex: `"RSA"`, `"RSA2"`, `"DSA"`, `"DSA1"`, `"DSA2"`, `"DAS3"`, `"DAS4"`, `"DH"`, `"unknown"`)

Code Flags:
  CONSTANT

Example:
  string str = pkey.getType();

## ◆ getVersion()

int Qore::SSLPrivateKey::getVersion | ( |  | ) |

Returns a constant value of 1; do not use; only included for backwards-compatibility.

Code Flags:
  CONSTANT

The openssl library never put any usable value into the internal fields that were used to provide this information; newer versions of openssl do not expose this information at all, therefore this method now returns a constant value of 1 for backwards-compatibility.

Returns
  a constant value of 1; do not use; only included for backwards-compatibility