|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QSslKey Class Reference
[QtNetwork module]

The QSslKey class provides an interface for private and public keys. More...

     #include <QSslKey>

Note: All the functions in this class are reentrant.

This class was introduced in Qt 4.3.

- List of all members, including inherited members

### Public Types

- enum Algorithm { Rsa, Dsa }
- enum Type { PrivateKey, PublicKey }

### Public Functions

- QSslKey ( const QByteArray & encoded = QByteArray() )
- QSslKey ( const QSslKey & other )
- ~QSslKey ()
- Algorithm algorithm () const
- void clear ()
- const uchar * data () const
- bool isNull () const
- int length () const
- QByteArray toDer ( const QByteArray & passPhrase = QByteArray() ) const
- QByteArray toPem ( const QByteArray & passPhrase = QByteArray() ) const
- Type type () const
- QSslKey & operator= ( const QSslKey & other )

### Static Public Members

- QPair<QSslKey, QSslKey> generateKeyPair ( Algorithm algorithm, int keyLength )

## Detailed Description

The QSslKey class provides an interface for private and public keys.

QSslKey provides a simple API for managing keys.

See also QSslSocket, QSslCertificate, and QSslCipher.

## Member Type Documentation

### enum QSslKey::Algorithm

Describes the algorithm for the key.

Constant | Value | Description
--- | --- | ---
`QSslKey::Rsa` | `0` | The RSA algorithm.
`QSslKey::Dsa` | `1` | The DSA algorithm.

### enum QSslKey::Type

Describes the two types of keys QSslKey supports.

Constant | Value | Description
--- | --- | ---
`QSslKey::PrivateKey` | `0` | A private key.
`QSslKey::PublicKey` | `1` | A public key.

## Member Function Documentation

### QSslKey::QSslKey ( const QByteArray & encoded = QByteArray() )

Constructs a QSslKey by parsing encoded. You can call isNull() later to check if encoded contained a valid key or not.

### QSslKey::QSslKey ( const QSslKey & other )

Constructs an identical copy of other.

### QSslKey::~QSslKey ()

Destroys the QSslKey object.

### Algorithm QSslKey::algorithm () const

Returns the key algorithm.

### void QSslKey::clear ()

Clears the contents of this key, making it a null key.

See also isNull().

### const uchar * QSslKey::data () const

Returns a pointer to key bits.

See also keyLength().

### QPair<QSslKey, QSslKey> QSslKey::generateKeyPair ( Algorithm algorithm, int keyLength ) `[static]`

Generates and returns a new pair of keys (the first is a PrivateKey, and the second is the PublicKey). algorithm specifies what algorithm to use when generting the keys, and keyLength specifies the number of bits.

This function can be time consuming, and will block the calling thread.

### bool QSslKey::isNull () const

Returns true if this is a null key; otherwise, false is returned.

See also clear().

### int QSslKey::length () const

Returns the length of the key in bits.

### QByteArray QSslKey::toDer ( const QByteArray & passPhrase = QByteArray() ) const

Returns the key in DER encoding, optionally encrypted and protected by passPhrase.

### QByteArray QSslKey::toPem ( const QByteArray & passPhrase = QByteArray() ) const

Returns the key in PEM encoding, optionally encrypted and protected by passPhrase.

### Type QSslKey::type () const

Returns the type of the key (i.e., PublicKey or PrivateKey).

### QSslKey & QSslKey::operator= ( const QSslKey & other )

Copies the contents of other into this key, making the two keys identical.

Returns a reference to this QSslKey.