![]() |
Qt 6.x
The Qt SDK
|
#include <qtlskey_generic_p.h>
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) | |
![]() | |
TlsKeyBase (KeyType type=QSsl::PublicKey, KeyAlgorithm algorithm=QSsl::Opaque) | |
bool | isNull () const override |
KeyType | type () const override |
KeyAlgorithm | algorithm () const override |
bool | isPkcs8 () const override |
QByteArray | pemFromDer (const QByteArray &der, const QMap< QByteArray, QByteArray > &headers) const override |
![]() | |
virtual | ~TlsKey () |
virtual void | decodeDer (KeyType type, KeyAlgorithm algorithm, const QByteArray &der, const QByteArray &passPhrase, bool deepClear)=0 |
virtual void | decodePem (KeyType type, KeyAlgorithm algorithm, const QByteArray &pem, const QByteArray &passPhrase, bool deepClear)=0 |
virtual QByteArray | toPem (const QByteArray &passPhrase) const =0 |
virtual QByteArray | derFromPem (const QByteArray &pem, QMap< QByteArray, QByteArray > *headers) const =0 |
virtual QByteArray | pemFromDer (const QByteArray &der, const QMap< QByteArray, QByteArray > &headers) const =0 |
virtual void | fromHandle (Qt::HANDLE handle, KeyType type)=0 |
virtual Qt::HANDLE | handle () const =0 |
virtual bool | isNull () const =0 |
virtual KeyType | type () const =0 |
virtual KeyAlgorithm | algorithm () const =0 |
virtual int | length () const =0 |
virtual void | clear (bool deepClear)=0 |
virtual bool | isPkcs8 () const =0 |
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 | |
![]() | |
using | KeyType = QSsl::KeyType |
using | KeyAlgorithm = QSsl::KeyAlgorithm |
![]() | |
static QByteArray | pkcs8Header (bool encrypted) |
static QByteArray | pkcs8Footer (bool encrypted) |
static bool | isEncryptedPkcs8 (const QByteArray &der) |
![]() | |
bool | keyIsNull = true |
KeyType | keyType = QSsl::PublicKey |
KeyAlgorithm | keyAlgorithm = QSsl::Opaque |
Definition at line 36 of file qtlskey_generic_p.h.
|
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).
Implements QTlsPrivate::TlsKey.
Definition at line 774 of file qtlskey_generic.cpp.
References QByteArray::clear(), QByteArray::data(), QTlsPrivate::TlsKeyBase::keyIsNull, and QByteArray::size().
|
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).
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, QByteArray::isEmpty(), QList< T >::isEmpty(), items, QTlsPrivate::TlsKeyBase::keyAlgorithm, QTlsPrivate::TlsKeyBase::keyIsNull, QTlsPrivate::TlsKeyBase::keyType, QByteArray::mid(), QAsn1Element::ObjectIdentifierType, QAsn1Element::OctetStringType, QSsl::PublicKey, QAsn1Element::read(), QSsl::Rsa, RSA_ENCRYPTION_OID, QAsn1Element::SequenceType, QList< T >::size(), QAsn1Element::toList(), QAsn1Element::toObjectId(), QAsn1Element::type(), QTlsPrivate::TlsKeyBase::type(), QAsn1Element::value(), and QList< T >::value().
Referenced by decodePem().
|
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).
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, QList< T >::first(), QByteArray::fromHex(), QTlsPrivate::TlsKeyBase::keyAlgorithm, QTlsPrivate::TlsKeyBase::keyType, QList< T >::last(), QTlsPrivate::Rc2Cbc, QList< T >::size(), QTlsPrivate::TlsKeyBase::type(), and QMap< Key, T >::value().
|
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.
Implements QTlsPrivate::TlsKey.
Definition at line 703 of file qtlskey_generic.cpp.
References QByteArray::at(), QByteArray::contains(), QByteArray::fromBase64(), header(), i, QByteArray::indexOf(), QMap< Key, T >::insert(), j, QString::length(), QByteArray::length(), QByteArray::mid(), QTlsPrivate::TlsKey::pemFooter(), QTlsPrivate::TlsKey::pemHeader(), QTlsPrivate::TlsKeyBase::pkcs8Footer(), QTlsPrivate::TlsKeyBase::pkcs8Header(), QSsl::PublicKey, QString::size(), QByteArray::size(), QByteArray::trimmed(), and QTlsPrivate::TlsKeyBase::type().
Referenced by decodePem().
|
overridevirtual |
Initializes this key using the handle and type, taking the ownership of the handle.
Implements QTlsPrivate::TlsKey.
Definition at line 768 of file qtlskey_generic.cpp.
References handle(), and QTlsPrivate::TlsKeyBase::keyType.
|
inlineoverridevirtual |
If a TLS backend supports opaque keys, returns a native handle that this key was initialized with.
Implements QTlsPrivate::TlsKey.
Definition at line 55 of file qtlskey_generic_p.h.
Referenced by fromHandle().
|
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.
|
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.
|
inline |
Definition at line 33 of file qtlskey_base_p.h.
|
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).
Implements QTlsPrivate::TlsKey.
Definition at line 680 of file qtlskey_generic.cpp.
References QTlsPrivate::DesEde3Cbc, QTlsPrivate::TlsKey::encrypt(), QByteArray::fromRawData(), QRandomGenerator::generate64(), QMap< Key, T >::insert(), QByteArray::isEmpty(), QTlsPrivate::TlsKeyBase::pemFromDer(), QSsl::PrivateKey, QRandomGenerator::system(), QByteArray::toHex(), and QTlsPrivate::TlsKeyBase::type().