Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qcryptographichash.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | typedef unsigned char BitSequence; | - | ||||||||||||||||||||||||
11 | typedef unsigned long long DataLength; | - | ||||||||||||||||||||||||
12 | typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn; | - | ||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | typedef spongeState hashState; | - | ||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | typedef spongeState SHA3Context; | - | ||||||||||||||||||||||||
21 | typedef HashReturn (SHA3Init)(hashState *state, int hashbitlen); | - | ||||||||||||||||||||||||
22 | typedef HashReturn (SHA3Update)(hashState *state, const BitSequence *data, DataLength databitlen); | - | ||||||||||||||||||||||||
23 | typedef HashReturn (SHA3Final)(hashState *state, BitSequence *hashval); | - | ||||||||||||||||||||||||
24 | - | |||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | static SHA3Init * const sha3Init = Init; | - | ||||||||||||||||||||||||
29 | static SHA3Update * const sha3Update = Update; | - | ||||||||||||||||||||||||
30 | static SHA3Final * const sha3Final = Final; | - | ||||||||||||||||||||||||
31 | static int SHA224_256AddLength(SHA256Context *context, unsigned int length); | - | ||||||||||||||||||||||||
32 | static int SHA384_512AddLength(SHA512Context *context, unsigned int length); | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | static inline int SHA224_256AddLength(SHA256Context *context, unsigned int length) | - | ||||||||||||||||||||||||
46 | { | - | ||||||||||||||||||||||||
47 | ::quint32 addTemp; | - | ||||||||||||||||||||||||
48 | return executed 750 times by 2 tests: (addTemp = (context)->Length_Low, (context)->Corrupted = (((return (addTemp = (context)->Length_Low, (context)->Corrupted = (((context)->Length_Low += (length)) < addTemp) && (++(context)->Length_High == 0) ? shaInputTooLong : (context)->Corrupted ); Executed by:
executed 750 times by 2 tests: return (addTemp = (context)->Length_Low, (context)->Corrupted = (((context)->Length_Low += (length)) < addTemp) && (++(context)->Length_High == 0) ? shaInputTooLong : (context)->Corrupted ); Executed by:
| 0-750 | ||||||||||||||||||||||||
49 | } | - | ||||||||||||||||||||||||
50 | static inline int SHA384_512AddLength(SHA512Context *context, unsigned int length) | - | ||||||||||||||||||||||||
51 | { | - | ||||||||||||||||||||||||
52 | ::quint64 addTemp; | - | ||||||||||||||||||||||||
53 | return executed 24 times by 1 test: (addTemp = context->Length_Low, context->Corrupted = ((return (addTemp = context->Length_Low, context->Corrupted = ((context->Length_Low += length) < addTemp) && (++context->Length_High == 0) ? shaInputTooLong : (context)->Corrupted); Executed by:
executed 24 times by 1 test: return (addTemp = context->Length_Low, context->Corrupted = ((context->Length_Low += length) < addTemp) && (++context->Length_High == 0) ? shaInputTooLong : (context)->Corrupted); Executed by:
| 0-24 | ||||||||||||||||||||||||
54 | } | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||
59 | class QCryptographicHashPrivate | - | ||||||||||||||||||||||||
60 | { | - | ||||||||||||||||||||||||
61 | public: | - | ||||||||||||||||||||||||
62 | QCryptographicHash::Algorithm method; | - | ||||||||||||||||||||||||
63 | union { | - | ||||||||||||||||||||||||
64 | Sha1State sha1Context; | - | ||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||
66 | MD5Context md5Context; | - | ||||||||||||||||||||||||
67 | md4_context md4Context; | - | ||||||||||||||||||||||||
68 | SHA224Context sha224Context; | - | ||||||||||||||||||||||||
69 | SHA256Context sha256Context; | - | ||||||||||||||||||||||||
70 | SHA384Context sha384Context; | - | ||||||||||||||||||||||||
71 | SHA512Context sha512Context; | - | ||||||||||||||||||||||||
72 | SHA3Context sha3Context; | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | }; | - | ||||||||||||||||||||||||
75 | QByteArray result; | - | ||||||||||||||||||||||||
76 | }; | - | ||||||||||||||||||||||||
77 | QCryptographicHash::QCryptographicHash(Algorithm method) | - | ||||||||||||||||||||||||
78 | : d(new QCryptographicHashPrivate) | - | ||||||||||||||||||||||||
79 | { | - | ||||||||||||||||||||||||
80 | d->method = method; | - | ||||||||||||||||||||||||
81 | reset(); | - | ||||||||||||||||||||||||
82 | } executed 10727 times by 24 tests: end of block Executed by:
| 10727 | ||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | QCryptographicHash::~QCryptographicHash() | - | ||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||
89 | delete d; | - | ||||||||||||||||||||||||
90 | } executed 10727 times by 24 tests: end of block Executed by:
| 10727 | ||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | void QCryptographicHash::reset() | - | ||||||||||||||||||||||||
96 | { | - | ||||||||||||||||||||||||
97 | switch (d->method) { | - | ||||||||||||||||||||||||
98 | case executed 7726 times by 12 tests: Sha1:case Sha1: Executed by:
executed 7726 times by 12 tests: case Sha1: Executed by:
| 7726 | ||||||||||||||||||||||||
99 | sha1InitState(&d->sha1Context); | - | ||||||||||||||||||||||||
100 | break; executed 7726 times by 12 tests: break; Executed by:
| 7726 | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | case executed 8 times by 2 tests: Md4:case Md4: Executed by:
executed 8 times by 2 tests: case Md4: Executed by:
| 8 | ||||||||||||||||||||||||
108 | md4_init(&d->md4Context); | - | ||||||||||||||||||||||||
109 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
110 | case executed 3075 times by 19 tests: Md5:case Md5: Executed by:
executed 3075 times by 19 tests: case Md5: Executed by:
| 3075 | ||||||||||||||||||||||||
111 | MD5Init(&d->md5Context); | - | ||||||||||||||||||||||||
112 | break; executed 3075 times by 19 tests: break; Executed by:
| 3075 | ||||||||||||||||||||||||
113 | case executed 4 times by 1 test: Sha224:case Sha224: Executed by:
executed 4 times by 1 test: case Sha224: Executed by:
| 4 | ||||||||||||||||||||||||
114 | SHA224Reset(&d->sha224Context); | - | ||||||||||||||||||||||||
115 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
116 | case executed 16 times by 2 tests: Sha256:case Sha256: Executed by:
executed 16 times by 2 tests: case Sha256: Executed by:
| 16 | ||||||||||||||||||||||||
117 | SHA256Reset(&d->sha256Context); | - | ||||||||||||||||||||||||
118 | break; executed 16 times by 2 tests: break; Executed by:
| 16 | ||||||||||||||||||||||||
119 | case executed 4 times by 1 test: Sha384:case Sha384: Executed by:
executed 4 times by 1 test: case Sha384: Executed by:
| 4 | ||||||||||||||||||||||||
120 | SHA384Reset(&d->sha384Context); | - | ||||||||||||||||||||||||
121 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
122 | case executed 4 times by 1 test: Sha512:case Sha512: Executed by:
executed 4 times by 1 test: case Sha512: Executed by:
| 4 | ||||||||||||||||||||||||
123 | SHA512Reset(&d->sha512Context); | - | ||||||||||||||||||||||||
124 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
125 | case executed 6 times by 1 test: Sha3_224:case Sha3_224: Executed by:
executed 6 times by 1 test: case Sha3_224: Executed by:
| 6 | ||||||||||||||||||||||||
126 | sha3Init(&d->sha3Context, 224); | - | ||||||||||||||||||||||||
127 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
128 | case executed 6 times by 1 test: Sha3_256:case Sha3_256: Executed by:
executed 6 times by 1 test: case Sha3_256: Executed by:
| 6 | ||||||||||||||||||||||||
129 | sha3Init(&d->sha3Context, 256); | - | ||||||||||||||||||||||||
130 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
131 | case executed 6 times by 1 test: Sha3_384:case Sha3_384: Executed by:
executed 6 times by 1 test: case Sha3_384: Executed by:
| 6 | ||||||||||||||||||||||||
132 | sha3Init(&d->sha3Context, 384); | - | ||||||||||||||||||||||||
133 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
134 | case executed 6 times by 1 test: Sha3_512:case Sha3_512: Executed by:
executed 6 times by 1 test: case Sha3_512: Executed by:
| 6 | ||||||||||||||||||||||||
135 | sha3Init(&d->sha3Context, 512); | - | ||||||||||||||||||||||||
136 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | } | - | ||||||||||||||||||||||||
139 | d->result.clear(); | - | ||||||||||||||||||||||||
140 | } executed 10861 times by 24 tests: end of block Executed by:
| 10861 | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | void QCryptographicHash::addData(const char *data, int length) | - | ||||||||||||||||||||||||
147 | { | - | ||||||||||||||||||||||||
148 | switch (d->method) { | - | ||||||||||||||||||||||||
149 | case executed 7734 times by 12 tests: Sha1:case Sha1: Executed by:
executed 7734 times by 12 tests: case Sha1: Executed by:
| 7734 | ||||||||||||||||||||||||
150 | sha1Update(&d->sha1Context, (const unsigned char *)data, length); | - | ||||||||||||||||||||||||
151 | break; executed 7734 times by 12 tests: break; Executed by:
| 7734 | ||||||||||||||||||||||||
152 | - | |||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | case executed 8 times by 2 tests: Md4:case Md4: Executed by:
executed 8 times by 2 tests: case Md4: Executed by:
| 8 | ||||||||||||||||||||||||
159 | md4_update(&d->md4Context, (const unsigned char *)data, length); | - | ||||||||||||||||||||||||
160 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
161 | case executed 3643 times by 19 tests: Md5:case Md5: Executed by:
executed 3643 times by 19 tests: case Md5: Executed by:
| 3643 | ||||||||||||||||||||||||
162 | MD5Update(&d->md5Context, (const unsigned char *)data, length); | - | ||||||||||||||||||||||||
163 | break; executed 3643 times by 19 tests: break; Executed by:
| 3643 | ||||||||||||||||||||||||
164 | case executed 4 times by 1 test: Sha224:case Sha224: Executed by:
executed 4 times by 1 test: case Sha224: Executed by:
| 4 | ||||||||||||||||||||||||
165 | SHA224Input(&d->sha224Context, reinterpret_cast<const unsigned char *>(data), length); | - | ||||||||||||||||||||||||
166 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
167 | case executed 22 times by 2 tests: Sha256:case Sha256: Executed by:
executed 22 times by 2 tests: case Sha256: Executed by:
| 22 | ||||||||||||||||||||||||
168 | SHA256Input(&d->sha256Context, reinterpret_cast<const unsigned char *>(data), length); | - | ||||||||||||||||||||||||
169 | break; executed 22 times by 2 tests: break; Executed by:
| 22 | ||||||||||||||||||||||||
170 | case executed 4 times by 1 test: Sha384:case Sha384: Executed by:
executed 4 times by 1 test: case Sha384: Executed by:
| 4 | ||||||||||||||||||||||||
171 | SHA384Input(&d->sha384Context, reinterpret_cast<const unsigned char *>(data), length); | - | ||||||||||||||||||||||||
172 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
173 | case executed 4 times by 1 test: Sha512:case Sha512: Executed by:
executed 4 times by 1 test: case Sha512: Executed by:
| 4 | ||||||||||||||||||||||||
174 | SHA512Input(&d->sha512Context, reinterpret_cast<const unsigned char *>(data), length); | - | ||||||||||||||||||||||||
175 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
176 | case executed 6 times by 1 test: Sha3_224:case Sha3_224: Executed by:
executed 6 times by 1 test: case Sha3_224: Executed by:
| 6 | ||||||||||||||||||||||||
177 | sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | - | ||||||||||||||||||||||||
178 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
179 | case executed 6 times by 1 test: Sha3_256:case Sha3_256: Executed by:
executed 6 times by 1 test: case Sha3_256: Executed by:
| 6 | ||||||||||||||||||||||||
180 | sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | - | ||||||||||||||||||||||||
181 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
182 | case executed 6 times by 1 test: Sha3_384:case Sha3_384: Executed by:
executed 6 times by 1 test: case Sha3_384: Executed by:
| 6 | ||||||||||||||||||||||||
183 | sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | - | ||||||||||||||||||||||||
184 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
185 | case executed 6 times by 1 test: Sha3_512:case Sha3_512: Executed by:
executed 6 times by 1 test: case Sha3_512: Executed by:
| 6 | ||||||||||||||||||||||||
186 | sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); | - | ||||||||||||||||||||||||
187 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | } | - | ||||||||||||||||||||||||
190 | d->result.clear(); | - | ||||||||||||||||||||||||
191 | } executed 11443 times by 24 tests: end of block Executed by:
| 11443 | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | void QCryptographicHash::addData(const QByteArray &data) | - | ||||||||||||||||||||||||
197 | { | - | ||||||||||||||||||||||||
198 | addData(data.constData(), data.length()); | - | ||||||||||||||||||||||||
199 | } executed 11114 times by 24 tests: end of block Executed by:
| 11114 | ||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | bool QCryptographicHash::addData(QIODevice* device) | - | ||||||||||||||||||||||||
207 | { | - | ||||||||||||||||||||||||
208 | if (!device->isReadable()
| 2 | ||||||||||||||||||||||||
209 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | if (!device->isOpen()
| 0-2 | ||||||||||||||||||||||||
212 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | char buffer[1024]; | - | ||||||||||||||||||||||||
215 | int length; | - | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | while ((
| 2-9 | ||||||||||||||||||||||||
218 | addData(buffer,length); executed 9 times by 1 test: addData(buffer,length); Executed by:
| 9 | ||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | return executed 2 times by 1 test: device->atEnd();return device->atEnd(); Executed by:
executed 2 times by 1 test: return device->atEnd(); Executed by:
| 2 | ||||||||||||||||||||||||
221 | } | - | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | QByteArray QCryptographicHash::result() const | - | ||||||||||||||||||||||||
230 | { | - | ||||||||||||||||||||||||
231 | if (!d->result.isEmpty()
| 22-10827 | ||||||||||||||||||||||||
232 | return executed 22 times by 1 test: d->result;return d->result; Executed by:
executed 22 times by 1 test: return d->result; Executed by:
| 22 | ||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||
234 | switch (d->method) { | - | ||||||||||||||||||||||||
235 | case executed 7722 times by 12 tests: Sha1:case Sha1: Executed by:
executed 7722 times by 12 tests: {case Sha1: Executed by:
| 7722 | ||||||||||||||||||||||||
236 | Sha1State copy = d->sha1Context; | - | ||||||||||||||||||||||||
237 | d->result.resize(20); | - | ||||||||||||||||||||||||
238 | sha1FinalizeState(©); | - | ||||||||||||||||||||||||
239 | sha1ToHash(©, (unsigned char *)d->result.data()); | - | ||||||||||||||||||||||||
240 | break; executed 7722 times by 12 tests: break; Executed by:
| 7722 | ||||||||||||||||||||||||
241 | } | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | case executed 8 times by 2 tests: Md4:case Md4: Executed by:
executed 8 times by 2 tests: {case Md4: Executed by:
| 8 | ||||||||||||||||||||||||
249 | md4_context copy = d->md4Context; | - | ||||||||||||||||||||||||
250 | d->result.resize((128/8)); | - | ||||||||||||||||||||||||
251 | md4_final(©, (unsigned char *)d->result.data()); | - | ||||||||||||||||||||||||
252 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
253 | } | - | ||||||||||||||||||||||||
254 | case executed 3049 times by 19 tests: Md5:case Md5: Executed by:
executed 3049 times by 19 tests: {case Md5: Executed by:
| 3049 | ||||||||||||||||||||||||
255 | MD5Context copy = d->md5Context; | - | ||||||||||||||||||||||||
256 | d->result.resize(16); | - | ||||||||||||||||||||||||
257 | MD5Final(©, (unsigned char *)d->result.data()); | - | ||||||||||||||||||||||||
258 | break; executed 3049 times by 19 tests: break; Executed by:
| 3049 | ||||||||||||||||||||||||
259 | } | - | ||||||||||||||||||||||||
260 | case executed 4 times by 1 test: Sha224:case Sha224: Executed by:
executed 4 times by 1 test: {case Sha224: Executed by:
| 4 | ||||||||||||||||||||||||
261 | SHA224Context copy = d->sha224Context; | - | ||||||||||||||||||||||||
262 | d->result.resize(SHA224HashSize); | - | ||||||||||||||||||||||||
263 | SHA224Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | - | ||||||||||||||||||||||||
264 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
265 | } | - | ||||||||||||||||||||||||
266 | case executed 12 times by 2 tests: Sha256:case Sha256: Executed by:
executed 12 times by 2 tests: {case Sha256: Executed by:
| 12 | ||||||||||||||||||||||||
267 | SHA256Context copy = d->sha256Context; | - | ||||||||||||||||||||||||
268 | d->result.resize(SHA256HashSize); | - | ||||||||||||||||||||||||
269 | SHA256Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | - | ||||||||||||||||||||||||
270 | break; executed 12 times by 2 tests: break; Executed by:
| 12 | ||||||||||||||||||||||||
271 | } | - | ||||||||||||||||||||||||
272 | case executed 4 times by 1 test: Sha384:case Sha384: Executed by:
executed 4 times by 1 test: {case Sha384: Executed by:
| 4 | ||||||||||||||||||||||||
273 | SHA384Context copy = d->sha384Context; | - | ||||||||||||||||||||||||
274 | d->result.resize(SHA384HashSize); | - | ||||||||||||||||||||||||
275 | SHA384Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | - | ||||||||||||||||||||||||
276 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
277 | } | - | ||||||||||||||||||||||||
278 | case executed 4 times by 1 test: Sha512:case Sha512: Executed by:
executed 4 times by 1 test: {case Sha512: Executed by:
| 4 | ||||||||||||||||||||||||
279 | SHA512Context copy = d->sha512Context; | - | ||||||||||||||||||||||||
280 | d->result.resize(SHA512HashSize); | - | ||||||||||||||||||||||||
281 | SHA512Result(©, reinterpret_cast<unsigned char *>(d->result.data())); | - | ||||||||||||||||||||||||
282 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
283 | } | - | ||||||||||||||||||||||||
284 | case executed 6 times by 1 test: Sha3_224:case Sha3_224: Executed by:
executed 6 times by 1 test: {case Sha3_224: Executed by:
| 6 | ||||||||||||||||||||||||
285 | SHA3Context copy = d->sha3Context; | - | ||||||||||||||||||||||||
286 | d->result.resize(224/8); | - | ||||||||||||||||||||||||
287 | sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | - | ||||||||||||||||||||||||
288 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
289 | } | - | ||||||||||||||||||||||||
290 | case executed 6 times by 1 test: Sha3_256:case Sha3_256: Executed by:
executed 6 times by 1 test: {case Sha3_256: Executed by:
| 6 | ||||||||||||||||||||||||
291 | SHA3Context copy = d->sha3Context; | - | ||||||||||||||||||||||||
292 | d->result.resize(256/8); | - | ||||||||||||||||||||||||
293 | sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | - | ||||||||||||||||||||||||
294 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
295 | } | - | ||||||||||||||||||||||||
296 | case executed 6 times by 1 test: Sha3_384:case Sha3_384: Executed by:
executed 6 times by 1 test: {case Sha3_384: Executed by:
| 6 | ||||||||||||||||||||||||
297 | SHA3Context copy = d->sha3Context; | - | ||||||||||||||||||||||||
298 | d->result.resize(384/8); | - | ||||||||||||||||||||||||
299 | sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | - | ||||||||||||||||||||||||
300 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
301 | } | - | ||||||||||||||||||||||||
302 | case executed 6 times by 1 test: Sha3_512:case Sha3_512: Executed by:
executed 6 times by 1 test: {case Sha3_512: Executed by:
| 6 | ||||||||||||||||||||||||
303 | SHA3Context copy = d->sha3Context; | - | ||||||||||||||||||||||||
304 | d->result.resize(512/8); | - | ||||||||||||||||||||||||
305 | sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); | - | ||||||||||||||||||||||||
306 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
307 | } | - | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | } | - | ||||||||||||||||||||||||
310 | return executed 10827 times by 24 tests: d->result;return d->result; Executed by:
executed 10827 times by 24 tests: return d->result; Executed by:
| 10827 | ||||||||||||||||||||||||
311 | } | - | ||||||||||||||||||||||||
312 | - | |||||||||||||||||||||||||
313 | - | |||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||
316 | QByteArray QCryptographicHash::hash(const QByteArray &data, Algorithm method) | - | ||||||||||||||||||||||||
317 | { | - | ||||||||||||||||||||||||
318 | QCryptographicHash hash(method); | - | ||||||||||||||||||||||||
319 | hash.addData(data); | - | ||||||||||||||||||||||||
320 | return executed 10306 times by 22 tests: hash.result();return hash.result(); Executed by:
executed 10306 times by 22 tests: return hash.result(); Executed by:
| 10306 | ||||||||||||||||||||||||
321 | } | - | ||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |