Mercurial > dovecot > core-2.2
annotate src/lib/md5.c @ 22664:fea53c2725c0
director: Fix director_max_parallel_moves/kicks type
Should be uint, not time.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 09 Nov 2017 12:24:16 +0200 |
parents | 59437f8764c6 |
children |
rev | line source |
---|---|
0 | 1 /* |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
2 * This is an OpenSSL-compatible implementation of the RSA Data Security, |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
3 * Inc. MD5 Message-Digest Algorithm. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
4 * |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
5 * Written by Solar Designer <solar@openwall.com> in 2001, and placed in |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
6 * the public domain. There's absolutely no warranty. |
0 | 7 * |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
8 * This differs from Colin Plumb's older public domain implementation in |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
9 * that no 32-bit integer data type is required, there's no compile-time |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
10 * endianness configuration, and the function prototypes match OpenSSL's. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
11 * The primary goals are portability and ease of use. |
0 | 12 * |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
13 * This implementation is meant to be fast, but not as fast as possible. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
14 * Some known optimizations are not included to reduce source code size |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
15 * and avoid compile-time configuration. |
0 | 16 */ |
17 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
18 #include "lib.h" |
2337
beefcc4249ef
md5_final() didn't properly clear the whole MD5 context. Also changed to use
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
19 #include "safe-memset.h" |
0 | 20 #include "md5.h" |
21 | |
22 /* | |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
23 * The basic MD5 functions. |
0 | 24 * |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
25 * F is optimized compared to its RFC 1321 definition just like in Colin |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
26 * Plumb's implementation. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
27 */ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
28 #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
29 #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
30 #define H(x, y, z) ((x) ^ (y) ^ (z)) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
31 #define I(x, y, z) ((y) ^ ((x) | ~(z))) |
0 | 32 |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
33 /* |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
34 * The MD5 transformation for all four rounds. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
35 */ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
36 #define STEP(f, a, b, c, d, x, t, s) \ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
37 (a) += f((b), (c), (d)) + (x) + (t); \ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
38 (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
39 (a) += (b); |
0 | 40 |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
41 /* |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
42 * SET reads 4 input bytes in little-endian byte order and stores them |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
43 * in a properly aligned word in host byte order. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
44 * |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
45 * The check for little-endian architectures which tolerate unaligned |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
46 * memory accesses is just an optimization. Nothing will break if it |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
47 * doesn't work. |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
48 */ |
4380
7eef9a1c51c4
MD4 was broken with 64bit systems. Added a few x86-64 optimizations. Patch
Timo Sirainen <tss@iki.fi>
parents:
2337
diff
changeset
|
49 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
50 #define SET(n) \ |
17336
fc627348087e
lib: fix md4/md5 buffer read overrun
Phil Carmody <phil@dovecot.fi>
parents:
14689
diff
changeset
|
51 (*(const uint32_t *)&ptr[(n) * 4]) |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
52 #define GET(n) \ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
53 SET(n) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
54 #else |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
55 #define SET(n) \ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
56 (ctx->block[(n)] = \ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
57 (uint_fast32_t)ptr[(n) * 4] | \ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
58 ((uint_fast32_t)ptr[(n) * 4 + 1] << 8) | \ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
59 ((uint_fast32_t)ptr[(n) * 4 + 2] << 16) | \ |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
60 ((uint_fast32_t)ptr[(n) * 4 + 3] << 24)) |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
61 #define GET(n) \ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
62 (ctx->block[(n)]) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
63 #endif |
0 | 64 |
65 /* | |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
66 * This processes one or more 64-byte data blocks, but does NOT update |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
67 * the bit counters. There're no alignment requirements. |
0 | 68 */ |
21210
c1106ebf55c0
lib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20652
diff
changeset
|
69 static const void * ATTR_NOWARN_UNUSED_RESULT ATTR_UNSIGNED_WRAPS |
14689
096e4c4d62bb
Try to avoid (void) casts by adding more ATTR_NOWARN_UNUSED_RESULT.
Timo Sirainen <tss@iki.fi>
parents:
14682
diff
changeset
|
70 body(struct md5_context *ctx, const void *data, size_t size) |
0 | 71 { |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
72 const unsigned char *ptr; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
73 uint_fast32_t a, b, c, d; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
74 uint_fast32_t saved_a, saved_b, saved_c, saved_d; |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
75 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
76 ptr = data; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
77 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
78 a = ctx->a; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
79 b = ctx->b; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
80 c = ctx->c; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
81 d = ctx->d; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
82 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
83 do { |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
84 saved_a = a; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
85 saved_b = b; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
86 saved_c = c; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
87 saved_d = d; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
88 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
89 /* Round 1 */ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
90 STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
91 STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
92 STEP(F, c, d, a, b, SET(2), 0x242070db, 17) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
93 STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
94 STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
95 STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
96 STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
97 STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
98 STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
99 STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
100 STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
101 STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
102 STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
103 STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
104 STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
105 STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
106 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
107 /* Round 2 */ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
108 STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
109 STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
110 STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
111 STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
112 STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
113 STEP(G, d, a, b, c, GET(10), 0x02441453, 9) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
114 STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
115 STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
116 STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
117 STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
118 STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
119 STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
120 STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
121 STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
122 STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
123 STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
124 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
125 /* Round 3 */ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
126 STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
127 STEP(H, d, a, b, c, GET(8), 0x8771f681, 11) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
128 STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
129 STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
130 STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
131 STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
132 STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
133 STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
134 STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
135 STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
136 STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
137 STEP(H, b, c, d, a, GET(6), 0x04881d05, 23) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
138 STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
139 STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
140 STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
141 STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
142 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
143 /* Round 4 */ |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
144 STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
145 STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
146 STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
147 STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
148 STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
149 STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
150 STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
151 STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
152 STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
153 STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
154 STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
155 STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
156 STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
157 STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
158 STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
159 STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
160 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
161 a += saved_a; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
162 b += saved_b; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
163 c += saved_c; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
164 d += saved_d; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
165 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
166 ptr += 64; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
167 } while (size -= 64); |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
168 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
169 ctx->a = a; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
170 ctx->b = b; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
171 ctx->c = c; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
172 ctx->d = d; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
173 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
174 return ptr; |
0 | 175 } |
176 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
177 void md5_init(struct md5_context *ctx) |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
178 { |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
179 ctx->a = 0x67452301; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
180 ctx->b = 0xefcdab89; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
181 ctx->c = 0x98badcfe; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
182 ctx->d = 0x10325476; |
0 | 183 |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
184 ctx->lo = 0; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
185 ctx->hi = 0; |
20652 | 186 memset(ctx->block, 0, sizeof(ctx->block)); |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
187 } |
0 | 188 |
21210
c1106ebf55c0
lib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20652
diff
changeset
|
189 void ATTR_UNSIGNED_WRAPS |
c1106ebf55c0
lib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20652
diff
changeset
|
190 md5_update(struct md5_context *ctx, const void *data, size_t size) |
0 | 191 { |
805
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
579
diff
changeset
|
192 /* @UNSAFE */ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
193 uint_fast32_t saved_lo; |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
194 unsigned long used, free; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
195 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
196 saved_lo = ctx->lo; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
197 if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
198 ctx->hi++; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
199 ctx->hi += size >> 29; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
200 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
201 used = saved_lo & 0x3f; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
202 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
203 if (used) { |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
204 free = 64 - used; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
205 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
206 if (size < free) { |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
207 memcpy(&ctx->buffer[used], data, size); |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
208 return; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
209 } |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
210 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
211 memcpy(&ctx->buffer[used], data, free); |
579
e524da896d92
Several minor fixes: signess, casting away const, missing static, etc.
Timo Sirainen <tss@iki.fi>
parents:
346
diff
changeset
|
212 data = (const unsigned char *) data + free; |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
213 size -= free; |
14689
096e4c4d62bb
Try to avoid (void) casts by adding more ATTR_NOWARN_UNUSED_RESULT.
Timo Sirainen <tss@iki.fi>
parents:
14682
diff
changeset
|
214 body(ctx, ctx->buffer, 64); |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
215 } |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
216 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
217 if (size >= 64) { |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
218 data = body(ctx, data, size & ~(unsigned long)0x3f); |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
219 size &= 0x3f; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
220 } |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
221 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
222 memcpy(ctx->buffer, data, size); |
0 | 223 } |
224 | |
21210
c1106ebf55c0
lib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20652
diff
changeset
|
225 void ATTR_UNSIGNED_WRAPS |
c1106ebf55c0
lib: Mark md4/md5/sha1/sha2 code with ATTR_UNSIGNED_WRAPS
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20652
diff
changeset
|
226 md5_final(struct md5_context *ctx, unsigned char result[STATIC_ARRAY MD5_RESULTLEN]) |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
227 { |
805
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
579
diff
changeset
|
228 /* @UNSAFE */ |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
229 unsigned long used, free; |
0 | 230 |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
231 used = ctx->lo & 0x3f; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
232 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
233 ctx->buffer[used++] = 0x80; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
234 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
235 free = 64 - used; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
236 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
237 if (free < 8) { |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
238 memset(&ctx->buffer[used], 0, free); |
14689
096e4c4d62bb
Try to avoid (void) casts by adding more ATTR_NOWARN_UNUSED_RESULT.
Timo Sirainen <tss@iki.fi>
parents:
14682
diff
changeset
|
239 body(ctx, ctx->buffer, 64); |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
240 used = 0; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
241 free = 64; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
242 } |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
243 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
244 memset(&ctx->buffer[used], 0, free - 8); |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
245 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
246 ctx->lo <<= 3; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
247 ctx->buffer[56] = ctx->lo; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
248 ctx->buffer[57] = ctx->lo >> 8; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
249 ctx->buffer[58] = ctx->lo >> 16; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
250 ctx->buffer[59] = ctx->lo >> 24; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
251 ctx->buffer[60] = ctx->hi; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
252 ctx->buffer[61] = ctx->hi >> 8; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
253 ctx->buffer[62] = ctx->hi >> 16; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
254 ctx->buffer[63] = ctx->hi >> 24; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
255 |
14689
096e4c4d62bb
Try to avoid (void) casts by adding more ATTR_NOWARN_UNUSED_RESULT.
Timo Sirainen <tss@iki.fi>
parents:
14682
diff
changeset
|
256 body(ctx, ctx->buffer, 64); |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
257 |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
258 result[0] = ctx->a; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
259 result[1] = ctx->a >> 8; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
260 result[2] = ctx->a >> 16; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
261 result[3] = ctx->a >> 24; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
262 result[4] = ctx->b; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
263 result[5] = ctx->b >> 8; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
264 result[6] = ctx->b >> 16; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
265 result[7] = ctx->b >> 24; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
266 result[8] = ctx->c; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
267 result[9] = ctx->c >> 8; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
268 result[10] = ctx->c >> 16; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
269 result[11] = ctx->c >> 24; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
270 result[12] = ctx->d; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
271 result[13] = ctx->d >> 8; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
272 result[14] = ctx->d >> 16; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
273 result[15] = ctx->d >> 24; |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
274 |
21389
59437f8764c6
global: Replaced all instances of memset(p, 0, sizeof(*p)) with the new i_zero() macro.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21210
diff
changeset
|
275 i_zero_safe(ctx); |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
276 } |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
277 |
4642 | 278 void md5_get_digest(const void *data, size_t size, |
20328
7e016f5e8cb4
[LEN] to [static LEN] on some function parameters
Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
parents:
17336
diff
changeset
|
279 unsigned char result[STATIC_ARRAY MD5_RESULTLEN]) |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
280 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
805
diff
changeset
|
281 struct md5_context ctx; |
0 | 282 |
21
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
283 md5_init(&ctx); |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
284 md5_update(&ctx, data, size); |
163675942b83
Replaced the MD5 implementation with Solar Designer's.
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
285 md5_final(&ctx, result); |
0 | 286 } |
12307
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
287 |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
288 static void hash_method_init_md5(void *context) |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
289 { |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
290 md5_init(context); |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
291 } |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
292 static void hash_method_loop_md5(void *context, const void *data, size_t size) |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
293 { |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
294 md5_update(context, data, size); |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
295 } |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
296 |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
297 static void hash_method_result_md5(void *context, unsigned char *result_r) |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
298 { |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
299 md5_final(context, result_r); |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
300 } |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
301 |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
302 const struct hash_method hash_method_md5 = { |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
303 "md5", |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
304 sizeof(struct md5_context), |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
305 MD5_RESULTLEN, |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
306 |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
307 hash_method_init_md5, |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
308 hash_method_loop_md5, |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
309 hash_method_result_md5 |
368fd1cce4d6
liblib: Added a common API for accessing all hash methods.
Timo Sirainen <tss@iki.fi>
parents:
4642
diff
changeset
|
310 }; |