Loading...
Searching...
No Matches
SiPrivateKey Class Reference

a class representing a private key. More...

## Public Member Functions

| SiPrivateKey ()
| default constructor
virtual | ~SiPrivateKey ()
| destructor
void | setPrivateKeyPasswd (const char *thePasswd)
| sets the password string to be used when loading an encrypted private key file in PEM format (ASN.1/DER encoded files are never encrypted).
void | setPrivateKeyPasswdFromConsole ()
| sets the password string to be used when loading an encrypted private key file to be read from the console stdin.
OFCondition | loadPrivateKey (const char *filename, int filetype)
| loads a private key from file.
E_KeyType | getKeyType () const
| returns the type of public key stored in this certificate
SiAlgorithm * | createAlgorithmForPrivateKey ()
| creates an SiAlgorithm object for the private key contained in this certificate.
OFBool | matchesCertificate (SiCertificate &cert)
| checks if the private key and the certificate set using setPrivateKeyFile() and setCertificateFile() match, i.e.
EVP_PKEY * | getRawPrivateKey ()
| provides access to the raw private key in OpenSSL format.

## Private Member Functions

| SiPrivateKey (SiPrivateKey &arg)
| private undefined copy constructor
SiPrivateKey & | operator= (SiPrivateKey &arg)
| private undefined copy assignment operator

## Private Attributes

OFString | privateKeyPasswd
| contains the password for the private key if set on command line
OFBool | usePrivateKeyPassword
| true if the privateKeyPasswd contains the password, false otherwise.
EVP_PKEY * | pkey
| the private key managed by this object, may be NULL if not loaded yet

## Detailed Description

a class representing a private key.

Remarks
  this class is only available if DCMTK is compiled with OpenSSL support enabled.

## Member Function Documentation

## createAlgorithmForPrivateKey()

SiAlgorithm * SiPrivateKey::createAlgorithmForPrivateKey | ( |  | ) |

creates an SiAlgorithm object for the private key contained in this certificate.

If no key is loaded or operation fails, returns NULL. New SiAlgorithm object must be deleted by caller.

Returns
  pointer to new SiAlgorithm object

## getRawPrivateKey()

EVP_PKEY * SiPrivateKey::getRawPrivateKey | ( |  | ) |

provides access to the raw private key in OpenSSL format.

Use with care!

Returns
  raw private key in OpenSSL format

## loadPrivateKey()

OFCondition SiPrivateKey::loadPrivateKey | ( | const char * | filename,
|  | int | filetype )

loads a private key from file.

If the private key is in encrypted PEM format, the password is either read from console (default) or taken from an internal setting created with setPrivateKeyPasswd().

Parameters

  filename | file name of key
  filetype | file format: X509_FILETYPE_PEM or X509_FILETYPE_ASN1

Returns
  status code

## matchesCertificate()

OFBool SiPrivateKey::matchesCertificate | ( | SiCertificate & | cert | ) |

checks if the private key and the certificate set using setPrivateKeyFile() and setCertificateFile() match, i.e.

if they establish a private/public key pair.

Returns
  OFTrue if private key and certificate match, OFFalse otherwise.

## setPrivateKeyPasswd()

void SiPrivateKey::setPrivateKeyPasswd | ( | const char * | thePasswd | ) |

sets the password string to be used when loading an encrypted private key file in PEM format (ASN.1/DER encoded files are never encrypted).

Must be called prior to loadPrivateKey() in order to be effective.

Parameters

  thePasswd | password string, may be "" or NULL in which case an empty password is assumed.

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

- dcmsign/include/dcmtk/dcmsign/siprivat.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.15.0