Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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 36 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 774 of file qtlskey_generic.cpp.

References QByteArray::clear(), QByteArray::data(), QTlsPrivate::TlsKeyBase::keyIsNull, and QByteArray::size().

+ Here is the call graph for this function:

◆ 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 517 of file qtlskey_generic.cpp.

References QTlsPrivate::TlsKeyBase::algorithm(), QAsn1Element::BitStringType, clear(), QAsn1Element::Context0Type, QAsn1Element::Context1Type, QSsl::Dh, DH_ENCRYPTION_OID, QSsl::Dsa, DSA_ENCRYPTION_OID, QSsl::Ec, EC_ENCRYPTION_OID, QAsn1Element::IntegerType, QList< T >::isEmpty(), items, QTlsPrivate::TlsKeyBase::keyAlgorithm, QTlsPrivate::TlsKeyBase::keyIsNull, QTlsPrivate::TlsKeyBase::keyType, QAsn1Element::ObjectIdentifierType, QAsn1Element::OctetStringType, QSsl::PublicKey, QSsl::Rsa, RSA_ENCRYPTION_OID, QAsn1Element::SequenceType, QList< T >::size(), QList< T >::toList(), QTlsPrivate::TlsKeyBase::type(), and QList< T >::value().

Referenced by decodePem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 638 of file qtlskey_generic.cpp.

References QTlsPrivate::Aes128Cbc, QTlsPrivate::Aes192Cbc, QTlsPrivate::Aes256Cbc, QTlsPrivate::TlsKeyBase::algorithm(), clear(), decodeDer(), QTlsPrivate::TlsKey::decrypt(), derFromPem(), QTlsPrivate::DesCbc, QTlsPrivate::DesEde3Cbc, QByteArray::fromHex(), QTlsPrivate::TlsKeyBase::keyAlgorithm, QTlsPrivate::TlsKeyBase::keyType, QTlsPrivate::Rc2Cbc, and QTlsPrivate::TlsKeyBase::type().

+ Here is the call graph for this function:

◆ 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 703 of file qtlskey_generic.cpp.

References QByteArray::fromBase64(), header(), i, j, QByteArray::mid(), QTlsPrivate::TlsKey::pemFooter(), QTlsPrivate::TlsKey::pemHeader(), QTlsPrivate::TlsKeyBase::pkcs8Footer(), QTlsPrivate::TlsKeyBase::pkcs8Header(), QSsl::PublicKey, QByteArray(), QByteArray::size(), QByteArray::trimmed(), and QTlsPrivate::TlsKeyBase::type().

Referenced by decodePem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 768 of file qtlskey_generic.cpp.

References handle(), and QTlsPrivate::TlsKeyBase::keyType.

+ Here is the call graph for this function:

◆ 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 55 of file qtlskey_generic_p.h.

Referenced by fromHandle().

+ Here is the caller graph for this function:

◆ 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 65 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 60 of file qtlskey_generic_p.h.

◆ TlsKeyBase()

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

Definition at line 33 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 680 of file qtlskey_generic.cpp.

References QTlsPrivate::DesEde3Cbc, QTlsPrivate::TlsKey::encrypt(), QByteArray::fromRawData(), QTlsPrivate::TlsKeyBase::pemFromDer(), QSsl::PrivateKey, QRandomGenerator::system(), and QTlsPrivate::TlsKeyBase::type().

+ Here is the call graph for this function:

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