qasn1element.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qasn1element.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2014 Jeremy Lainé <jeremy.laine@m4x.org>-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34-
35#include "qasn1element_p.h"-
36-
37#include <QtCore/qdatastream.h>-
38#include <QtCore/qdatetime.h>-
39#include <QtCore/qvector.h>-
40#include <QDebug>-
41-
42QT_BEGIN_NAMESPACE-
43-
44typedef QMap<QByteArray, QByteArray> OidNameMap;-
45static OidNameMap createOidMap()-
46{-
47 OidNameMap oids;-
48 // used by unit tests-
49 oids.insert(oids.cend(), QByteArrayLiteral("0.9.2342.19200300.100.1.5"), QByteArrayLiteral("favouriteDrink"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
50 oids.insert(oids.cend(), QByteArrayLiteral("1.2.840.113549.1.9.1"), QByteArrayLiteral("emailAddress"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
51 oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.1.1"), QByteArrayLiteral("authorityInfoAccess"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
52 oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.48.1"), QByteArrayLiteral("OCSP"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
53 oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.48.2"), QByteArrayLiteral("caIssuers"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
54 oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.14"), QByteArrayLiteral("subjectKeyIdentifier"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
55 oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.15"), QByteArrayLiteral("keyUsage"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
56 oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.17"), QByteArrayLiteral("subjectAltName"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
57 oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.19"), QByteArrayLiteral("basicConstraints"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
58 oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.35"), QByteArrayLiteral("authorityKeyIdentifier"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
59 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.10"), QByteArrayLiteral("O"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
60 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.11"), QByteArrayLiteral("OU"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
61 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.12"), QByteArrayLiteral("title"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
62 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.13"), QByteArrayLiteral("description"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
63 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.17"), QByteArrayLiteral("postalCode"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
64 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.3"), QByteArrayLiteral("CN"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
65 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.4"), QByteArrayLiteral("SN"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
66 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.41"), QByteArrayLiteral("name"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
67 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.42"), QByteArrayLiteral("GN"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
68 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.43"), QByteArrayLiteral("initials"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
69 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.46"), QByteArrayLiteral("dnQualifier"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
70 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.5"), QByteArrayLiteral("serialNumber"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
71 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.6"), QByteArrayLiteral("C"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
72 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.7"), QByteArrayLiteral("L"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
73 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.8"), QByteArrayLiteral("ST"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
74 oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.9"), QByteArrayLiteral("street"));
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: return ba;
Executed by:
  • tst_qasn1element - unknown status
1
75 return oids;
executed 1 time by 1 test: return oids;
Executed by:
  • tst_qasn1element - unknown status
1
76}-
77Q_GLOBAL_STATIC_WITH_ARGS(OidNameMap, oidNameMap, (createOidMap()))
executed 1 time by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
executed 1 time by 1 test: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qasn1element - unknown status
executed 2 times by 1 test: return &holder.value;
Executed by:
  • tst_qasn1element - unknown status
guard.load() =...c::InitializedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-2
78-
79QAsn1Element::QAsn1Element(quint8 type, const QByteArray &value)-
80 : mType(type)-
81 , mValue(value)-
82{-
83}
executed 56 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
56
84-
85bool QAsn1Element::read(QDataStream &stream)-
86{-
87 // type-
88 quint8 tmpType;-
89 stream >> tmpType;-
90 if (!tmpType)
!tmpTypeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
2-22
91 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qasn1element - unknown status
2
92-
93 // length-
94 qint64 length = 0;-
95 quint8 first;-
96 stream >> first;-
97 if (first & 0x80) {
first & 0x80Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 21 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-21
98 // long form-
99 const quint8 bytes = (first & 0x7f);-
100 if (bytes > 7)
bytes > 7Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
0-1
101 return false;
never executed: return false;
0
102-
103 quint8 b;-
104 for (int i = 0; i < bytes; i++) {
i < bytesDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1
105 stream >> b;-
106 length = (length << 8) | b;-
107 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
1
108 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
1
109 // short form-
110 length = (first & 0x7f);-
111 }
executed 21 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
21
112-
113 // value-
114 QByteArray tmpValue;-
115 tmpValue.resize(length);-
116 int count = stream.readRawData(tmpValue.data(), tmpValue.size());-
117 if (count != length)
count != lengthDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 21 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-21
118 return false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_qasn1element - unknown status
1
119-
120 mType = tmpType;-
121 mValue.swap(tmpValue);-
122 return true;
executed 21 times by 1 test: return true;
Executed by:
  • tst_qasn1element - unknown status
21
123}-
124-
125bool QAsn1Element::read(const QByteArray &data)-
126{-
127 QDataStream stream(data);-
128 return read(stream);
executed 24 times by 1 test: return read(stream);
Executed by:
  • tst_qasn1element - unknown status
24
129}-
130-
131void QAsn1Element::write(QDataStream &stream) const-
132{-
133 // type-
134 stream << mType;-
135-
136 // length-
137 qint64 length = mValue.size();-
138 if (length >= 128) {
length >= 128Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-7
139 // long form-
140 quint8 encodedLength = 0x80;-
141 QByteArray ba;-
142 while (length) {
lengthDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1
143 ba.prepend(quint8((length & 0xff)));-
144 length >>= 8;-
145 encodedLength += 1;-
146 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
1
147 stream << encodedLength;-
148 stream.writeRawData(ba.data(), ba.size());-
149 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
1
150 // short form-
151 stream << quint8(length);-
152 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
7
153-
154 // value-
155 stream.writeRawData(mValue.data(), mValue.size());-
156}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
8
157-
158QAsn1Element QAsn1Element::fromBool(bool val)-
159{-
160 return QAsn1Element(QAsn1Element::BooleanType,
executed 7 times by 1 test: return QAsn1Element(QAsn1Element::BooleanType, QByteArray(1, val ? 0xff : 0x00));
Executed by:
  • tst_qasn1element - unknown status
7
161 QByteArray(1, val ? 0xff : 0x00));
executed 7 times by 1 test: return QAsn1Element(QAsn1Element::BooleanType, QByteArray(1, val ? 0xff : 0x00));
Executed by:
  • tst_qasn1element - unknown status
7
162}-
163-
164QAsn1Element QAsn1Element::fromInteger(unsigned int val)-
165{-
166 QAsn1Element elem(QAsn1Element::IntegerType);-
167 while (val > 127) {
val > 127Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
2-4
168 elem.mValue.prepend(val & 0xff);-
169 val >>= 8;-
170 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
2
171 elem.mValue.prepend(val & 0x7f);-
172 return elem;
executed 4 times by 1 test: return elem;
Executed by:
  • tst_qasn1element - unknown status
4
173}-
174-
175QAsn1Element QAsn1Element::fromVector(const QVector<QAsn1Element> &items)-
176{-
177 QAsn1Element seq;-
178 seq.mType = SequenceType;-
179 QDataStream stream(&seq.mValue, QIODevice::WriteOnly);-
180 for (QVector<QAsn1Element>::const_iterator it = items.cbegin(), end = items.cend(); it != end; ++it)
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
181 it->write(stream);
never executed: it->write(stream);
0
182 return seq;
never executed: return seq;
0
183}-
184-
185QAsn1Element QAsn1Element::fromObjectId(const QByteArray &id)-
186{-
187 QAsn1Element elem;-
188 elem.mType = ObjectIdentifierType;-
189 QList<QByteArray> bits = id.split('.');-
190 Q_ASSERT(bits.size() > 2);-
191 elem.mValue += quint8((bits[0].toUInt() * 40 + bits[1].toUInt()));-
192 for (int i = 2; i < bits.size(); ++i) {
i < bits.size()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
2-7
193 char buffer[std::numeric_limits<unsigned int>::digits / 7 + 2];-
194 char *pBuffer = buffer + sizeof(buffer);-
195 *--pBuffer = '\0';-
196 unsigned int node = bits[i].toUInt();-
197 *--pBuffer = quint8((node & 0x7f));-
198 node >>= 7;-
199 while (node) {
nodeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
4-7
200 *--pBuffer = quint8(((node & 0x7f) | 0x80));-
201 node >>= 7;-
202 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
4
203 elem.mValue += pBuffer;-
204 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
7
205 return elem;
executed 2 times by 1 test: return elem;
Executed by:
  • tst_qasn1element - unknown status
2
206}-
207-
208bool QAsn1Element::toBool(bool *ok) const-
209{-
210 if (*this == fromBool(true)) {
*this == fromBool(true)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-3
211 if (ok)
okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-1
212 *ok = true;
executed 1 time by 1 test: *ok = true;
Executed by:
  • tst_qasn1element - unknown status
1
213 return true;
executed 1 time by 1 test: return true;
Executed by:
  • tst_qasn1element - unknown status
1
214 } else if (*this == fromBool(false)) {
*this == fromBool(false)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-2
215 if (ok)
okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-1
216 *ok = true;
executed 1 time by 1 test: *ok = true;
Executed by:
  • tst_qasn1element - unknown status
1
217 return false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_qasn1element - unknown status
1
218 } else {-
219 if (ok)
okDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-2
220 *ok = false;
executed 2 times by 1 test: *ok = false;
Executed by:
  • tst_qasn1element - unknown status
2
221 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qasn1element - unknown status
2
222 }-
223}-
224-
225QDateTime QAsn1Element::toDateTime() const-
226{-
227 if (mValue.endsWith('Z')) {
mValue.endsWith('Z')Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
3-4
228 if (mType == UtcTimeType && mValue.size() == 13)
mType == UtcTimeTypeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
mValue.size() == 13Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-2
229 return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
230 mValue.mid(2, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
231 mValue.mid(4, 2).toInt()),
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
232 QTime(mValue.mid(6, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
233 mValue.mid(8, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
234 mValue.mid(10, 2).toInt()),
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
235 Qt::UTC);
executed 1 time by 1 test: return QDateTime(QDate(2000 + mValue.mid(0, 2).toInt(), mValue.mid(2, 2).toInt(), mValue.mid(4, 2).toInt()), QTime(mValue.mid(6, 2).toInt(), mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
236 else if (mType == GeneralizedTimeType && mValue.size() == 15)
mType == GeneralizedTimeTypeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
mValue.size() == 15Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-2
237 return QDateTime(QDate(mValue.mid(0, 4).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
238 mValue.mid(4, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
239 mValue.mid(6, 2).toInt()),
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
240 QTime(mValue.mid(8, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
241 mValue.mid(10, 2).toInt(),
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
242 mValue.mid(12, 2).toInt()),
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
243 Qt::UTC);
executed 1 time by 1 test: return QDateTime(QDate(mValue.mid(0, 4).toInt(), mValue.mid(4, 2).toInt(), mValue.mid(6, 2).toInt()), QTime(mValue.mid(8, 2).toInt(), mValue.mid(10, 2).toInt(), mValue.mid(12, 2).toInt()), Qt::UTC);
Executed by:
  • tst_qasn1element - unknown status
1
244 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
2
245 return QDateTime();
executed 5 times by 1 test: return QDateTime();
Executed by:
  • tst_qasn1element - unknown status
5
246}-
247-
248QMultiMap<QByteArray, QString> QAsn1Element::toInfo() const-
249{-
250 QMultiMap<QByteArray, QString> info;-
251 QAsn1Element elem;-
252 QDataStream issuerStream(mValue);-
253 while (elem.read(issuerStream) && elem.mType == QAsn1Element::SetType) {
elem.read(issuerStream)Description
TRUEnever evaluated
FALSEnever evaluated
elem.mType == ...ement::SetTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
254 QAsn1Element issuerElem;-
255 QDataStream setStream(elem.mValue);-
256 if (issuerElem.read(setStream) && issuerElem.mType == QAsn1Element::SequenceType) {
issuerElem.read(setStream)Description
TRUEnever evaluated
FALSEnever evaluated
issuerElem.mTy...::SequenceTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
257 QVector<QAsn1Element> elems = issuerElem.toVector();-
258 if (elems.size() == 2) {
elems.size() == 2Description
TRUEnever evaluated
FALSEnever evaluated
0
259 const QByteArray key = elems.front().toObjectName();-
260 if (!key.isEmpty())
!key.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
261 info.insert(key, elems.back().toString());
never executed: info.insert(key, elems.back().toString());
0
262 }
never executed: end of block
0
263 }
never executed: end of block
0
264 }
never executed: end of block
0
265 return info;
never executed: return info;
0
266}-
267-
268qint64 QAsn1Element::toInteger(bool *ok) const-
269{-
270 if (mType != QAsn1Element::IntegerType || mValue.isEmpty()) {
mType != QAsn1...t::IntegerTypeDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
mValue.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
0-4
271 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
272 *ok = false;
never executed: *ok = false;
0
273 return 0;
never executed: return 0;
0
274 }-
275-
276 // NOTE: negative numbers are not handled-
277 if (mValue.at(0) & 0x80) {
mValue.at(0) & 0x80Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
0-4
278 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
279 *ok = false;
never executed: *ok = false;
0
280 return 0;
never executed: return 0;
0
281 }-
282-
283 qint64 value = mValue.at(0) & 0x7f;-
284 for (int i = 1; i < mValue.size(); ++i)
i < mValue.size()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
2-4
285 value = (value << 8) | quint8(mValue.at(i));
executed 2 times by 1 test: value = (value << 8) | quint8(mValue.at(i));
Executed by:
  • tst_qasn1element - unknown status
2
286-
287 if (ok)
okDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-4
288 *ok = true;
executed 4 times by 1 test: *ok = true;
Executed by:
  • tst_qasn1element - unknown status
4
289 return value;
executed 4 times by 1 test: return value;
Executed by:
  • tst_qasn1element - unknown status
4
290}-
291-
292QVector<QAsn1Element> QAsn1Element::toVector() const-
293{-
294 QVector<QAsn1Element> items;-
295 if (mType == SequenceType) {
mType == SequenceTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
296 QAsn1Element elem;-
297 QDataStream stream(mValue);-
298 while (elem.read(stream))
elem.read(stream)Description
TRUEnever evaluated
FALSEnever evaluated
0
299 items << elem;
never executed: items << elem;
0
300 }
never executed: end of block
0
301 return items;
never executed: return items;
0
302}-
303-
304QByteArray QAsn1Element::toObjectId() const-
305{-
306 QByteArray key;-
307 if (mType == ObjectIdentifierType && !mValue.isEmpty()) {
mType == ObjectIdentifierTypeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
!mValue.isEmpty()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-6
308 quint8 b = mValue[0];-
309 key += QByteArray::number(b / 40) + '.' + QByteArray::number (b % 40);-
310 unsigned int val = 0;-
311 for (int i = 1; i < mValue.size(); ++i) {
i < mValue.size()Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
6-33
312 b = mValue[i];-
313 val = (val << 7) | (b & 0x7f);-
314 if (!(b & 0x80)) {
!(b & 0x80)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
12-21
315 key += '.' + QByteArray::number(val);-
316 val = 0;-
317 }
executed 21 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
21
318 }
executed 33 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
33
319 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qasn1element - unknown status
6
320 return key;
executed 6 times by 1 test: return key;
Executed by:
  • tst_qasn1element - unknown status
6
321}-
322-
323QByteArray QAsn1Element::toObjectName() const-
324{-
325 QByteArray key = toObjectId();-
326 return oidNameMap->value(key, key);
executed 2 times by 1 test: return oidNameMap->value(key, key);
Executed by:
  • tst_qasn1element - unknown status
2
327}-
328-
329QString QAsn1Element::toString() const-
330{-
331 // Detect embedded NULs and reject-
332 if (qstrlen(mValue) < uint(mValue.size()))
qstrlen(mValue...mValue.size())Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
6
333 return QString();
executed 6 times by 1 test: return QString();
Executed by:
  • tst_qasn1element - unknown status
6
334-
335 if (mType == PrintableStringType || mType == TeletexStringType
mType == PrintableStringTypeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
mType == TeletexStringTypeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-5
336 || mType == Rfc822NameType || mType == DnsNameType
mType == Rfc822NameTypeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
mType == DnsNameTypeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1-3
337 || mType == UniformResourceIdentifierType)
mType == Unifo...IdentifierTypeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
1
338 return QString::fromLatin1(mValue, mValue.size());
executed 5 times by 1 test: return QString::fromLatin1(mValue, mValue.size());
Executed by:
  • tst_qasn1element - unknown status
5
339 if (mType == Utf8StringType)
mType == Utf8StringTypeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qasn1element - unknown status
FALSEnever evaluated
0-1
340 return QString::fromUtf8(mValue, mValue.size());
executed 1 time by 1 test: return QString::fromUtf8(mValue, mValue.size());
Executed by:
  • tst_qasn1element - unknown status
1
341-
342 return QString();
never executed: return QString();
0
343}-
344-
345QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9