tools/../../3rdparty/md4/md4.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5static const unsigned char *body(struct md4_context *ctx, const unsigned char *data, size_t size) -
6{ -
7 const unsigned char *ptr; -
8 quint32 a, b, c, d; -
9 quint32 saved_a, saved_b, saved_c, saved_d; -
10 -
11 ptr = data; -
12 -
13 a = ctx->a; -
14 b = ctx->b; -
15 c = ctx->c; -
16 d = ctx->d; -
17 -
18 do { -
19 saved_a = a; -
20 saved_b = b; -
21 saved_c = c; -
22 saved_d = d; -
23 -
24 -
25 (a) += (((d)) ^ (((b)) & (((c)) ^ ((d))))) + ((*(const quint32 *)&ptr[(0) * 4])); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
26 (d) += (((c)) ^ (((a)) & (((b)) ^ ((c))))) + ((*(const quint32 *)&ptr[(1) * 4])); (d) = ((d) << (7)) | ((d) >> (32 - (7))); -
27 (c) += (((b)) ^ (((d)) & (((a)) ^ ((b))))) + ((*(const quint32 *)&ptr[(2) * 4])); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
28 (b) += (((a)) ^ (((c)) & (((d)) ^ ((a))))) + ((*(const quint32 *)&ptr[(3) * 4])); (b) = ((b) << (19)) | ((b) >> (32 - (19))); -
29 -
30 (a) += (((d)) ^ (((b)) & (((c)) ^ ((d))))) + ((*(const quint32 *)&ptr[(4) * 4])); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
31 (d) += (((c)) ^ (((a)) & (((b)) ^ ((c))))) + ((*(const quint32 *)&ptr[(5) * 4])); (d) = ((d) << (7)) | ((d) >> (32 - (7))); -
32 (c) += (((b)) ^ (((d)) & (((a)) ^ ((b))))) + ((*(const quint32 *)&ptr[(6) * 4])); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
33 (b) += (((a)) ^ (((c)) & (((d)) ^ ((a))))) + ((*(const quint32 *)&ptr[(7) * 4])); (b) = ((b) << (19)) | ((b) >> (32 - (19))); -
34 -
35 (a) += (((d)) ^ (((b)) & (((c)) ^ ((d))))) + ((*(const quint32 *)&ptr[(8) * 4])); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
36 (d) += (((c)) ^ (((a)) & (((b)) ^ ((c))))) + ((*(const quint32 *)&ptr[(9) * 4])); (d) = ((d) << (7)) | ((d) >> (32 - (7))); -
37 (c) += (((b)) ^ (((d)) & (((a)) ^ ((b))))) + ((*(const quint32 *)&ptr[(10) * 4])); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
38 (b) += (((a)) ^ (((c)) & (((d)) ^ ((a))))) + ((*(const quint32 *)&ptr[(11) * 4])); (b) = ((b) << (19)) | ((b) >> (32 - (19))); -
39 -
40 (a) += (((d)) ^ (((b)) & (((c)) ^ ((d))))) + ((*(const quint32 *)&ptr[(12) * 4])); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
41 (d) += (((c)) ^ (((a)) & (((b)) ^ ((c))))) + ((*(const quint32 *)&ptr[(13) * 4])); (d) = ((d) << (7)) | ((d) >> (32 - (7))); -
42 (c) += (((b)) ^ (((d)) & (((a)) ^ ((b))))) + ((*(const quint32 *)&ptr[(14) * 4])); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
43 (b) += (((a)) ^ (((c)) & (((d)) ^ ((a))))) + ((*(const quint32 *)&ptr[(15) * 4])); (b) = ((b) << (19)) | ((b) >> (32 - (19))); -
44 -
45 (a) += ((((b)) & ((c))) | (((b)) & ((d))) | (((c)) & ((d)))) + ((*(const quint32 *)&ptr[(0) * 4]) + 0x5A827999); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
46 (d) += ((((a)) & ((b))) | (((a)) & ((c))) | (((b)) & ((c)))) + ((*(const quint32 *)&ptr[(4) * 4]) + 0x5A827999); (d) = ((d) << (5)) | ((d) >> (32 - (5))); -
47 (c) += ((((d)) & ((a))) | (((d)) & ((b))) | (((a)) & ((b)))) + ((*(const quint32 *)&ptr[(8) * 4]) + 0x5A827999); (c) = ((c) << (9)) | ((c) >> (32 - (9))); -
48 (b) += ((((c)) & ((d))) | (((c)) & ((a))) | (((d)) & ((a)))) + ((*(const quint32 *)&ptr[(12) * 4]) + 0x5A827999); (b) = ((b) << (13)) | ((b) >> (32 - (13))); -
49 -
50 (a) += ((((b)) & ((c))) | (((b)) & ((d))) | (((c)) & ((d)))) + ((*(const quint32 *)&ptr[(1) * 4]) + 0x5A827999); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
51 (d) += ((((a)) & ((b))) | (((a)) & ((c))) | (((b)) & ((c)))) + ((*(const quint32 *)&ptr[(5) * 4]) + 0x5A827999); (d) = ((d) << (5)) | ((d) >> (32 - (5))); -
52 (c) += ((((d)) & ((a))) | (((d)) & ((b))) | (((a)) & ((b)))) + ((*(const quint32 *)&ptr[(9) * 4]) + 0x5A827999); (c) = ((c) << (9)) | ((c) >> (32 - (9))); -
53 (b) += ((((c)) & ((d))) | (((c)) & ((a))) | (((d)) & ((a)))) + ((*(const quint32 *)&ptr[(13) * 4]) + 0x5A827999); (b) = ((b) << (13)) | ((b) >> (32 - (13))); -
54 -
55 (a) += ((((b)) & ((c))) | (((b)) & ((d))) | (((c)) & ((d)))) + ((*(const quint32 *)&ptr[(2) * 4]) + 0x5A827999); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
56 (d) += ((((a)) & ((b))) | (((a)) & ((c))) | (((b)) & ((c)))) + ((*(const quint32 *)&ptr[(6) * 4]) + 0x5A827999); (d) = ((d) << (5)) | ((d) >> (32 - (5))); -
57 (c) += ((((d)) & ((a))) | (((d)) & ((b))) | (((a)) & ((b)))) + ((*(const quint32 *)&ptr[(10) * 4]) + 0x5A827999); (c) = ((c) << (9)) | ((c) >> (32 - (9))); -
58 (b) += ((((c)) & ((d))) | (((c)) & ((a))) | (((d)) & ((a)))) + ((*(const quint32 *)&ptr[(14) * 4]) + 0x5A827999); (b) = ((b) << (13)) | ((b) >> (32 - (13))); -
59 -
60 (a) += ((((b)) & ((c))) | (((b)) & ((d))) | (((c)) & ((d)))) + ((*(const quint32 *)&ptr[(3) * 4]) + 0x5A827999); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
61 (d) += ((((a)) & ((b))) | (((a)) & ((c))) | (((b)) & ((c)))) + ((*(const quint32 *)&ptr[(7) * 4]) + 0x5A827999); (d) = ((d) << (5)) | ((d) >> (32 - (5))); -
62 (c) += ((((d)) & ((a))) | (((d)) & ((b))) | (((a)) & ((b)))) + ((*(const quint32 *)&ptr[(11) * 4]) + 0x5A827999); (c) = ((c) << (9)) | ((c) >> (32 - (9))); -
63 (b) += ((((c)) & ((d))) | (((c)) & ((a))) | (((d)) & ((a)))) + ((*(const quint32 *)&ptr[(15) * 4]) + 0x5A827999); (b) = ((b) << (13)) | ((b) >> (32 - (13))); -
64 -
65 (a) += (((b)) ^ ((c)) ^ ((d))) + ((*(const quint32 *)&ptr[(0) * 4]) + 0x6ED9EBA1); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
66 (d) += (((a)) ^ ((b)) ^ ((c))) + ((*(const quint32 *)&ptr[(8) * 4]) + 0x6ED9EBA1); (d) = ((d) << (9)) | ((d) >> (32 - (9))); -
67 (c) += (((d)) ^ ((a)) ^ ((b))) + ((*(const quint32 *)&ptr[(4) * 4]) + 0x6ED9EBA1); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
68 (b) += (((c)) ^ ((d)) ^ ((a))) + ((*(const quint32 *)&ptr[(12) * 4]) + 0x6ED9EBA1); (b) = ((b) << (15)) | ((b) >> (32 - (15))); -
69 -
70 (a) += (((b)) ^ ((c)) ^ ((d))) + ((*(const quint32 *)&ptr[(2) * 4]) + 0x6ED9EBA1); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
71 (d) += (((a)) ^ ((b)) ^ ((c))) + ((*(const quint32 *)&ptr[(10) * 4]) + 0x6ED9EBA1); (d) = ((d) << (9)) | ((d) >> (32 - (9))); -
72 (c) += (((d)) ^ ((a)) ^ ((b))) + ((*(const quint32 *)&ptr[(6) * 4]) + 0x6ED9EBA1); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
73 (b) += (((c)) ^ ((d)) ^ ((a))) + ((*(const quint32 *)&ptr[(14) * 4]) + 0x6ED9EBA1); (b) = ((b) << (15)) | ((b) >> (32 - (15))); -
74 -
75 (a) += (((b)) ^ ((c)) ^ ((d))) + ((*(const quint32 *)&ptr[(1) * 4]) + 0x6ED9EBA1); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
76 (d) += (((a)) ^ ((b)) ^ ((c))) + ((*(const quint32 *)&ptr[(9) * 4]) + 0x6ED9EBA1); (d) = ((d) << (9)) | ((d) >> (32 - (9))); -
77 (c) += (((d)) ^ ((a)) ^ ((b))) + ((*(const quint32 *)&ptr[(5) * 4]) + 0x6ED9EBA1); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
78 (b) += (((c)) ^ ((d)) ^ ((a))) + ((*(const quint32 *)&ptr[(13) * 4]) + 0x6ED9EBA1); (b) = ((b) << (15)) | ((b) >> (32 - (15))); -
79 -
80 (a) += (((b)) ^ ((c)) ^ ((d))) + ((*(const quint32 *)&ptr[(3) * 4]) + 0x6ED9EBA1); (a) = ((a) << (3)) | ((a) >> (32 - (3))); -
81 (d) += (((a)) ^ ((b)) ^ ((c))) + ((*(const quint32 *)&ptr[(11) * 4]) + 0x6ED9EBA1); (d) = ((d) << (9)) | ((d) >> (32 - (9))); -
82 (c) += (((d)) ^ ((a)) ^ ((b))) + ((*(const quint32 *)&ptr[(7) * 4]) + 0x6ED9EBA1); (c) = ((c) << (11)) | ((c) >> (32 - (11))); -
83 (b) += (((c)) ^ ((d)) ^ ((a))) + ((*(const quint32 *)&ptr[(15) * 4]) + 0x6ED9EBA1); (b) = ((b) << (15)) | ((b) >> (32 - (15))); -
84 -
85 a += saved_a; -
86 b += saved_b; -
87 c += saved_c; -
88 d += saved_d; -
89 -
90 ptr += 64; -
91 } while (size -= 64);
executed: }
Execution Count:4
partially evaluated: size -= 64
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
92 -
93 ctx->a = a; -
94 ctx->b = b; -
95 ctx->c = c; -
96 ctx->d = d; -
97 -
98 return ptr;
executed: return ptr;
Execution Count:4
4
99} -
100 -
101static void md4_init(struct md4_context *ctx) -
102{ -
103 ctx->a = 0x67452301; -
104 ctx->b = 0xefcdab89; -
105 ctx->c = 0x98badcfe; -
106 ctx->d = 0x10325476; -
107 -
108 ctx->lo = 0; -
109 ctx->hi = 0; -
110}
executed: }
Execution Count:4
4
111 -
112static void md4_update(struct md4_context *ctx, const unsigned char *data, size_t size) -
113{ -
114 -
115 quint32 saved_lo; -
116 unsigned long used, free; -
117 -
118 saved_lo = ctx->lo; -
119 if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
partially evaluated: (ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
120 ctx->hi++;
never executed: ctx->hi++;
0
121 ctx->hi += size >> 29; -
122 -
123 used = saved_lo & 0x3f; -
124 -
125 if (used) {
evaluated: used
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
126 free = 64 - used; -
127 -
128 if (size < free) {
partially evaluated: size < free
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
129 memcpy(&ctx->buffer[used], data, size); -
130 return;
executed: return;
Execution Count:1
1
131 } -
132 -
133 memcpy(&ctx->buffer[used], data, free); -
134 data = (const unsigned char *) data + free; -
135 size -= free; -
136 body(ctx, ctx->buffer, 64); -
137 }
never executed: }
0
138 -
139 if (size >= 64) {
partially evaluated: size >= 64
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
140 data = body(ctx, data, size & ~(unsigned long)0x3f); -
141 size &= 0x3f; -
142 }
never executed: }
0
143 -
144 memcpy(ctx->buffer, data, size); -
145}
executed: }
Execution Count:3
3
146 -
147static void md4_final(struct md4_context *ctx, unsigned char result[(128/8)]) -
148{ -
149 -
150 unsigned long used, free; -
151 -
152 used = ctx->lo & 0x3f; -
153 -
154 ctx->buffer[used++] = 0x80; -
155 -
156 free = 64 - used; -
157 -
158 if (free < 8) {
partially evaluated: free < 8
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
159 memset(&ctx->buffer[used], 0, free); -
160 body(ctx, ctx->buffer, 64); -
161 used = 0; -
162 free = 64; -
163 }
never executed: }
0
164 -
165 memset(&ctx->buffer[used], 0, free - 8); -
166 -
167 ctx->lo <<= 3; -
168 ctx->buffer[56] = ctx->lo; -
169 ctx->buffer[57] = ctx->lo >> 8; -
170 ctx->buffer[58] = ctx->lo >> 16; -
171 ctx->buffer[59] = ctx->lo >> 24; -
172 ctx->buffer[60] = ctx->hi; -
173 ctx->buffer[61] = ctx->hi >> 8; -
174 ctx->buffer[62] = ctx->hi >> 16; -
175 ctx->buffer[63] = ctx->hi >> 24; -
176 -
177 body(ctx, ctx->buffer, 64); -
178 -
179 result[0] = ctx->a; -
180 result[1] = ctx->a >> 8; -
181 result[2] = ctx->a >> 16; -
182 result[3] = ctx->a >> 24; -
183 result[4] = ctx->b; -
184 result[5] = ctx->b >> 8; -
185 result[6] = ctx->b >> 16; -
186 result[7] = ctx->b >> 24; -
187 result[8] = ctx->c; -
188 result[9] = ctx->c >> 8; -
189 result[10] = ctx->c >> 16; -
190 result[11] = ctx->c >> 24; -
191 result[12] = ctx->d; -
192 result[13] = ctx->d >> 8; -
193 result[14] = ctx->d >> 16; -
194 result[15] = ctx->d >> 24; -
195 -
196 memset(ctx, 0, sizeof(*ctx)); -
197}
executed: }
Execution Count:4
4
198 -
199 -
200 -
201 -
202 -
203 -
204 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial