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
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
4
5#ifndef QASN1ELEMENT_P_H
6#define QASN1ELEMENT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtNetwork/private/qtnetworkglobal_p.h>
20#include <QtCore/qdatetime.h>
21#include <QtCore/qmap.h>
22
24
25// General
26#define RSADSI_OID "1.2.840.113549."
27
28#define RSA_ENCRYPTION_OID QByteArrayLiteral(RSADSI_OID "1.1.1")
29#define DSA_ENCRYPTION_OID QByteArrayLiteral("1.2.840.10040.4.1")
30#define EC_ENCRYPTION_OID QByteArrayLiteral("1.2.840.10045.2.1")
31#define DH_ENCRYPTION_OID QByteArrayLiteral(RSADSI_OID "1.3.1")
32
33// These are mostly from the RFC for PKCS#5
34// PKCS#5: https://tools.ietf.org/html/rfc8018#appendix-B
35#define PKCS5_OID RSADSI_OID "1.5."
36// PKCS#12: https://tools.ietf.org/html/rfc7292#appendix-D)
37#define PKCS12_OID RSADSI_OID "1.12."
38
39// -PBES1
40#define PKCS5_MD2_DES_CBC_OID QByteArrayLiteral(PKCS5_OID "1") // Not (yet) implemented
41#define PKCS5_MD2_RC2_CBC_OID QByteArrayLiteral(PKCS5_OID "4") // Not (yet) implemented
42#define PKCS5_MD5_DES_CBC_OID QByteArrayLiteral(PKCS5_OID "3")
43#define PKCS5_MD5_RC2_CBC_OID QByteArrayLiteral(PKCS5_OID "6")
44#define PKCS5_SHA1_DES_CBC_OID QByteArrayLiteral(PKCS5_OID "10")
45#define PKCS5_SHA1_RC2_CBC_OID QByteArrayLiteral(PKCS5_OID "11")
46#define PKCS12_SHA1_RC4_128_OID QByteArrayLiteral(PKCS12_OID "1.1") // Not (yet) implemented
47#define PKCS12_SHA1_RC4_40_OID QByteArrayLiteral(PKCS12_OID "1.2") // Not (yet) implemented
48#define PKCS12_SHA1_3KEY_3DES_CBC_OID QByteArrayLiteral(PKCS12_OID "1.3")
49#define PKCS12_SHA1_2KEY_3DES_CBC_OID QByteArrayLiteral(PKCS12_OID "1.4")
50#define PKCS12_SHA1_RC2_128_CBC_OID QByteArrayLiteral(PKCS12_OID "1.5")
51#define PKCS12_SHA1_RC2_40_CBC_OID QByteArrayLiteral(PKCS12_OID "1.6")
52
53// -PBKDF2
54#define PKCS5_PBKDF2_ENCRYPTION_OID QByteArrayLiteral(PKCS5_OID "12")
55
56// -PBES2
57#define PKCS5_PBES2_ENCRYPTION_OID QByteArrayLiteral(PKCS5_OID "13")
58
59// Digest
60#define DIGEST_ALGORITHM_OID RSADSI_OID "2."
61// -HMAC-SHA-1
62#define HMAC_WITH_SHA1 QByteArrayLiteral(DIGEST_ALGORITHM_OID "7")
63// -HMAC-SHA-2
64#define HMAC_WITH_SHA224 QByteArrayLiteral(DIGEST_ALGORITHM_OID "8")
65#define HMAC_WITH_SHA256 QByteArrayLiteral(DIGEST_ALGORITHM_OID "9")
66#define HMAC_WITH_SHA384 QByteArrayLiteral(DIGEST_ALGORITHM_OID "10")
67#define HMAC_WITH_SHA512 QByteArrayLiteral(DIGEST_ALGORITHM_OID "11")
68#define HMAC_WITH_SHA512_224 QByteArrayLiteral(DIGEST_ALGORITHM_OID "12")
69#define HMAC_WITH_SHA512_256 QByteArrayLiteral(DIGEST_ALGORITHM_OID "13")
70
71// Encryption algorithms
72#define ENCRYPTION_ALGORITHM_OID RSADSI_OID "3."
73#define DES_CBC_ENCRYPTION_OID QByteArrayLiteral("1.3.14.3.2.7")
74#define DES_EDE3_CBC_ENCRYPTION_OID QByteArrayLiteral(ENCRYPTION_ALGORITHM_OID "7")
75#define RC2_CBC_ENCRYPTION_OID QByteArrayLiteral(ENCRYPTION_ALGORITHM_OID "2")
76#define RC5_CBC_ENCRYPTION_OID QByteArrayLiteral(ENCRYPTION_ALGORITHM_OID "9") // Not (yet) implemented
77#define AES_OID "2.16.840.1.101.3.4.1."
78#define AES128_CBC_ENCRYPTION_OID QByteArrayLiteral(AES_OID "2")
79#define AES192_CBC_ENCRYPTION_OID QByteArrayLiteral(AES_OID "22") // Not (yet) implemented
80#define AES256_CBC_ENCRYPTION_OID QByteArrayLiteral(AES_OID "42") // Not (yet) implemented
81
83{
84public:
86 // universal
91 NullType = 0x05,
99 SetType = 0x31,
100
101 // GeneralNameTypes
106
107 // context specific
110 Context3Type = 0xA3
111 };
112
114 bool read(QDataStream &data);
115 bool read(const QByteArray &data);
116 void write(QDataStream &data) const;
117
118 static QAsn1Element fromBool(bool val);
119 static QAsn1Element fromInteger(unsigned int val);
120 static QAsn1Element fromVector(const QList<QAsn1Element> &items);
121 static QAsn1Element fromObjectId(const QByteArray &id);
122
123 bool toBool(bool *ok = nullptr) const;
124 QDateTime toDateTime() const;
125 QMultiMap<QByteArray, QString> toInfo() const;
126 qint64 toInteger(bool *ok = nullptr) const;
127 QList<QAsn1Element> toList() const;
128 QByteArray toObjectId() const;
129 QByteArray toObjectName() const;
130 QString toString() const;
131
132 quint8 type() const { return mType; }
133 QByteArray value() const { return mValue; }
134
135 friend inline bool operator==(const QAsn1Element &, const QAsn1Element &);
136 friend inline bool operator!=(const QAsn1Element &, const QAsn1Element &);
137
138private:
139 quint8 mType;
140 QByteArray mValue;
141};
143
144inline bool operator==(const QAsn1Element &e1, const QAsn1Element &e2)
145{ return e1.mType == e2.mType && e1.mValue == e2.mValue; }
146
147inline bool operator!=(const QAsn1Element &e1, const QAsn1Element &e2)
148{ return e1.mType != e2.mType || e1.mValue != e2.mValue; }
149
151
152#endif
@ UniformResourceIdentifierType
QByteArray toObjectName() const
QMultiMap< QByteArray, QString > toInfo() const
QDateTime toDateTime() const
bool read(QDataStream &data)
qint64 toInteger(bool *ok=nullptr) const
static QAsn1Element fromVector(const QList< QAsn1Element > &items)
static QAsn1Element fromObjectId(const QByteArray &id)
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 &)
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
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
bool operator!=(const QAsn1Element &e1, const QAsn1Element &e2)
bool operator==(const QAsn1Element &e1, const QAsn1Element &e2)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLuint GLfloat * val
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
long long qint64
Definition qtypes.h:60
unsigned char quint8
Definition qtypes.h:46
QList< QTreeWidgetItem * > items