CopperSpice API  1.9.1
QSslKey Class Reference

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

Public Methods

 QSslKey ()
 
 QSslKey (const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format=QSsl::Pem, QSsl::KeyType type=QSsl::PrivateKey, const QByteArray &passPhrase=QByteArray ())
 
 QSslKey (const QSslKey &other)
 
 QSslKey (QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format=QSsl::Pem, QSsl::KeyType type=QSsl::PrivateKey, const QByteArray &passPhrase=QByteArray ())
 
 ~QSslKey ()
 
QSsl::KeyAlgorithm algorithm () const
 
void clear ()
 
Qt::HANDLE handle () const
 
bool isNull () const
 
int length () const
 
bool operator!= (const QSslKey &other) const
 
QSslKey & operator= (const QSslKey &other)
 
QSslKey & operator= (QSslKey &&other)
 
bool operator== (const QSslKey &other) const
 
void swap (QSslKey &other)
 
QByteArray toDer (const QByteArray &passPhrase=QByteArray ()) const
 
QByteArray toPem (const QByteArray &passPhrase=QByteArray ()) const
 
QSsl::KeyType type () const
 

Friends

class QSslCertificate
 

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, QSslCipher

Constructor & Destructor Documentation

QSslKey::QSslKey ( )

Constructs an empty QSslKey.

See also
isNull()
QSslKey::QSslKey ( const QByteArray encoded,
QSsl::KeyAlgorithm  algorithm,
QSsl::EncodingFormat  format = QSsl::Pem,
QSsl::KeyType  type = QSsl::PrivateKey,
const QByteArray passPhrase = QByteArray() 
)

Constructs a QSslKey by decoding the string in encoded using a specified algorithm and format. If the encoded key is encrypted, passPhrase is used to decrypt it. The type specifies whether the key is public or private.

After construction, use isNull() to check if encoded contained a valid key.

QSslKey::QSslKey ( QIODevice device,
QSsl::KeyAlgorithm  algorithm,
QSsl::EncodingFormat  format = QSsl::Pem,
QSsl::KeyType  type = QSsl::PrivateKey,
const QByteArray passPhrase = QByteArray() 
)

Constructs a QSslKey by reading and decoding data from a device using a specified algorithm and format format. If the encoded key is encrypted, passPhrase is used to decrypt it. The type specifies whether the key is public or private.

After construction, use isNull() to check if device provided a valid key.

QSslKey::QSslKey ( const QSslKey &  other)

Copy constructs a new QSslKey from other.

QSslKey::~QSslKey ( )

Destroys the QSslKey object.

Method Documentation

QSsl::KeyAlgorithm QSslKey::algorithm ( ) const

Returns the key algorithm.

void QSslKey::clear ( )

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

See also
isNull()
Qt::HANDLE QSslKey::handle ( ) const

Returns a pointer to the native key handle, if it is available, otherwise a null pointer is returned. You can use this handle together with the native API to access extended information about the key.

Warning
Use of this method has a high probability of being non-portable, and its return value may vary across platforms.
bool QSslKey::isNull ( ) const

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

See also
clear()
int QSslKey::length ( ) const

Returns the length of the key in bits, or -1 if the key is null.

bool QSslKey::operator!= ( const QSslKey &  other) const
inline

Returns true if this key is not equal to key other, otherwise returns false.

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

Copy assigns from other and returns a reference to this object.

QSslKey & QSslKey::operator= ( QSslKey &&  other)
inline

Move assigns from other and returns a reference to this object.

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

Returns true if this key is equal to other, otherwise returns false.

void QSslKey::swap ( QSslKey &  other)
inline

Swaps other with this object. This operation is very fast and never fails.

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

Returns the key in DER encoding. The result is encrypted with passPhrase if the key is a private key and passPhrase is non-empty.

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

Returns the key in PEM encoding. The result is encrypted with passPhrase if the key is a private key and passPhrase is non-empty.

QSsl::KeyType QSslKey::type ( ) const

Returns the type of the key, PublicKey or PrivateKey.