Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QTlsPrivate::TlsKeyGeneric Class Reference

#include <qtlskey_generic_p.h>

Inheritance diagram for QTlsPrivate::TlsKeyGeneric:
Collaboration diagram for QTlsPrivate::TlsKeyGeneric:

Public Member Functions

void decodeDer (KeyType type, KeyAlgorithm algorithm, const QByteArray &der, const QByteArray &passPhrase, bool deepClear) override
void decodePem (KeyType type, KeyAlgorithm algorithm, const QByteArray &pem, const QByteArray &passPhrase, bool deepClear) override
QByteArray toPem (const QByteArray &passPhrase) const override
QByteArray derFromPem (const QByteArray &pem, QMap< QByteArray, QByteArray > *headers) const override
void fromHandle (Qt::HANDLE opaque, KeyType expectedType) override
void clear (bool deep) override
Qt::HANDLE handle () const override
int length () const override
bool isPkcs8 () const override
 TlsKeyBase (KeyType type=QSsl::PublicKey, KeyAlgorithm algorithm=QSsl::Opaque)
Public Member Functions inherited from QTlsPrivate::TlsKeyBase
 TlsKeyBase (KeyType type=QSsl::PublicKey, KeyAlgorithm algorithm=QSsl::Opaque)
bool isNull () const override
KeyType type () const override
KeyAlgorithm algorithm () const override
QByteArray pemFromDer (const QByteArray &der, const QMap< QByteArray, QByteArray > &headers) const override
Public Member Functions inherited from QTlsPrivate::TlsKey
 TlsKey ()=default
virtual ~TlsKey ()
virtual QByteArray decrypt (Cipher cipher, const QByteArray &data, const QByteArray &passPhrase, const QByteArray &iv) const =0
virtual QByteArray encrypt (Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) const =0
QByteArray pemHeader () const
QByteArray pemFooter () const

Additional Inherited Members

Public Types inherited from QTlsPrivate::TlsKey
using KeyType = QSsl::KeyType
using KeyAlgorithm = QSsl::KeyAlgorithm
Static Protected Member Functions inherited from QTlsPrivate::TlsKeyBase
static QByteArray pkcs8Header (bool encrypted)
static QByteArray pkcs8Footer (bool encrypted)
static bool isEncryptedPkcs8 (const QByteArray &der)
Protected Attributes inherited from QTlsPrivate::TlsKeyBase
bool keyIsNull = true
KeyType keyType = QSsl::PublicKey
KeyAlgorithm keyAlgorithm = QSsl::Opaque

Detailed Description

Definition at line 37 of file qtlskey_generic_p.h.

Member Function Documentation

◆ clear()

void QTlsPrivate::TlsKeyGeneric::clear ( bool deep)
overridevirtual

Clears the contents of this key, making it a null key. The meaning of deep is implementation-specific (e.g. if some internal objects representing a key can be shared using reference counting, deep equal to true would imply decrementing a reference count).

See also
isNull()

Implements QTlsPrivate::TlsKey.

Definition at line 773 of file qtlskey_generic.cpp.

References QTlsPrivate::TlsKeyBase::keyIsNull.

◆ decodeDer()

void QTlsPrivate::TlsKeyGeneric::decodeDer ( QSsl::KeyType type,
QSsl::KeyAlgorithm algorithm,
const QByteArray & der,
const QByteArray & passPhrase,
bool deepClear )
overridevirtual

If a support of public and private keys in DER format is required, this function must be overridden and should initialize this key using the type, algorithm, der and passPhrase. If this key was initialized previously, deepClear has an implementation-specific meaning (e.g., if an implementation is using reference-counting and can share internally some data structures, a value true may trigger decrementing a reference counter on some implementation-specific object).

Note
An empty overrider is sufficient, but then reading keys in QSsl::Der format will not be supported.
See also
isNull(), QSsl::KeyType, QSsl::EncodingFormat, QSsl::KeyAlgorithm

Implements QTlsPrivate::TlsKey.

Definition at line 516 of file qtlskey_generic.cpp.

◆ decodePem()

