# QCA::KeyGenerator Class Reference
[QCA user API]

Class for generating asymmetric key pairs. More...

`#include <QtCrypto>`

Inheritance diagram for QCA::KeyGenerator:

Collaboration diagram for QCA::KeyGenerator:

[legend]

List of all members.

## Signals

void | finished ()

## Public Member Functions

bool | blockingEnabled () const
PrivateKey | createDH (const DLGroup &domain, const QString &provider=QString())
DLGroup | createDLGroup (QCA::DLGroupSet set, const QString &provider=QString())
PrivateKey | createDSA (const DLGroup &domain, const QString &provider=QString())
PrivateKey | createRSA (int bits, int exp=65537, const QString &provider=QString())
DLGroup | dlGroup () const
bool | isBusy () const
PrivateKey | key () const
| KeyGenerator (QObject *parent=0)
void | setBlockingEnabled (bool b)

## Friends

class | Private

## Detailed Description

Class for generating asymmetric key pairs.

This class is used for generating asymmetric keys (public/private key pairs).

Examples:

  rsatest.cpp.

## Constructor & Destructor Documentation

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

Create a new key generator.

Parameters:

  | parent | the parent object, if applicable

## Member Function Documentation

bool QCA::KeyGenerator::blockingEnabled | ( |  | ) | const

Test whether the key generator is set to operate in blocking mode, or not.

Returns:
  true if the key generator is in blocking mode

See also:
  setBlockingEnabled

PrivateKey QCA::KeyGenerator::createDH | ( | const DLGroup & | domain,
|  | const QString & | provider = `QString()` |
| ) |  |  |

Generate a Diffie-Hellman key.

This method creates both the public key and corresponding private key. You almost certainly want to extract the public key part out - see PKey::toPublicKey for an easy way.

Parameters:

  | domain | the discrete logarithm group that this key should be generated from
  | provider | the name of the provider to use, if a particular provider is required

Note:
  For compatibility, you should use one of the IETF_ groupsets as the domain argument.

DLGroup QCA::KeyGenerator::createDLGroup | ( | QCA::DLGroupSet | set,
|  | const QString & | provider = `QString()` |
| ) |  |  |

Create a new discrete logarithm group.

Parameters:

  | set | the set of discrete logarithm parameters to generate from
  | provider | the name of the provider to use, if a particular provider is required.

PrivateKey QCA::KeyGenerator::createDSA | ( | const DLGroup & | domain,
|  | const QString & | provider = `QString()` |
| ) |  |  |

Generate a DSA key.

This method creates both the public key and corresponding private key. You almost certainly want to extract the public key part out - see PKey::toPublicKey for an easy way.

Parameters:

  | domain | the discrete logarithm group that this key should be generated from
  | provider | the name of the provider to use, if a particular provider is required

Note:
  Not every DLGroup makes sense for DSA. You should use one of DSA_512, DSA_768 and DSA_1024.

PrivateKey QCA::KeyGenerator::createRSA | ( | int | bits,
|  | int | exp = `65537`,
|  | const QString & | provider = `QString()` |
| ) |  |  |

Generate an RSA key of the specified length.

This method creates both the public key and corresponding private key. You almost certainly want to extract the public key part out - see PKey::toPublicKey for an easy way.

Key length is a tricky judgment - using less than 2048 is probably being too liberal for long term use. Don't use less than 1024 without serious analysis.

Parameters:

  | bits | the length of key that is required
  | exp | the exponent - typically 3, 17 or 65537
  | provider | the name of the provider to use, if a particular provider is required

DLGroup QCA::KeyGenerator::dlGroup | ( |  | ) | const

The current discrete logarithm group.

void QCA::KeyGenerator::finished | ( |  | ) | `[signal]`

Emitted when the key generation is complete.

This is only used in non-blocking mode

bool QCA::KeyGenerator::isBusy | ( |  | ) | const

Test if the key generator is currently busy, or not.

Returns:
  true if the key generator is busy generating a key already

PrivateKey QCA::KeyGenerator::key | ( |  | ) | const

Return the last generated key.

This is really only useful when you are working with non-blocking key generation

void QCA::KeyGenerator::setBlockingEnabled | ( | bool | b | ) |

Set whether the key generator is in blocking mode, nor not.

Parameters:

  | b | if true, the key generator will be set to operate in blocking mode, otherwise it will operate in non-blocking mode

See also:
  blockingEnabled()

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

- qca_publickey.h