tools/../../3rdparty/md5/md5.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4static void -
5byteSwap(UWORD32 *buf, unsigned words) -
6{ -
7 const quint32 byteOrderTest = 0x1; -
8 if (((char *)&byteOrderTest)[0] == 0) {
partially evaluated: ((char *)&byteOrderTest)[0] == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:641059
0-641059
9 md5byte *p = (md5byte *)buf; -
10 -
11 do { -
12 *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 | -
13 ((unsigned)p[1] << 8 | p[0]); -
14 p += 4; -
15 } while (--words);
never executed: }
never evaluated: --words
0
16 }
never executed: }
0
17}
executed: }
Execution Count:641059
641059
18 -
19 -
20 -
21 -
22 -
23static void -
24MD5Init(struct MD5Context *ctx) -
25{ -
26 ctx->buf[0] = 0x67452301; -
27 ctx->buf[1] = 0xefcdab89; -
28 ctx->buf[2] = 0x98badcfe; -
29 ctx->buf[3] = 0x10325476; -
30 -
31 ctx->bytes[0] = 0; -
32 ctx->bytes[1] = 0; -
33}
executed: }
Execution Count:2120
2120
34 -
35 -
36 -
37 -
38 -
39static void -
40MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) -
41{ -
42 UWORD32 t; -
43 -
44 -
45 -
46 t = ctx->bytes[0]; -
47 if ((ctx->bytes[0] = t + len) < t)
partially evaluated: (ctx->bytes[0] = t + len) < t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2657
0-2657
48 ctx->bytes[1]++;
never executed: ctx->bytes[1]++;
0
49 -
50 t = 64 - (t & 0x3f); -
51 if (t > len) {
evaluated: t > len
TRUEFALSE
yes
Evaluation Count:2453
yes
Evaluation Count:204
204-2453
52 memcpy((md5byte *)ctx->in + 64 - t, buf, len); -
53 return;
executed: return;
Execution Count:2453
2453
54 } -
55 -
56 memcpy((md5byte *)ctx->in + 64 - t, buf, t); -
57 byteSwap(ctx->in, 16); -
58 MD5Transform(ctx->buf, ctx->in); -
59 buf += t; -
60 len -= t; -
61 -
62 -
63 while (len >= 64) {
evaluated: len >= 64
TRUEFALSE
yes
Evaluation Count:636611
yes
Evaluation Count:204
204-636611
64 memcpy(ctx->in, buf, 64); -
65 byteSwap(ctx->in, 16); -
66 MD5Transform(ctx->buf, ctx->in); -
67 buf += 64; -
68 len -= 64; -
69 }
executed: }
Execution Count:636611
636611
70 -
71 -
72 memcpy(ctx->in, buf, len); -
73}
executed: }
Execution Count:204
204
74 -
75 -
76 -
77 -
78 -
79static void -
80MD5Final(struct MD5Context *ctx, md5byte digest[16]) -
81{ -
82 int count = ctx->bytes[0] & 0x3f; -
83 md5byte *p = (md5byte *)ctx->in + count; -
84 -
85 -
86 *p++ = 0x80; -
87 -
88 -
89 count = 56 - 1 - count; -
90 -
91 if (count < 0) {
evaluated: count < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2116
4-2116
92 memset(p, 0, count + 8); -
93 byteSwap(ctx->in, 16); -
94 MD5Transform(ctx->buf, ctx->in); -
95 p = (md5byte *)ctx->in; -
96 count = 56; -
97 }
executed: }
Execution Count:4
4
98 memset(p, 0, count); -
99 byteSwap(ctx->in, 14); -
100 -
101 -
102 ctx->in[14] = ctx->bytes[0] << 3; -
103 ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; -
104 MD5Transform(ctx->buf, ctx->in); -
105 -
106 byteSwap(ctx->buf, 4); -
107 memcpy(digest, ctx->buf, 16); -
108 memset(ctx, 0, sizeof(*ctx)); -
109}
executed: }
Execution Count:2120
2120
110static void -
111MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) -
112{ -
113 register UWORD32 a, b, c, d; -
114 -
115 a = buf[0]; -
116 b = buf[1]; -
117 c = buf[2]; -
118 d = buf[3]; -
119 -
120 (a += (d ^ (b & (c ^ d))) + in[0] + 0xd76aa478, a = (a<<7 | a>>(32-7)) + b); -
121 (d += (c ^ (a & (b ^ c))) + in[1] + 0xe8c7b756, d = (d<<12 | d>>(32-12)) + a); -
122 (c += (b ^ (d & (a ^ b))) + in[2] + 0x242070db, c = (c<<17 | c>>(32-17)) + d); -
123 (b += (a ^ (c & (d ^ a))) + in[3] + 0xc1bdceee, b = (b<<22 | b>>(32-22)) + c); -
124 (a += (d ^ (b & (c ^ d))) + in[4] + 0xf57c0faf, a = (a<<7 | a>>(32-7)) + b); -
125 (d += (c ^ (a & (b ^ c))) + in[5] + 0x4787c62a, d = (d<<12 | d>>(32-12)) + a); -
126 (c += (b ^ (d & (a ^ b))) + in[6] + 0xa8304613, c = (c<<17 | c>>(32-17)) + d); -
127 (b += (a ^ (c & (d ^ a))) + in[7] + 0xfd469501, b = (b<<22 | b>>(32-22)) + c); -
128 (a += (d ^ (b & (c ^ d))) + in[8] + 0x698098d8, a = (a<<7 | a>>(32-7)) + b); -
129 (d += (c ^ (a & (b ^ c))) + in[9] + 0x8b44f7af, d = (d<<12 | d>>(32-12)) + a); -
130 (c += (b ^ (d & (a ^ b))) + in[10] + 0xffff5bb1, c = (c<<17 | c>>(32-17)) + d); -
131 (b += (a ^ (c & (d ^ a))) + in[11] + 0x895cd7be, b = (b<<22 | b>>(32-22)) + c); -
132 (a += (d ^ (b & (c ^ d))) + in[12] + 0x6b901122, a = (a<<7 | a>>(32-7)) + b); -
133 (d += (c ^ (a & (b ^ c))) + in[13] + 0xfd987193, d = (d<<12 | d>>(32-12)) + a); -
134 (c += (b ^ (d & (a ^ b))) + in[14] + 0xa679438e, c = (c<<17 | c>>(32-17)) + d); -
135 (b += (a ^ (c & (d ^ a))) + in[15] + 0x49b40821, b = (b<<22 | b>>(32-22)) + c); -
136 -
137 (a += (c ^ (d & (b ^ c))) + in[1] + 0xf61e2562, a = (a<<5 | a>>(32-5)) + b); -
138 (d += (b ^ (c & (a ^ b))) + in[6] + 0xc040b340, d = (d<<9 | d>>(32-9)) + a); -
139 (c += (a ^ (b & (d ^ a))) + in[11] + 0x265e5a51, c = (c<<14 | c>>(32-14)) + d); -
140 (b += (d ^ (a & (c ^ d))) + in[0] + 0xe9b6c7aa, b = (b<<20 | b>>(32-20)) + c); -
141 (a += (c ^ (d & (b ^ c))) + in[5] + 0xd62f105d, a = (a<<5 | a>>(32-5)) + b); -
142 (d += (b ^ (c & (a ^ b))) + in[10] + 0x02441453, d = (d<<9 | d>>(32-9)) + a); -
143 (c += (a ^ (b & (d ^ a))) + in[15] + 0xd8a1e681, c = (c<<14 | c>>(32-14)) + d); -
144 (b += (d ^ (a & (c ^ d))) + in[4] + 0xe7d3fbc8, b = (b<<20 | b>>(32-20)) + c); -
145 (a += (c ^ (d & (b ^ c))) + in[9] + 0x21e1cde6, a = (a<<5 | a>>(32-5)) + b); -
146 (d += (b ^ (c & (a ^ b))) + in[14] + 0xc33707d6, d = (d<<9 | d>>(32-9)) + a); -
147 (c += (a ^ (b & (d ^ a))) + in[3] + 0xf4d50d87, c = (c<<14 | c>>(32-14)) + d); -
148 (b += (d ^ (a & (c ^ d))) + in[8] + 0x455a14ed, b = (b<<20 | b>>(32-20)) + c); -
149 (a += (c ^ (d & (b ^ c))) + in[13] + 0xa9e3e905, a = (a<<5 | a>>(32-5)) + b); -
150 (d += (b ^ (c & (a ^ b))) + in[2] + 0xfcefa3f8, d = (d<<9 | d>>(32-9)) + a); -
151 (c += (a ^ (b & (d ^ a))) + in[7] + 0x676f02d9, c = (c<<14 | c>>(32-14)) + d); -
152 (b += (d ^ (a & (c ^ d))) + in[12] + 0x8d2a4c8a, b = (b<<20 | b>>(32-20)) + c); -
153 -
154 (a += (b ^ c ^ d) + in[5] + 0xfffa3942, a = (a<<4 | a>>(32-4)) + b); -
155 (d += (a ^ b ^ c) + in[8] + 0x8771f681, d = (d<<11 | d>>(32-11)) + a); -
156 (c += (d ^ a ^ b) + in[11] + 0x6d9d6122, c = (c<<16 | c>>(32-16)) + d); -
157 (b += (c ^ d ^ a) + in[14] + 0xfde5380c, b = (b<<23 | b>>(32-23)) + c); -
158 (a += (b ^ c ^ d) + in[1] + 0xa4beea44, a = (a<<4 | a>>(32-4)) + b); -
159 (d += (a ^ b ^ c) + in[4] + 0x4bdecfa9, d = (d<<11 | d>>(32-11)) + a); -
160 (c += (d ^ a ^ b) + in[7] + 0xf6bb4b60, c = (c<<16 | c>>(32-16)) + d); -
161 (b += (c ^ d ^ a) + in[10] + 0xbebfbc70, b = (b<<23 | b>>(32-23)) + c); -
162 (a += (b ^ c ^ d) + in[13] + 0x289b7ec6, a = (a<<4 | a>>(32-4)) + b); -
163 (d += (a ^ b ^ c) + in[0] + 0xeaa127fa, d = (d<<11 | d>>(32-11)) + a); -
164 (c += (d ^ a ^ b) + in[3] + 0xd4ef3085, c = (c<<16 | c>>(32-16)) + d); -
165 (b += (c ^ d ^ a) + in[6] + 0x04881d05, b = (b<<23 | b>>(32-23)) + c); -
166 (a += (b ^ c ^ d) + in[9] + 0xd9d4d039, a = (a<<4 | a>>(32-4)) + b); -
167 (d += (a ^ b ^ c) + in[12] + 0xe6db99e5, d = (d<<11 | d>>(32-11)) + a); -
168 (c += (d ^ a ^ b) + in[15] + 0x1fa27cf8, c = (c<<16 | c>>(32-16)) + d); -
169 (b += (c ^ d ^ a) + in[2] + 0xc4ac5665, b = (b<<23 | b>>(32-23)) + c); -
170 -
171 (a += (c ^ (b | ~d)) + in[0] + 0xf4292244, a = (a<<6 | a>>(32-6)) + b); -
172 (d += (b ^ (a | ~c)) + in[7] + 0x432aff97, d = (d<<10 | d>>(32-10)) + a); -
173 (c += (a ^ (d | ~b)) + in[14] + 0xab9423a7, c = (c<<15 | c>>(32-15)) + d); -
174 (b += (d ^ (c | ~a)) + in[5] + 0xfc93a039, b = (b<<21 | b>>(32-21)) + c); -
175 (a += (c ^ (b | ~d)) + in[12] + 0x655b59c3, a = (a<<6 | a>>(32-6)) + b); -
176 (d += (b ^ (a | ~c)) + in[3] + 0x8f0ccc92, d = (d<<10 | d>>(32-10)) + a); -
177 (c += (a ^ (d | ~b)) + in[10] + 0xffeff47d, c = (c<<15 | c>>(32-15)) + d); -
178 (b += (d ^ (c | ~a)) + in[1] + 0x85845dd1, b = (b<<21 | b>>(32-21)) + c); -
179 (a += (c ^ (b | ~d)) + in[8] + 0x6fa87e4f, a = (a<<6 | a>>(32-6)) + b); -
180 (d += (b ^ (a | ~c)) + in[15] + 0xfe2ce6e0, d = (d<<10 | d>>(32-10)) + a); -
181 (c += (a ^ (d | ~b)) + in[6] + 0xa3014314, c = (c<<15 | c>>(32-15)) + d); -
182 (b += (d ^ (c | ~a)) + in[13] + 0x4e0811a1, b = (b<<21 | b>>(32-21)) + c); -
183 (a += (c ^ (b | ~d)) + in[4] + 0xf7537e82, a = (a<<6 | a>>(32-6)) + b); -
184 (d += (b ^ (a | ~c)) + in[11] + 0xbd3af235, d = (d<<10 | d>>(32-10)) + a); -
185 (c += (a ^ (d | ~b)) + in[2] + 0x2ad7d2bb, c = (c<<15 | c>>(32-15)) + d); -
186 (b += (d ^ (c | ~a)) + in[9] + 0xeb86d391, b = (b<<21 | b>>(32-21)) + c); -
187 -
188 buf[0] += a; -
189 buf[1] += b; -
190 buf[2] += c; -
191 buf[3] += d; -
192}
executed: }
Execution Count:638939
638939
193 -
194 -
195 -
196 -
197 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial