Qt Cryptographic Architecture: QCA::KeyLoader Class Reference

Qt Cryptographic Architecture

Signals | Public Member Functions | Friends | List of all members
QCA::KeyLoader Class Reference
QCA user API

`#include <QtCrypto>`

Collaboration diagram for QCA::KeyLoader:
[legend]

## Signals
void | finished ()

## Public Member Functions
ConvertResult | convertResult () const
KeyBundle | keyBundle () const
| KeyLoader (QObject *parent=0)
void | loadKeyBundleFromArray (const QByteArray &a)
void | loadKeyBundleFromFile (const QString &fileName)
void | loadPrivateKeyFromDER (const SecureArray &a)
void | loadPrivateKeyFromPEM (const QString &s)
void | loadPrivateKeyFromPEMFile (const QString &fileName)
PrivateKey | privateKey () const

## Friends
class | Private

## Detailed Description

Asynchronous private key loader.

GUI applications generally must use KeyLoader to load private keys. This is because the synchronous private key loading functions, for example QCA::PrivateKey::fromPEMFile(), cannot be used within the same thread as an EventHandler, and most GUI applications will use EventHandler from the main thread. KeyLoader does not have this problem. It can be used from any thread, including the same thread as EventHandler.

The KeyLoader class allows you to asynchronously load stand-alone private keys (QCA::PrivateKey) or private keys with a certificate (QCA::KeyBundle) with a signal that advises of completion.

To use this class to load a PrivateKey, you create a KeyLoader object then use one of the loadPrivateKeyFrom...() functions, depending on the format for your key. These functions return immediately. When you get the finished() signal, you can check that the loading operation succeeded (using convertResult()) and then obtain the PrivateKey using the privateKey() function.

The same process applies for loading a KeyBundle, except that you use either loadKeyBundleFromFile() or loadKeyBundleFromArray() instead of the loadPrivateKeyFrom...() function, and use keyBundle() instead of privateKey().

The loader may need a passphrase to complete the loading of the key or key bundle. You should use the QCA::EventHandler class to ensure that you deal with this correctly.

Note
  QCA also provides synchronous private key loading using QCA::PrivateKey::fromPEMFile(), QCA::PrivateKey::fromPEM() and QCA::PrivateKey::fromDER(). QCA provides synchronous key bundle loading using QCA::KeyBundle::fromArray() and QCA::KeyBundle::fromFile().

Examples:
  keyloader.cpp.

## Constructor & Destructor Documentation

## ◆ KeyLoader()

QCA::KeyLoader::KeyLoader | ( | QObject * | parent = `0` | ) |

Create a KeyLoader object.

Parameters

  parent | the parent object for this object

## Member Function Documentation

## ◆ loadPrivateKeyFromPEMFile()

void QCA::KeyLoader::loadPrivateKeyFromPEMFile | ( | const QString & | fileName | ) |

Initiate an asynchronous loading of a PrivateKey from a PEM format file.

This function will return immediately.

Parameters

  fileName | the name of the file (and path, if necessary) to load the key from

Examples:
  keyloader.cpp.

## ◆ loadPrivateKeyFromPEM()

void QCA::KeyLoader::loadPrivateKeyFromPEM | ( | const QString & | s | ) |

Initiate an asynchronous loading of a PrivateKey from a PEM format string.

This function will return immediately.

Parameters

  s | the string containing the PEM formatted key

## ◆ loadPrivateKeyFromDER()

void QCA::KeyLoader::loadPrivateKeyFromDER | ( | const SecureArray & | a | ) |

Initiate an asynchronous loading of a PrivateKey from a DER format array.

This function will return immediately.

Parameters

  a | the array containing the DER formatted key

## ◆ loadKeyBundleFromFile()

void QCA::KeyLoader::loadKeyBundleFromFile | ( | const QString & | fileName | ) |

Initiate an asynchronous loading of a KeyBundle from a file.

This function will return immediately.

Parameters

  fileName | the name of the file (and path, if necessary) to load the key bundle from

## ◆ loadKeyBundleFromArray()

void QCA::KeyLoader::loadKeyBundleFromArray | ( | const QByteArray & | a | ) |

Initiate an asynchronous loading of a KeyBundle from an array.

This function will return immediately.

Parameters

  a | the array containing the key bundle

## ◆ convertResult()

ConvertResult QCA::KeyLoader::convertResult | ( |  | ) | const

The result of the loading process.

This is not valid until the finished() signal has been emitted.

Examples:
  keyloader.cpp.

## ◆ privateKey()

PrivateKey QCA::KeyLoader::privateKey | ( |  | ) | const

The private key that has been loaded.

This is only valid if loadPrivateKeyFromPEMFile(), loadPrivateKeyFromPEM() or loadPrivateKeyFromDER() has been used, the load has completed (that is, finished() has been emitted), and the conversion succeeded (that is, convertResult() returned ConvertGood).

Examples:
  keyloader.cpp.

## ◆ keyBundle()

KeyBundle QCA::KeyLoader::keyBundle | ( |  | ) | const

The key bundle that has been loaded.

This is only valid if loadKeyBundleFromFile() or loadKeyBundleFromArray() has been used, the load has completed (that is, finished() has been emitted), and the conversion succeeded (that is, convertResult() returned ConvertGood).

## ◆ finished

void QCA::KeyLoader::finished | ( |  | ) |
| signal

Signal that is emitted when the load process has completed.

Note
  The load process may not have completed successfully - check the result of convertResult() to confirm this before using the privateKey() or keyBundle() results.

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

- qca_cert.h