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
qasn1element_p.h
Go to the documentation of this file.
1// Copyright (C) 2014 Jeremy Lainé <jeremy.laine@m4x.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QASN1ELEMENT_P_H
7#define QASN1ELEMENT_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtNetwork/private/qtnetworkglobal_p.h>
21#include <QtCore/qdatetime.h>
22#include <QtCore/qmap.h>
23
25
26// General
27#define RSADSI_OID "1.2.840.113549."
28
29#define RSA_ENCRYPTION_OID QByteArrayLiteral(RSADSI_OID "1.1.1")
30#define DSA_ENCRYPTION_OID QByteArrayLiteral("1.2.840.10040.4.1")
31#define EC_ENCRYPTION_OID QByteArrayLiteral("1.2.840.10045.2.1")
32#define DH_ENCRYPTION_OID QByteArrayLiteral(RSADSI_OID "1.3.1")
33
34// ML-DSA
35// https://datatracker.ietf.org/doc/html/draft-ietf-lamps-dilithium-certificates
36#define MLDSA_OID "2.16.840.1.101.3.4.3.17."
37
38#define MLDSA_44_ENCRYPTION_OID QByteArrayLiteral(MLDSA_OID "17")
39#define MLDSA_65_ENCRYPTION_OID QByteArrayLiteral(MLDSA_OID "18")
40#define MLDSA_87_ENCRYPTION_OID QByteArrayLiteral(MLDSA_OID "19")
41
42// These are mostly from the RFC for PKCS#5
43// PKCS#5: https://tools.ietf.org/html/rfc8018#appendix-B
44#define PKCS5_OID RSADSI_OID "1.5."
45// PKCS#12: https://tools.ietf.org/html/rfc7292#appendix-D)
46#define PKCS12_OID RSADSI_OID "1.12."
47
48// -PBES1
49#define PKCS5_MD2_DES_CBC_OID QByteArrayLiteral(PKCS5_OID "1") // Not (yet) implemented
50#define PKCS5_MD2_RC2_CBC_OID QByteArrayLiteral(PKCS5_OID "4") // Not (yet) implemented
51#define PKCS5_MD5_DES_CBC_OID QByteArrayLiteral(PKCS5_OID "3")
52#define PKCS5_MD5_RC2_CBC_OID QByteArrayLiteral(PKCS5_OID "6")
53#define PKCS5_SHA1_DES_CBC_OID QByteArrayLiteral(PKCS5_OID "10")
54#define PKCS5_SHA1_RC2_CBC_OID QByteArrayLiteral(PKCS5_OID "11")
55#define PKCS12_SHA1_RC4_128_OID QByteArrayLiteral(PKCS12_OID "1.1") // Not (yet) implemented
56#define PKCS12_SHA1_RC4_40_OID QByteArrayLiteral(PKCS12_OID "1.2") // Not (yet) implemented
57#define PKCS12_SHA1_3KEY_3DES_CBC_OID QByteArrayLiteral(PKCS12_OID "1.3")
58#define PKCS12_SHA1_2KEY_3DES_CBC_OID QByteArrayLiteral(PKCS12_OID "1.4")
59#define PKCS12_SHA1_RC2_128_CBC_OID QByteArrayLiteral(PKCS12_OID "1.5")
60#define PKCS12_SHA1_RC2_40_CBC_OID QByteArrayLiteral(PKCS12_OID "1.6")
61
62// -PBKDF2
63#define PKCS5_PBKDF2_ENCRYPTION_OID QByteArrayLiteral(PKCS5_OID "12")
64
65// -PBES2
66#define PKCS5_PBES2_ENCRYPTION_OID QByteArrayLiteral(PKCS5_OID "13")
67
68// Digest
69#define DIGEST_ALGORITHM_OID RSADSI_OID "2."
70// -HMAC-SHA-1
71#define HMAC_WITH_SHA1 QByteArrayLiteral(DIGEST_ALGORITHM_OID "7")
72// -HMAC-SHA-2
73#define HMAC_WITH_SHA224 QByteArrayLiteral(DIGEST_ALGORITHM_OID "8")
74#define HMAC_WITH_SHA256 QByteArrayLiteral(DIGEST_ALGORITHM_OID "9")
75#define HMAC_WITH_SHA384 QByteArrayLiteral(DIGEST_ALGORITHM_OID "10")
76#define HMAC_WITH_SHA512 QByteArrayLiteral(DIGEST_ALGORITHM_OID "11")
77#define HMAC_WITH_SHA512_224 QByteArrayLiteral(DIGEST_ALGORITHM_OID "12")
78#define HMAC_WITH_SHA512_256 QByteArrayLiteral(DIGEST_ALGORITHM_OID "13")
79
80// Encryption algorithms
81#define ENCRYPTION_ALGORITHM_OID RSADSI_OID "3."
82#define DES_CBC_ENCRYPTION_OID QByteArrayLiteral("1.3.14.3.2.7")
83#define DES_EDE3_CBC_ENCRYPTION_OID QByteArrayLiteral(ENCRYPTION_ALGORITHM_OID "7")
84#define RC2_CBC_ENCRYPTION_OID QByteArrayLiteral(ENCRYPTION_ALGORITHM_OID "2")
85#define RC5_CBC_ENCRYPTION_OID QByteArrayLiteral(ENCRYPTION_ALGORITHM_OID "9") // Not (yet) implemented
86#define AES_OID "2.16.840.1.101.3.4.1."
87#define AES128_CBC_ENCRYPTION_OID QByteArrayLiteral(AES_OID "2")
88#define AES192_CBC_ENCRYPTION_OID QByteArrayLiteral(AES_OID "22") // Not (yet) implemented
89#define AES256_CBC_ENCRYPTION_OID QByteArrayLiteral(AES_OID "42") // Not (yet) implemented
90
92{
93public:
95 // universal
100 NullType = 0x05,
108 SetType = 0x31,
109
110 // GeneralNameTypes
115
116 // context specific
120 };
121
122 explicit QAsn1Element(quint8 type = 0, const QByteArray &value = QByteArray());
123 bool read(QDataStream &data);
124 bool read(const QByteArray &data);
125 void write(QDataStream &data) const;
126
127 static QAsn1Element fromBool(bool val);
128 static QAsn1Element fromInteger(unsigned int val);
129 static QAsn1Element fromVector(const QList<QAsn1Element> &items);
130 static QAsn1Element fromObjectId(const QByteArray &id);
131
132 bool toBool(bool *ok = nullptr) const;
133 QDateTime toDateTime() const;
135 qint64 toInteger(bool *ok = nullptr) const;
136 QList<QAsn1Element> toList() const;
137 QByteArray toObjectId() const;
138 QByteArray toObjectName() const;
139 QString toString() const;
140
141 quint8 type() const { return mType; }
142 QByteArray value() const { return mValue; }
143
144 friend inline bool operator==(const QAsn1Element &, const QAsn1Element &);
145 friend inline bool operator!=(const QAsn1Element &, const QAsn1Element &);
146
147private:
148 quint8 mType;
149 QByteArray mValue;
150};
152
153inline bool operator==(const QAsn1Element &e1, const QAsn1Element &e2)
154{ return e1.mType == e2.mType && e1.mValue == e2.mValue; }
155
156inline bool operator!=(const QAsn1Element &e1, const QAsn1Element &e2)
157{ return e1.mType != e2.mType || e1.mValue != e2.mValue; }
158
159QT_END_NAMESPACE
160
161#endif
@ UniformResourceIdentifierType
QByteArray toObjectName() const
QMultiMap< QByteArray, QString > toInfo() const
QDateTime toDateTime() const
bool read(QDataStream &data)
bool read(const QByteArray &data)
qint64 toInteger(bool *ok=nullptr) const
static QAsn1Element fromVector(const QList< QAsn1Element > &items)
static QAsn1Element fromObjectId(const QByteArray &id)
friend bool operator!=(const QAsn1Element &, const QAsn1Element &)
void write(QDataStream &data) const
static QAsn1Element fromInteger(unsigned int val)
QAsn1Element(quint8 type=0, const QByteArray &value=QByteArray())
friend bool operator==(const QAsn1Element &, const QAsn1Element &)
QString toString() const
QByteArray toObjectId() const
bool toBool(bool *ok=nullptr) const
static QAsn1Element fromBool(bool val)
QList< QAsn1Element > toList() const
QByteArray value() const
quint8 type() const
void init(QSslSocket *q, QSslSocketPrivate *d) override
QSsl::SslProtocol sessionProtocol() const override
bool hasUndecryptedData() const override
QSslCipher sessionCipher() const override
QList< QSslError > tlsErrors() const override
QByteArray derFromPem(const QByteArray &pem, QMap< QByteArray, QByteArray > *headers) const override
bool isPkcs8() const override
QByteArray toPem(const QByteArray &passPhrase) const override
int length() const override
void decodePem(KeyType type, KeyAlgorithm algorithm, const QByteArray &pem, const QByteArray &passPhrase, bool deepClear) override
void fromHandle(Qt::HANDLE opaque, KeyType expectedType) override
Qt::HANDLE handle() const override
void clear(bool deep) override
void decodeDer(KeyType type, KeyAlgorithm algorithm, const QByteArray &der, const QByteArray &passPhrase, bool deepClear) override
QByteArray decrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) const override
QByteArray encrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) const override
TlsKey * publicKey() const override
Qt::HANDLE handle() const override
static bool importPkcs12(QIODevice *device, QSslKey *key, QSslCertificate *cert, QList< QSslCertificate > *caCertificates, const QByteArray &passPhrase)
Q_DISABLE_COPY_MOVE(X509CertificateSchannel)
static QSslCertificate QSslCertificate_from_CERT_CONTEXT(const CERT_CONTEXT *certificateContext)
Namespace containing onternal types that TLS backends implement.
QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED std::array< SchannelCipherInfo, 44 > schannelCipherInfo
QList< QSslCipher > defaultCiphers()
UNICODE_STRING cbcChainingMode
QList< CRYPTO_SETTINGS > cryptoSettingsForCiphers(const QList< QSslCipher > &ciphers)
bool containsTls13Cipher(const QList< QSslCipher > &ciphers)
UNICODE_STRING gcmChainingMode
QList< QSslCipher > ciphersByName(QStringView schannelSuiteName)
static void attachPrivateKeyToCertificate(const QSslCertificate &certificate, const QSslKey &privateKey)
#define PKCS5_OID
#define PKCS12_OID
Q_DECLARE_TYPEINFO(QAsn1Element, Q_RELOCATABLE_TYPE)
#define AES_OID
#define ENCRYPTION_ALGORITHM_OID
#define RSADSI_OID
#define MLDSA_OID
#define DIGEST_ALGORITHM_OID
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)
QT_REQUIRE_CONFIG(thread)
#define SP_PROT_TLS1_0_SERVER
#define SP_PROT_TLS1_1_SERVER
#define SP_PROT_TLS1_2_SERVER
#define BCRYPT_ECDSA_ALGORITHM
#define SP_PROT_TLS1_2
#define SP_PROT_TLS1_3_SERVER
#define MAP_PROTOCOL(sp_protocol, q_protocol)
#define SP_PROT_TLS1_0
#define SP_PROT_TLS1_3
#define CHECK_STATUS(status)
#define CHECK_ATTRIBUTE(attributeName)
#define DEBUG_WARN(message)
QByteArray _q_makePkcs12(const QList< QSslCertificate > &certs, const QSslKey &key, const QString &passPhrase)
#define SP_PROT_TLS1_1_CLIENT
#define SP_PROT_TLS1_SERVER
QAsn1Element _q_PKCS12_key(const QSslKey &key)
#define BCRYPT_ECDH_ALGORITHM
#define SP_PROT_TLS1_3_CLIENT
#define SP_PROT_TLS1_1
#define SEC_E_APPLICATION_PROTOCOL_MISMATCH
#define SP_PROT_TLS1_CLIENT
#define SP_PROT_TLS1_0_CLIENT
#define SECBUFFER_ALERT
#define SP_PROT_TLS1_2_CLIENT
std::unique_ptr< void, QHCertStoreDeleter > QHCertStorePointer
Definition qwincrypt_p.h:42
QList< QSsl::SslProtocol > protocols