grpc 1.10.0.pre1 → 1.10.0.pre2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +3 -3
  3. data/src/core/ext/filters/max_age/max_age_filter.cc +3 -0
  4. data/src/core/lib/surface/version.cc +1 -1
  5. data/src/ruby/lib/grpc/version.rb +1 -1
  6. data/third_party/boringssl/crypto/fipsmodule/aes/aes.c +1100 -0
  7. data/third_party/boringssl/crypto/fipsmodule/aes/key_wrap.c +138 -0
  8. data/third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.c +112 -0
  9. data/third_party/boringssl/crypto/fipsmodule/bn/add.c +375 -0
  10. data/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c +537 -0
  11. data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +370 -0
  12. data/third_party/boringssl/crypto/fipsmodule/bn/bytes.c +269 -0
  13. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +239 -0
  14. data/third_party/boringssl/crypto/fipsmodule/bn/ctx.c +303 -0
  15. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +726 -0
  16. data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +1233 -0
  17. data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +627 -0
  18. data/third_party/boringssl/crypto/fipsmodule/bn/generic.c +715 -0
  19. data/third_party/boringssl/crypto/fipsmodule/bn/jacobi.c +146 -0
  20. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +430 -0
  21. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +207 -0
  22. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +869 -0
  23. data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +894 -0
  24. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +283 -0
  25. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +254 -0
  26. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +307 -0
  27. data/third_party/boringssl/crypto/fipsmodule/bn/sqrt.c +502 -0
  28. data/third_party/boringssl/crypto/fipsmodule/cipher/aead.c +284 -0
  29. data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +613 -0
  30. data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +1437 -0
  31. data/third_party/boringssl/crypto/fipsmodule/cipher/e_des.c +233 -0
  32. data/third_party/boringssl/crypto/fipsmodule/des/des.c +785 -0
  33. data/third_party/boringssl/crypto/fipsmodule/digest/digest.c +256 -0
  34. data/third_party/boringssl/crypto/fipsmodule/digest/digests.c +280 -0
  35. data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +842 -0
  36. data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +517 -0
  37. data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +304 -0
  38. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +404 -0
  39. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +1165 -0
  40. data/third_party/boringssl/crypto/fipsmodule/ec/p256-64.c +1708 -0
  41. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +561 -0
  42. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +1113 -0
  43. data/third_party/boringssl/crypto/fipsmodule/ec/util-64.c +109 -0
  44. data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +456 -0
  45. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +444 -0
  46. data/third_party/boringssl/crypto/fipsmodule/hmac/hmac.c +228 -0
  47. data/third_party/boringssl/crypto/fipsmodule/md4/md4.c +254 -0
  48. data/third_party/boringssl/crypto/fipsmodule/md5/md5.c +298 -0
  49. data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +212 -0
  50. data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +230 -0
  51. data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +219 -0
  52. data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +1074 -0
  53. data/third_party/boringssl/crypto/fipsmodule/modes/ofb.c +95 -0
  54. data/third_party/boringssl/crypto/fipsmodule/modes/polyval.c +91 -0
  55. data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +200 -0
  56. data/third_party/boringssl/crypto/fipsmodule/rand/rand.c +358 -0
  57. data/third_party/boringssl/crypto/fipsmodule/rand/urandom.c +302 -0
  58. data/third_party/boringssl/crypto/fipsmodule/rsa/blinding.c +263 -0
  59. data/third_party/boringssl/crypto/fipsmodule/rsa/padding.c +692 -0
  60. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +855 -0
  61. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +1061 -0
  62. data/third_party/boringssl/crypto/fipsmodule/sha/sha1-altivec.c +361 -0
  63. data/third_party/boringssl/crypto/fipsmodule/sha/sha1.c +375 -0
  64. data/third_party/boringssl/crypto/fipsmodule/sha/sha256.c +337 -0
  65. data/third_party/boringssl/crypto/fipsmodule/sha/sha512.c +608 -0
  66. metadata +62 -2
