26 oids.insert(oids.cend(), QByteArrayLiteral(
"0.9.2342.19200300.100.1.5"), QByteArrayLiteral(
"favouriteDrink"));
27 oids.insert(oids.cend(), QByteArrayLiteral(
"1.2.840.113549.1.9.1"), QByteArrayLiteral(
"emailAddress"));
28 oids.insert(oids.cend(), QByteArrayLiteral(
"1.3.6.1.5.5.7.1.1"), QByteArrayLiteral(
"authorityInfoAccess"));
29 oids.insert(oids.cend(), QByteArrayLiteral(
"1.3.6.1.5.5.7.48.1"), QByteArrayLiteral(
"OCSP"));
30 oids.insert(oids.cend(), QByteArrayLiteral(
"1.3.6.1.5.5.7.48.2"), QByteArrayLiteral(
"caIssuers"));
31 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.29.14"), QByteArrayLiteral(
"subjectKeyIdentifier"));
32 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.29.15"), QByteArrayLiteral(
"keyUsage"));
33 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.29.17"), QByteArrayLiteral(
"subjectAltName"));
34 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.29.19"), QByteArrayLiteral(
"basicConstraints"));
35 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.29.35"), QByteArrayLiteral(
"authorityKeyIdentifier"));
36 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.10"), QByteArrayLiteral(
"O"));
37 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.11"), QByteArrayLiteral(
"OU"));
38 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.12"), QByteArrayLiteral(
"title"));
39 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.13"), QByteArrayLiteral(
"description"));
40 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.17"), QByteArrayLiteral(
"postalCode"));
41 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.3"), QByteArrayLiteral(
"CN"));
42 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.4"), QByteArrayLiteral(
"SN"));
43 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.41"), QByteArrayLiteral(
"name"));
44 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.42"), QByteArrayLiteral(
"GN"));
45 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.43"), QByteArrayLiteral(
"initials"));
46 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.46"), QByteArrayLiteral(
"dnQualifier"));
47 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.5"), QByteArrayLiteral(
"serialNumber"));
48 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.6"), QByteArrayLiteral(
"C"));
49 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.7"), QByteArrayLiteral(
"L"));
50 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.8"), QByteArrayLiteral(
"ST"));
51 oids.insert(oids.cend(), QByteArrayLiteral(
"2.5.4.9"), QByteArrayLiteral(
"street"));
76 const quint8 bytes = (first & 0x7f);
81 for (
int i = 0; i < bytes; i++) {
83 length = (length << 8) | b;
87 length = (first & 0x7f);
90 if (length > quint64(
std::numeric_limits<
int>::max()))
94 const int BUFFERSIZE = 4 * 1024;
96 int remainingLength = length;
97 while (remainingLength) {
98 char readBuffer[BUFFERSIZE];
99 const int bytesToRead = qMin(remainingLength, BUFFERSIZE);
100 const int count = stream.readRawData(readBuffer, bytesToRead);
101 if (count !=
int(bytesToRead))
103 tmpValue.append(readBuffer, bytesToRead);
104 remainingLength -= bytesToRead;
108 mValue.swap(tmpValue);
124 qint64 length = mValue.size();
127 quint8 encodedLength = 0x80;
130 ba.prepend(quint8((length & 0xff)));
134 stream << encodedLength;
135 stream.writeRawData(ba.data(), ba.size());
138 stream << quint8(length);
142 stream.writeRawData(mValue.data(), mValue.size());
176 const QList<QByteArray> bits = id.split(
'.');
177 Q_ASSERT(bits.size() > 2);
178 elem.mValue += quint8((bits[0].toUInt() * 40 + bits[1].toUInt()));
179 for (
int i = 2; i < bits.size(); ++i) {
180 char buffer[
std::numeric_limits<
unsigned int>::digits / 7 + 2];
181 char *pBuffer = buffer +
sizeof(buffer);
183 unsigned int node = bits[i].toUInt();
184 *--pBuffer = quint8((node & 0x7f));
187 *--pBuffer = quint8(((node & 0x7f) | 0x80));
190 elem.mValue += pBuffer;
216 if (mValue.size() != 13 && mValue.size() != 15)
221 if (!isAsciiDigit(mValue[0]))
225 if (mValue.back() !=
'Z')
228 if (mType == UtcTimeType && mValue.size() == 13) {
236 constexpr int rfc2459CenturyStart = 1950;
237 const QLatin1StringView inputView(mValue);
238 QDate date = QDate::fromString(inputView.first(6), u"yyMMdd", rfc2459CenturyStart);
242 Q_ASSERT(date.year() >= rfc2459CenturyStart);
243 Q_ASSERT(date.year() < 100 + rfc2459CenturyStart);
245 QTime time = QTime::fromString(inputView.sliced(6, 6), u"HHmmss");
248 result = QDateTime(date, time, QTimeZone::UTC);
249 }
else if (mType == GeneralizedTimeType && mValue.size() == 15) {
250 result = QDateTime::fromString(QString::fromLatin1(mValue), u"yyyyMMddHHmmsst");
258 QMultiMap<QByteArray, QString> info;
260 QDataStream issuerStream(mValue);
263 QDataStream setStream(elem.mValue);
265 const auto elems = issuerElem.toList();
266 if (elems.size() == 2) {
267 const QByteArray key = elems.front().toObjectName();
269 info.insert(key, elems.back().toString());
278 if (mType != QAsn1Element::IntegerType || mValue.isEmpty()) {
286 if (mValue.at(0) & 0x80 || mValue.size() > 8) {
292 qint64 value = mValue.at(0) & 0x7f;
293 for (
int i = 1; i < mValue.size(); ++i)
294 value = (value << 8) | quint8(mValue.at(i));
316 if (mType == ObjectIdentifierType && !mValue.isEmpty()) {
317 quint8 b = mValue.at(0);
318 key += QByteArray::number(b / 40) +
'.' + QByteArray::number (b % 40);
319 unsigned int val = 0;
320 for (
int i = 1; i < mValue.size(); ++i) {
322 val = (val << 7) | (b & 0x7f);
324 key +=
'.' + QByteArray::number(val);
341 if (mValue.contains(
'\0'))
344 if (mType == PrintableStringType || mType == TeletexStringType
345 || mType == Rfc822NameType || mType == DnsNameType
346 || mType == UniformResourceIdentifierType)
347 return QString::fromLatin1(mValue);
348 if (mType == Utf8StringType)
349 return QString::fromUtf8(mValue);