Mercurial > hg > nginx-quic
annotate src/core/ngx_sha1.c @ 7247:b329c0ab1a48
Configure: restored "no-threads" in OpenSSL builds.
This was previously used, but was incorrectly removed in 83d54192e97b
while removing old threads remnants. Instead of using it conditionally
when threads are not used, we now set in unconditionally, as even with
thread pools enabled we never call OpenSSL functions in threads.
This fixes resulting binary when using --with-openssl with OpenSSL 1.1.0+
and without -lpthread linked (notably on FreeBSD without PCRE).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 22 Mar 2018 15:56:07 +0300 |
parents | 9eefb38f0005 |
children |
rev | line source |
---|---|
6586
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 /* |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 * Copyright (C) Maxim Dounin |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 * Copyright (C) Nginx, Inc. |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 * |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 * An internal SHA1 implementation. |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 */ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 #include <ngx_config.h> |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 #include <ngx_core.h> |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 #include <ngx_sha1.h> |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 static const u_char *ngx_sha1_body(ngx_sha1_t *ctx, const u_char *data, |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 size_t size); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 void |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 ngx_sha1_init(ngx_sha1_t *ctx) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 ctx->a = 0x67452301; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 ctx->b = 0xefcdab89; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 ctx->c = 0x98badcfe; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ctx->d = 0x10325476; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 ctx->e = 0xc3d2e1f0; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ctx->bytes = 0; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 void |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 ngx_sha1_update(ngx_sha1_t *ctx, const void *data, size_t size) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 size_t used, free; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 used = (size_t) (ctx->bytes & 0x3f); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 ctx->bytes += size; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 if (used) { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 free = 64 - used; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 if (size < free) { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 ngx_memcpy(&ctx->buffer[used], data, size); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 return; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 ngx_memcpy(&ctx->buffer[used], data, free); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 data = (u_char *) data + free; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 size -= free; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 (void) ngx_sha1_body(ctx, ctx->buffer, 64); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 if (size >= 64) { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 data = ngx_sha1_body(ctx, data, size & ~(size_t) 0x3f); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 size &= 0x3f; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 ngx_memcpy(ctx->buffer, data, size); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 void |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 ngx_sha1_final(u_char result[20], ngx_sha1_t *ctx) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 size_t used, free; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 used = (size_t) (ctx->bytes & 0x3f); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 ctx->buffer[used++] = 0x80; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 free = 64 - used; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 if (free < 8) { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 ngx_memzero(&ctx->buffer[used], free); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 (void) ngx_sha1_body(ctx, ctx->buffer, 64); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 used = 0; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 free = 64; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 ngx_memzero(&ctx->buffer[used], free - 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 ctx->bytes <<= 3; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 ctx->buffer[56] = (u_char) (ctx->bytes >> 56); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 ctx->buffer[57] = (u_char) (ctx->bytes >> 48); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 ctx->buffer[58] = (u_char) (ctx->bytes >> 40); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 ctx->buffer[59] = (u_char) (ctx->bytes >> 32); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 ctx->buffer[60] = (u_char) (ctx->bytes >> 24); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 ctx->buffer[61] = (u_char) (ctx->bytes >> 16); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 ctx->buffer[62] = (u_char) (ctx->bytes >> 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 ctx->buffer[63] = (u_char) ctx->bytes; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 (void) ngx_sha1_body(ctx, ctx->buffer, 64); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 result[0] = (u_char) (ctx->a >> 24); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 result[1] = (u_char) (ctx->a >> 16); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 result[2] = (u_char) (ctx->a >> 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 result[3] = (u_char) ctx->a; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 result[4] = (u_char) (ctx->b >> 24); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 result[5] = (u_char) (ctx->b >> 16); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 result[6] = (u_char) (ctx->b >> 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 result[7] = (u_char) ctx->b; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 result[8] = (u_char) (ctx->c >> 24); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 result[9] = (u_char) (ctx->c >> 16); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 result[10] = (u_char) (ctx->c >> 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 result[11] = (u_char) ctx->c; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 result[12] = (u_char) (ctx->d >> 24); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 result[13] = (u_char) (ctx->d >> 16); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 result[14] = (u_char) (ctx->d >> 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 result[15] = (u_char) ctx->d; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 result[16] = (u_char) (ctx->e >> 24); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 result[17] = (u_char) (ctx->e >> 16); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 result[18] = (u_char) (ctx->e >> 8); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 result[19] = (u_char) ctx->e; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 ngx_memzero(ctx, sizeof(*ctx)); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 /* |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 * Helper functions. |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 */ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 #define ROTATE(bits, word) (((word) << (bits)) | ((word) >> (32 - (bits)))) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 #define F1(b, c, d) (((b) & (c)) | ((~(b)) & (d))) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 #define F2(b, c, d) ((b) ^ (c) ^ (d)) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 #define F3(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 #define STEP(f, a, b, c, d, e, w, t) \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 temp = ROTATE(5, (a)) + f((b), (c), (d)) + (e) + (w) + (t); \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 (e) = (d); \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 (d) = (c); \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 (c) = ROTATE(30, (b)); \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 (b) = (a); \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 (a) = temp; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 /* |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 * GET() reads 4 input bytes in big-endian byte order and returns |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 * them as uint32_t. |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 */ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 #define GET(n) \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 ((uint32_t) p[n * 4 + 3] | \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 ((uint32_t) p[n * 4 + 2] << 8) | \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 ((uint32_t) p[n * 4 + 1] << 16) | \ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 ((uint32_t) p[n * 4] << 24)) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 /* |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 * This processes one or more 64-byte data blocks, but does not update |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 * the bit counters. There are no alignment requirements. |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 */ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 static const u_char * |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 ngx_sha1_body(ngx_sha1_t *ctx, const u_char *data, size_t size) |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 uint32_t a, b, c, d, e, temp; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 uint32_t saved_a, saved_b, saved_c, saved_d, saved_e; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 uint32_t words[80]; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 ngx_uint_t i; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 const u_char *p; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 p = data; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 a = ctx->a; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 b = ctx->b; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 c = ctx->c; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 d = ctx->d; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 e = ctx->e; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 do { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 saved_a = a; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 saved_b = b; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 saved_c = c; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 saved_d = d; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 saved_e = e; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 /* Load data block into the words array */ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 for (i = 0; i < 16; i++) { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 words[i] = GET(i); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 for (i = 16; i < 80; i++) { |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 words[i] = ROTATE(1, words[i - 3] ^ words[i - 8] ^ words[i - 14] |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 ^ words[i - 16]); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 } |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 /* Transformations */ |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 STEP(F1, a, b, c, d, e, words[0], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 STEP(F1, a, b, c, d, e, words[1], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 STEP(F1, a, b, c, d, e, words[2], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 STEP(F1, a, b, c, d, e, words[3], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 STEP(F1, a, b, c, d, e, words[4], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 STEP(F1, a, b, c, d, e, words[5], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 STEP(F1, a, b, c, d, e, words[6], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 STEP(F1, a, b, c, d, e, words[7], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 STEP(F1, a, b, c, d, e, words[8], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 STEP(F1, a, b, c, d, e, words[9], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
203 STEP(F1, a, b, c, d, e, words[10], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 STEP(F1, a, b, c, d, e, words[11], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 STEP(F1, a, b, c, d, e, words[12], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 STEP(F1, a, b, c, d, e, words[13], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 STEP(F1, a, b, c, d, e, words[14], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 STEP(F1, a, b, c, d, e, words[15], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 STEP(F1, a, b, c, d, e, words[16], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 STEP(F1, a, b, c, d, e, words[17], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 STEP(F1, a, b, c, d, e, words[18], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
212 STEP(F1, a, b, c, d, e, words[19], 0x5a827999); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
214 STEP(F2, a, b, c, d, e, words[20], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
215 STEP(F2, a, b, c, d, e, words[21], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 STEP(F2, a, b, c, d, e, words[22], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 STEP(F2, a, b, c, d, e, words[23], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
218 STEP(F2, a, b, c, d, e, words[24], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 STEP(F2, a, b, c, d, e, words[25], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 STEP(F2, a, b, c, d, e, words[26], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
221 STEP(F2, a, b, c, d, e, words[27], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 STEP(F2, a, b, c, d, e, words[28], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 STEP(F2, a, b, c, d, e, words[29], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 STEP(F2, a, b, c, d, e, words[30], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 STEP(F2, a, b, c, d, e, words[31], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 STEP(F2, a, b, c, d, e, words[32], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 STEP(F2, a, b, c, d, e, words[33], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 STEP(F2, a, b, c, d, e, words[34], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 STEP(F2, a, b, c, d, e, words[35], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 STEP(F2, a, b, c, d, e, words[36], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 STEP(F2, a, b, c, d, e, words[37], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 STEP(F2, a, b, c, d, e, words[38], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 STEP(F2, a, b, c, d, e, words[39], 0x6ed9eba1); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 STEP(F3, a, b, c, d, e, words[40], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 STEP(F3, a, b, c, d, e, words[41], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 STEP(F3, a, b, c, d, e, words[42], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 STEP(F3, a, b, c, d, e, words[43], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 STEP(F3, a, b, c, d, e, words[44], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 STEP(F3, a, b, c, d, e, words[45], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 STEP(F3, a, b, c, d, e, words[46], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 STEP(F3, a, b, c, d, e, words[47], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 STEP(F3, a, b, c, d, e, words[48], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 STEP(F3, a, b, c, d, e, words[49], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 STEP(F3, a, b, c, d, e, words[50], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 STEP(F3, a, b, c, d, e, words[51], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 STEP(F3, a, b, c, d, e, words[52], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 STEP(F3, a, b, c, d, e, words[53], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 STEP(F3, a, b, c, d, e, words[54], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 STEP(F3, a, b, c, d, e, words[55], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 STEP(F3, a, b, c, d, e, words[56], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 STEP(F3, a, b, c, d, e, words[57], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 STEP(F3, a, b, c, d, e, words[58], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 STEP(F3, a, b, c, d, e, words[59], 0x8f1bbcdc); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 STEP(F2, a, b, c, d, e, words[60], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 STEP(F2, a, b, c, d, e, words[61], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 STEP(F2, a, b, c, d, e, words[62], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 STEP(F2, a, b, c, d, e, words[63], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 STEP(F2, a, b, c, d, e, words[64], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 STEP(F2, a, b, c, d, e, words[65], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 STEP(F2, a, b, c, d, e, words[66], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 STEP(F2, a, b, c, d, e, words[67], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 STEP(F2, a, b, c, d, e, words[68], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 STEP(F2, a, b, c, d, e, words[69], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 STEP(F2, a, b, c, d, e, words[70], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 STEP(F2, a, b, c, d, e, words[71], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
268 STEP(F2, a, b, c, d, e, words[72], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 STEP(F2, a, b, c, d, e, words[73], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
270 STEP(F2, a, b, c, d, e, words[74], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
271 STEP(F2, a, b, c, d, e, words[75], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 STEP(F2, a, b, c, d, e, words[76], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 STEP(F2, a, b, c, d, e, words[77], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 STEP(F2, a, b, c, d, e, words[78], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 STEP(F2, a, b, c, d, e, words[79], 0xca62c1d6); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
276 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 a += saved_a; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 b += saved_b; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 c += saved_c; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 d += saved_d; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
281 e += saved_e; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
283 p += 64; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 } while (size -= 64); |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
287 ctx->a = a; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 ctx->b = b; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
289 ctx->c = c; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 ctx->d = d; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 ctx->e = e; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 return p; |
1064ea81ed3a
An internal SHA1 implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 } |