@@ -0,0 +1,256 @@
1
+ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2
+ * All rights reserved.
3
+ *
4
+ * This package is an SSL implementation written
5
+ * by Eric Young (eay@cryptsoft.com).
6
+ * The implementation was written so as to conform with Netscapes SSL.
7
+ *
8
+ * This library is free for commercial and non-commercial use as long as
9
+ * the following conditions are aheared to. The following conditions
10
+ * apply to all code found in this distribution, be it the RC4, RSA,
11
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12
+ * included with this distribution is covered by the same copyright terms
13
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14
+ *
15
+ * Copyright remains Eric Young's, and as such any Copyright notices in
16
+ * the code are not to be removed.
17
+ * If this package is used in a product, Eric Young should be given attribution
18
+ * as the author of the parts of the library used.
19
+ * This can be in the form of a textual message at program startup or
20
+ * in documentation (online or textual) provided with the package.
21
+ *
22
+ * Redistribution and use in source and binary forms, with or without
23
+ * modification, are permitted provided that the following conditions
24
+ * are met:
25
+ * 1. Redistributions of source code must retain the copyright
26
+ * notice, this list of conditions and the following disclaimer.
27
+ * 2. Redistributions in binary form must reproduce the above copyright
28
+ * notice, this list of conditions and the following disclaimer in the
29
+ * documentation and/or other materials provided with the distribution.
30
+ * 3. All advertising materials mentioning features or use of this software
31
+ * must display the following acknowledgement:
32
+ * "This product includes cryptographic software written by
33
+ * Eric Young (eay@cryptsoft.com)"
34
+ * The word 'cryptographic' can be left out if the rouines from the library
35
+ * being used are not cryptographic related :-).
36
+ * 4. If you include any Windows specific code (or a derivative thereof) from
37
+ * the apps directory (application code) you must include an acknowledgement:
38
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39
+ *
40
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50
+ * SUCH DAMAGE.
51
+ *
52
+ * The licence and distribution terms for any publically available version or
53
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
54
+ * copied and put under another distribution licence
55
+ * [including the GNU Public Licence.] */
56
+
57
+ #include <openssl/digest.h>
58
+
59
+ #include <assert.h>
60
+ #include <string.h>
61
+
62
+ #include <openssl/err.h>
63
+ #include <openssl/mem.h>
64
+
65
+ #include "internal.h"
66
+ #include "../../internal.h"
67
+
68
+
69
+ int EVP_MD_type(const EVP_MD *md) { return md->type; }
70
+
71
+ uint32_t EVP_MD_flags(const EVP_MD *md) { return md->flags; }
72
+
73
+ size_t EVP_MD_size(const EVP_MD *md) { return md->md_size; }
74
+
75
+ size_t EVP_MD_block_size(const EVP_MD *md) { return md->block_size; }
76
+
77
+
78
+ void EVP_MD_CTX_init(EVP_MD_CTX *ctx) {
79
+ OPENSSL_memset(ctx, 0, sizeof(EVP_MD_CTX));
80
+ }
81
+
82
+ EVP_MD_CTX *EVP_MD_CTX_new(void) {
83
+ EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof(EVP_MD_CTX));
84
+
85
+ if (ctx) {
86
+ EVP_MD_CTX_init(ctx);
87
+ }
88
+
89
+ return ctx;
90
+ }
91
+
92
+ EVP_MD_CTX *EVP_MD_CTX_create(void) { return EVP_MD_CTX_new(); }
93
+
94
+ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) {
95
+ OPENSSL_free(ctx->md_data);
96
+
97
+ assert(ctx->pctx == NULL || ctx->pctx_ops != NULL);
98
+ if (ctx->pctx_ops) {
99
+ ctx->pctx_ops->free(ctx->pctx);
100
+ }
101
+
102
+ EVP_MD_CTX_init(ctx);
103
+
104
+ return 1;
105
+ }
106
+
107
+ void EVP_MD_CTX_free(EVP_MD_CTX *ctx) {
108
+ if (!ctx) {
109
+ return;
110
+ }
111
+
112
+ EVP_MD_CTX_cleanup(ctx);
113
+ OPENSSL_free(ctx);
114
+ }
115
+
116
+ void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) { EVP_MD_CTX_free(ctx); }
117
+
118
+ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) {
119
+ if (in == NULL || in->digest == NULL) {
120
+ OPENSSL_PUT_ERROR(DIGEST, DIGEST_R_INPUT_NOT_INITIALIZED);
121
+ return 0;
122
+ }
123
+
124
+ EVP_PKEY_CTX *pctx = NULL;
125
+ assert(in->pctx == NULL || in->pctx_ops != NULL);
126
+ if (in->pctx) {
127
+ pctx = in->pctx_ops->dup(in->pctx);
128
+ if (!pctx) {
129
+ OPENSSL_PUT_ERROR(DIGEST, ERR_R_MALLOC_FAILURE);
130
+ return 0;
131
+ }
132
+ }
133
+
134
+ uint8_t *tmp_buf;
135
+ if (out->digest != in->digest) {
136
+ assert(in->digest->ctx_size != 0);
137
+ tmp_buf = OPENSSL_malloc(in->digest->ctx_size);
138
+ if (tmp_buf == NULL) {
139
+ if (pctx) {
140
+ in->pctx_ops->free(pctx);
141
+ }
142
+ OPENSSL_PUT_ERROR(DIGEST, ERR_R_MALLOC_FAILURE);
143
+ return 0;
144
+ }
145
+ } else {
146
+ // |md_data| will be the correct size in this case. It's removed from |out|
147
+ // so that |EVP_MD_CTX_cleanup| doesn't free it, and then it's reused.
148
+ tmp_buf = out->md_data;
149
+ out->md_data = NULL;
150
+ }
151
+
152
+ EVP_MD_CTX_cleanup(out);
153
+
154
+ out->digest = in->digest;
155
+ out->md_data = tmp_buf;
156
+ OPENSSL_memcpy(out->md_data, in->md_data, in->digest->ctx_size);
157
+ out->pctx = pctx;
158
+ out->pctx_ops = in->pctx_ops;
159
+ assert(out->pctx == NULL || out->pctx_ops != NULL);
160
+
161
+ return 1;
162
+ }
163
+
164
+ int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) {
165
+ EVP_MD_CTX_init(out);
166
+ return EVP_MD_CTX_copy_ex(out, in);
167
+ }
168
+
169
+ void EVP_MD_CTX_reset(EVP_MD_CTX *ctx) {
170
+ EVP_MD_CTX_cleanup(ctx);
171
+ EVP_MD_CTX_init(ctx);
172
+ }
173
+
174
+ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *engine) {
175
+ if (ctx->digest != type) {
176
+ assert(type->ctx_size != 0);
177
+ uint8_t *md_data = OPENSSL_malloc(type->ctx_size);
178
+ if (md_data == NULL) {
179
+ OPENSSL_PUT_ERROR(DIGEST, ERR_R_MALLOC_FAILURE);
180
+ return 0;
181
+ }
182
+
183
+ OPENSSL_free(ctx->md_data);
184
+ ctx->md_data = md_data;
185
+ ctx->digest = type;
186
+ }
187
+
188
+ assert(ctx->pctx == NULL || ctx->pctx_ops != NULL);
189
+
190
+ ctx->digest->init(ctx);
191
+ return 1;
192
+ }
193
+
194
+ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) {
195
+ EVP_MD_CTX_init(ctx);
196
+ return EVP_DigestInit_ex(ctx, type, NULL);
197
+ }
198
+
199
+ int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t len) {
200
+ ctx->digest->update(ctx, data, len);
201
+ return 1;
202
+ }
203
+
204
+ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, uint8_t *md_out, unsigned int *size) {
205
+ assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
206
+ ctx->digest->final(ctx, md_out);
207
+ if (size != NULL) {
208
+ *size = ctx->digest->md_size;
209
+ }
210
+ OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size);
211
+ return 1;
212
+ }
213
+
214
+ int EVP_DigestFinal(EVP_MD_CTX *ctx, uint8_t *md, unsigned int *size) {
215
+ (void)EVP_DigestFinal_ex(ctx, md, size);
216
+ EVP_MD_CTX_cleanup(ctx);
217
+ return 1;
218
+ }
219
+
220
+ int EVP_Digest(const void *data, size_t count, uint8_t *out_md,
221
+ unsigned int *out_size, const EVP_MD *type, ENGINE *impl) {
222
+ EVP_MD_CTX ctx;
223
+ int ret;
224
+
225
+ EVP_MD_CTX_init(&ctx);
226
+ ret = EVP_DigestInit_ex(&ctx, type, impl) &&
227
+ EVP_DigestUpdate(&ctx, data, count) &&
228
+ EVP_DigestFinal_ex(&ctx, out_md, out_size);
229
+ EVP_MD_CTX_cleanup(&ctx);
230
+
231
+ return ret;
232
+ }
233
+
234
+
235
+ const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx) {
236
+ if (ctx == NULL) {
237
+ return NULL;
238
+ }
239
+ return ctx->digest;
240
+ }
241
+
242
+ size_t EVP_MD_CTX_size(const EVP_MD_CTX *ctx) {
243
+ return EVP_MD_size(EVP_MD_CTX_md(ctx));
244
+ }
245
+
246
+ size_t EVP_MD_CTX_block_size(const EVP_MD_CTX *ctx) {
247
+ return EVP_MD_block_size(EVP_MD_CTX_md(ctx));
248
+ }
249
+
250
+ int EVP_MD_CTX_type(const EVP_MD_CTX *ctx) {
251
+ return EVP_MD_type(EVP_MD_CTX_md(ctx));
252
+ }
253
+
254
+ int EVP_add_digest(const EVP_MD *digest) {
255
+ return 1;
256
+ }
@@ -0,0 +1,280 @@
1
+ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2
+ * All rights reserved.
3
+ *
4
+ * This package is an SSL implementation written
5
+ * by Eric Young (eay@cryptsoft.com).
6
+ * The implementation was written so as to conform with Netscapes SSL.
7
+ *
8
+ * This library is free for commercial and non-commercial use as long as
9
+ * the following conditions are aheared to. The following conditions
10
+ * apply to all code found in this distribution, be it the RC4, RSA,
11
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12
+ * included with this distribution is covered by the same copyright terms
13
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14
+ *
15
+ * Copyright remains Eric Young's, and as such any Copyright notices in
16
+ * the code are not to be removed.
17
+ * If this package is used in a product, Eric Young should be given attribution
18
+ * as the author of the parts of the library used.
19
+ * This can be in the form of a textual message at program startup or
20
+ * in documentation (online or textual) provided with the package.
21
+ *
22
+ * Redistribution and use in source and binary forms, with or without
23
+ * modification, are permitted provided that the following conditions
24
+ * are met:
25
+ * 1. Redistributions of source code must retain the copyright
26
+ * notice, this list of conditions and the following disclaimer.
27
+ * 2. Redistributions in binary form must reproduce the above copyright
28
+ * notice, this list of conditions and the following disclaimer in the
29
+ * documentation and/or other materials provided with the distribution.
30
+ * 3. All advertising materials mentioning features or use of this software
31
+ * must display the following acknowledgement:
32
+ * "This product includes cryptographic software written by
33
+ * Eric Young (eay@cryptsoft.com)"
34
+ * The word 'cryptographic' can be left out if the rouines from the library
35
+ * being used are not cryptographic related :-).
36
+ * 4. If you include any Windows specific code (or a derivative thereof) from
37
+ * the apps directory (application code) you must include an acknowledgement:
38
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39
+ *
40
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50
+ * SUCH DAMAGE.
51
+ *
52
+ * The licence and distribution terms for any publically available version or
53
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
54
+ * copied and put under another distribution licence
55
+ * [including the GNU Public Licence.] */
56
+
57
+ #include <openssl/digest.h>
58
+
59
+ #include <assert.h>
60
+ #include <string.h>
61
+
62
+ #include <openssl/md4.h>
63
+ #include <openssl/md5.h>
64
+ #include <openssl/nid.h>
65
+ #include <openssl/sha.h>
66
+
67
+ #include "internal.h"
68
+ #include "../delocate.h"
69
+ #include "../../internal.h"
70
+
71
+ #if defined(NDEBUG)
72
+ #define CHECK(x) (void) (x)
73
+ #else
74
+ #define CHECK(x) assert(x)
75
+ #endif
76
+
77
+
78
+ static void md4_init(EVP_MD_CTX *ctx) {
79
+ CHECK(MD4_Init(ctx->md_data));
80
+ }
81
+
82
+ static void md4_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
83
+ CHECK(MD4_Update(ctx->md_data, data, count));
84
+ }
85
+
86
+ static void md4_final(EVP_MD_CTX *ctx, uint8_t *out) {
87
+ CHECK(MD4_Final(out, ctx->md_data));
88
+ }
89
+
90
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_md4) {
91
+ out->type = NID_md4;
92
+ out->md_size = MD4_DIGEST_LENGTH;
93
+ out->flags = 0;
94
+ out->init = md4_init;
95
+ out->update = md4_update;
96
+ out->final = md4_final;
97
+ out->block_size = 64;
98
+ out->ctx_size = sizeof(MD4_CTX);
99
+ }
100
+
101
+
102
+ static void md5_init(EVP_MD_CTX *ctx) {
103
+ CHECK(MD5_Init(ctx->md_data));
104
+ }
105
+
106
+ static void md5_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
107
+ CHECK(MD5_Update(ctx->md_data, data, count));
108
+ }
109
+
110
+ static void md5_final(EVP_MD_CTX *ctx, uint8_t *out) {
111
+ CHECK(MD5_Final(out, ctx->md_data));
112
+ }
113
+
114
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_md5) {
115
+ out->type = NID_md5;
116
+ out->md_size = MD5_DIGEST_LENGTH;
117
+ out->flags = 0;
118
+ out->init = md5_init;
119
+ out->update = md5_update;
120
+ out->final = md5_final;
121
+ out->block_size = 64;
122
+ out->ctx_size = sizeof(MD5_CTX);
123
+ }
124
+
125
+
126
+ static void sha1_init(EVP_MD_CTX *ctx) {
127
+ CHECK(SHA1_Init(ctx->md_data));
128
+ }
129
+
130
+ static void sha1_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
131
+ CHECK(SHA1_Update(ctx->md_data, data, count));
132
+ }
133
+
134
+ static void sha1_final(EVP_MD_CTX *ctx, uint8_t *md) {
135
+ CHECK(SHA1_Final(md, ctx->md_data));
136
+ }
137
+
138
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha1) {
139
+ out->type = NID_sha1;
140
+ out->md_size = SHA_DIGEST_LENGTH;
141
+ out->flags = 0;
142
+ out->init = sha1_init;
143
+ out->update = sha1_update;
144
+ out->final = sha1_final;
145
+ out->block_size = 64;
146
+ out->ctx_size = sizeof(SHA_CTX);
147
+ }
148
+
149
+
150
+ static void sha224_init(EVP_MD_CTX *ctx) {
151
+ CHECK(SHA224_Init(ctx->md_data));
152
+ }
153
+
154
+ static void sha224_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
155
+ CHECK(SHA224_Update(ctx->md_data, data, count));
156
+ }
157
+
158
+ static void sha224_final(EVP_MD_CTX *ctx, uint8_t *md) {
159
+ CHECK(SHA224_Final(md, ctx->md_data));
160
+ }
161
+
162
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha224) {
163
+ out->type = NID_sha224;
164
+ out->md_size = SHA224_DIGEST_LENGTH;
165
+ out->flags = 0;
166
+ out->init = sha224_init;
167
+ out->update = sha224_update;
168
+ out->final = sha224_final;
169
+ out->block_size = 64;
170
+ out->ctx_size = sizeof(SHA256_CTX);
171
+ }
172
+
173
+
174
+ static void sha256_init(EVP_MD_CTX *ctx) {
175
+ CHECK(SHA256_Init(ctx->md_data));
176
+ }
177
+
178
+ static void sha256_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
179
+ CHECK(SHA256_Update(ctx->md_data, data, count));
180
+ }
181
+
182
+ static void sha256_final(EVP_MD_CTX *ctx, uint8_t *md) {
183
+ CHECK(SHA256_Final(md, ctx->md_data));
184
+ }
185
+
186
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha256) {
187
+ out->type = NID_sha256;
188
+ out->md_size = SHA256_DIGEST_LENGTH;
189
+ out->flags = 0;
190
+ out->init = sha256_init;
191
+ out->update = sha256_update;
192
+ out->final = sha256_final;
193
+ out->block_size = 64;
194
+ out->ctx_size = sizeof(SHA256_CTX);
195
+ }
196
+
197
+
198
+ static void sha384_init(EVP_MD_CTX *ctx) {
199
+ CHECK(SHA384_Init(ctx->md_data));
200
+ }
201
+
202
+ static void sha384_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
203
+ CHECK(SHA384_Update(ctx->md_data, data, count));
204
+ }
205
+
206
+ static void sha384_final(EVP_MD_CTX *ctx, uint8_t *md) {
207
+ CHECK(SHA384_Final(md, ctx->md_data));
208
+ }
209
+
210
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha384) {
211
+ out->type = NID_sha384;
212
+ out->md_size = SHA384_DIGEST_LENGTH;
213
+ out->flags = 0;
214
+ out->init = sha384_init;
215
+ out->update = sha384_update;
216
+ out->final = sha384_final;
217
+ out->block_size = 128;
218
+ out->ctx_size = sizeof(SHA512_CTX);
219
+ }
220
+
221
+
222
+ static void sha512_init(EVP_MD_CTX *ctx) {
223
+ CHECK(SHA512_Init(ctx->md_data));
224
+ }
225
+
226
+ static void sha512_update(EVP_MD_CTX *ctx, const void *data, size_t count) {
227
+ CHECK(SHA512_Update(ctx->md_data, data, count));
228
+ }
229
+
230
+ static void sha512_final(EVP_MD_CTX *ctx, uint8_t *md) {
231
+ CHECK(SHA512_Final(md, ctx->md_data));
232
+ }
233
+
234
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha512) {
235
+ out->type = NID_sha512;
236
+ out->md_size = SHA512_DIGEST_LENGTH;
237
+ out->flags = 0;
238
+ out->init = sha512_init;
239
+ out->update = sha512_update;
240
+ out->final = sha512_final;
241
+ out->block_size = 128;
242
+ out->ctx_size = sizeof(SHA512_CTX);
243
+ }
244
+
245
+
246
+ typedef struct {
247
+ MD5_CTX md5;
248
+ SHA_CTX sha1;
249
+ } MD5_SHA1_CTX;
250
+
251
+ static void md5_sha1_init(EVP_MD_CTX *md_ctx) {
252
+ MD5_SHA1_CTX *ctx = md_ctx->md_data;
253
+ CHECK(MD5_Init(&ctx->md5) && SHA1_Init(&ctx->sha1));
254
+ }
255
+
256
+ static void md5_sha1_update(EVP_MD_CTX *md_ctx, const void *data,
257
+ size_t count) {
258
+ MD5_SHA1_CTX *ctx = md_ctx->md_data;
259
+ CHECK(MD5_Update(&ctx->md5, data, count) &&
260
+ SHA1_Update(&ctx->sha1, data, count));
261
+ }
262
+
263
+ static void md5_sha1_final(EVP_MD_CTX *md_ctx, uint8_t *out) {
264
+ MD5_SHA1_CTX *ctx = md_ctx->md_data;
265
+ CHECK(MD5_Final(out, &ctx->md5) &&
266
+ SHA1_Final(out + MD5_DIGEST_LENGTH, &ctx->sha1));
267
+ }
268
+
269
+ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_md5_sha1) {
270
+ out->type = NID_md5_sha1;
271
+ out->md_size = MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH;
272
+ out->flags = 0;
273
+ out->init = md5_sha1_init;
274
+ out->update = md5_sha1_update;
275
+ out->final = md5_sha1_final;
276
+ out->block_size = 64;
277
+ out->ctx_size = sizeof(MD5_SHA1_CTX);
278
+ }
279
+
280
+ #undef CHECK