void QTlsPrivate::TlsKeyGeneric::decodePem ( QSsl::KeyType type,
QSsl::KeyAlgorithm algorithm,
const QByteArray & pem,
const QByteArray & passPhrase,
bool deepClear )
overridevirtual

If a support of public and private keys in PEM format is required, this function must be overridden and should initialize this key using the type, algorithm, pem and passPhrase. If this key was initialized previously, deepClear has an implementation-specific meaning (e.g., in an implementation using reference-counting, a value true may trigger decrementing a reference counter on some implementation-specific object).

Note
An empty overrider is sufficient, but then reading keys in QSsl::Pem format will not be supported.
See also
isNull(), QSsl::KeyType, QSsl::EncodingFormat, QSsl::KeyAlgorithm

Implements QTlsPrivate::TlsKey.

Definition at line 637 of file qtlskey_generic.cpp.

◆ derFromPem()

QByteArray QTlsPrivate::TlsKeyGeneric::derFromPem ( const QByteArray & pem,
QMap< QByteArray, QByteArray > * headers ) const
overridevirtual

Converts pem to DER format, using this key's type and algorithm. The parameter headers must be a valid, non-null pointer. When parsing pem, the headers found there will be saved into headers.

Note
An overrider returning an empty QByteArray is sufficient, if QSslKey::toDer() is not needed.
This function is very implementation-specific. A backend, that already has this key's non-empty DER data, may simply return this data.
See also
QSslKey::toDer()

Implements QTlsPrivate::TlsKey.

Definition at line 702 of file qtlskey_generic.cpp.

◆ fromHandle()

void QTlsPrivate::TlsKeyGeneric::fromHandle ( Qt::HANDLE handle,
KeyType type )
overridevirtual

Initializes this key using the handle and type, taking the ownership of the handle.

Note
The meaning of the handle is implementation-specific.
If a TLS backend does not support such keys, it must provide an empty implementation.
See also
handle(), QSslKey::QSslKey(), QSslKet::handle()

Implements QTlsPrivate::TlsKey.

Definition at line 767 of file qtlskey_generic.cpp.

◆ handle()

Qt::HANDLE QTlsPrivate::TlsKeyGeneric::handle ( ) const
inlineoverridevirtual

If a TLS backend supports opaque keys, returns a native handle that this key was initialized with.

See also
fromHandle(), QSslKey::handle()

Implements QTlsPrivate::TlsKey.

Definition at line 56 of file qtlskey_generic_p.h.

◆ isPkcs8()

bool QTlsPrivate::TlsKeyGeneric::isPkcs8 ( ) const
inlineoverridevirtual

This function is internally used only by Qt's own TLS plugins and affects the way PEM file is generated by TlsKey. It's sufficient to override it and return false in case a new TLS backend is not using Qt's plugin as a base.

Reimplemented from QTlsPrivate::TlsKeyBase.

Definition at line 66 of file qtlskey_generic_p.h.

◆ length()

int QTlsPrivate::TlsKeyGeneric::length ( ) const
inlineoverridevirtual

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

Implements QTlsPrivate::TlsKey.

Definition at line 61 of file qtlskey_generic_p.h.

◆ TlsKeyBase()

QTlsPrivate::TlsKeyBase::TlsKeyBase ( KeyType type = QSsl::PublicKey,
KeyAlgorithm algorithm = QSsl::Opaque )
inline

Definition at line 34 of file qtlskey_base_p.h.

◆ toPem()

QByteArray QTlsPrivate::TlsKeyGeneric::toPem ( const QByteArray & passPhrase) const
overridevirtual

This function must be overridden, if converting a key to PEM format, potentially with encryption, is needed (e.g. to save a QSslKey into a file). If this key is private and passPhrase is not empty, the key's data is expected to be encrypted using some conventional encryption algorithm (e.g. DES or AES - the one that different tools or even the class QSslKey can understand later).

Note
If this particular functionality is not needed, an overrider returning an empty QByteArray is sufficient.
See also
QSslKey::toPem()

Implements QTlsPrivate::TlsKey.

Definition at line 679 of file qtlskey_generic.cpp.


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