diff options
author | jsing <> | 2018-02-17 14:55:31 +0000 |
---|---|---|
committer | jsing <> | 2018-02-17 14:55:31 +0000 |
commit | 3b7cdf9c768759bfba3e3afd3a234cc44ef4c7c1 (patch) | |
tree | 271d4b947a3db41c5ba023d0c3030ac88f62bafa /src | |
parent | b32a945103cc4488bb232840251fc0a861837051 (diff) | |
download | openbsd-3b7cdf9c768759bfba3e3afd3a234cc44ef4c7c1.tar.gz openbsd-3b7cdf9c768759bfba3e3afd3a234cc44ef4c7c1.tar.bz2 openbsd-3b7cdf9c768759bfba3e3afd3a234cc44ef4c7c1.zip |
Provide EVP_MD_CTX_new(), EVP_MD_CTX_free() and EVP_MD_CTX_reset().
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/digest.c | 59 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/evp.h | 8 |
3 files changed, 49 insertions, 21 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 1da0493c73..d633575397 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -1274,8 +1274,11 @@ EVP_MD_CTX_copy_ex | |||
1274 | EVP_MD_CTX_create | 1274 | EVP_MD_CTX_create |
1275 | EVP_MD_CTX_ctrl | 1275 | EVP_MD_CTX_ctrl |
1276 | EVP_MD_CTX_destroy | 1276 | EVP_MD_CTX_destroy |
1277 | EVP_MD_CTX_free | ||
1277 | EVP_MD_CTX_init | 1278 | EVP_MD_CTX_init |
1278 | EVP_MD_CTX_md | 1279 | EVP_MD_CTX_md |
1280 | EVP_MD_CTX_new | ||
1281 | EVP_MD_CTX_reset | ||
1279 | EVP_MD_CTX_set_flags | 1282 | EVP_MD_CTX_set_flags |
1280 | EVP_MD_CTX_test_flags | 1283 | EVP_MD_CTX_test_flags |
1281 | EVP_MD_block_size | 1284 | EVP_MD_block_size |
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index 7471c1e822..b69a928ab8 100644 --- a/src/lib/libcrypto/evp/digest.c +++ b/src/lib/libcrypto/evp/digest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: digest.c,v 1.28 2017/05/02 03:59:44 deraadt Exp $ */ | 1 | /* $OpenBSD: digest.c,v 1.29 2018/02/17 14:55:31 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -122,18 +122,6 @@ | |||
122 | #include <openssl/engine.h> | 122 | #include <openssl/engine.h> |
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | void | ||
126 | EVP_MD_CTX_init(EVP_MD_CTX *ctx) | ||
127 | { | ||
128 | memset(ctx, 0, sizeof *ctx); | ||
129 | } | ||
130 | |||
131 | EVP_MD_CTX * | ||
132 | EVP_MD_CTX_create(void) | ||
133 | { | ||
134 | return calloc(1, sizeof(EVP_MD_CTX)); | ||
135 | } | ||
136 | |||
137 | int | 125 | int |
138 | EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) | 126 | EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) |
139 | { | 127 | { |
@@ -339,20 +327,53 @@ EVP_Digest(const void *data, size_t count, | |||
339 | return ret; | 327 | return ret; |
340 | } | 328 | } |
341 | 329 | ||
330 | EVP_MD_CTX * | ||
331 | EVP_MD_CTX_new(void) | ||
332 | { | ||
333 | return calloc(1, sizeof(EVP_MD_CTX)); | ||
334 | } | ||
335 | |||
336 | void | ||
337 | EVP_MD_CTX_free(EVP_MD_CTX *ctx) | ||
338 | { | ||
339 | if (ctx == NULL) | ||
340 | return; | ||
341 | |||
342 | EVP_MD_CTX_cleanup(ctx); | ||
343 | |||
344 | free(ctx); | ||
345 | } | ||
346 | |||
347 | void | ||
348 | EVP_MD_CTX_init(EVP_MD_CTX *ctx) | ||
349 | { | ||
350 | memset(ctx, 0, sizeof(*ctx)); | ||
351 | } | ||
352 | |||
353 | int | ||
354 | EVP_MD_CTX_reset(EVP_MD_CTX *ctx) | ||
355 | { | ||
356 | return EVP_MD_CTX_cleanup(ctx); | ||
357 | } | ||
358 | |||
359 | EVP_MD_CTX * | ||
360 | EVP_MD_CTX_create(void) | ||
361 | { | ||
362 | return EVP_MD_CTX_new(); | ||
363 | } | ||
364 | |||
342 | void | 365 | void |
343 | EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) | 366 | EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) |
344 | { | 367 | { |
345 | if (ctx) { | 368 | EVP_MD_CTX_free(ctx); |
346 | EVP_MD_CTX_cleanup(ctx); | ||
347 | free(ctx); | ||
348 | } | ||
349 | } | 369 | } |
350 | 370 | ||
351 | /* This call frees resources associated with the context */ | 371 | /* This call frees resources associated with the context */ |
352 | int | 372 | int |
353 | EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) | 373 | EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) |
354 | { | 374 | { |
355 | /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final, | 375 | /* |
376 | * Don't assume ctx->md_data was cleaned in EVP_Digest_Final, | ||
356 | * because sometimes only copies of the context are ever finalised. | 377 | * because sometimes only copies of the context are ever finalised. |
357 | */ | 378 | */ |
358 | if (ctx->digest && ctx->digest->cleanup && | 379 | if (ctx->digest && ctx->digest->cleanup && |
@@ -368,7 +389,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) | |||
368 | * functional reference we held for this reason. */ | 389 | * functional reference we held for this reason. */ |
369 | ENGINE_finish(ctx->engine); | 390 | ENGINE_finish(ctx->engine); |
370 | #endif | 391 | #endif |
371 | memset(ctx, 0, sizeof *ctx); | 392 | memset(ctx, 0, sizeof(*ctx)); |
372 | 393 | ||
373 | return 1; | 394 | return 1; |
374 | } | 395 | } |
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index c8da89844d..148e15274f 100644 --- a/src/lib/libcrypto/evp/evp.h +++ b/src/lib/libcrypto/evp/evp.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp.h,v 1.55 2018/02/17 13:47:36 tb Exp $ */ | 1 | /* $OpenBSD: evp.h,v 1.56 2018/02/17 14:55:31 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -535,15 +535,19 @@ int EVP_Cipher(EVP_CIPHER_CTX *c, unsigned char *out, const unsigned char *in, | |||
535 | #define EVP_delete_digest_alias(alias) \ | 535 | #define EVP_delete_digest_alias(alias) \ |
536 | OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); | 536 | OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); |
537 | 537 | ||
538 | EVP_MD_CTX *EVP_MD_CTX_new(void); | ||
539 | void EVP_MD_CTX_free(EVP_MD_CTX *ctx); | ||
538 | void EVP_MD_CTX_init(EVP_MD_CTX *ctx); | 540 | void EVP_MD_CTX_init(EVP_MD_CTX *ctx); |
539 | int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); | 541 | int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); |
540 | EVP_MD_CTX *EVP_MD_CTX_create(void); | 542 | EVP_MD_CTX *EVP_MD_CTX_create(void); |
541 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); | 543 | void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); |
544 | int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); | ||
542 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); | 545 | int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); |
543 | void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); | 546 | void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); |
544 | void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); | 547 | void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); |
545 | int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr); | 548 | int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr); |
546 | int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); | 549 | int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); |
550 | |||
547 | int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); | 551 | int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); |
548 | int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); | 552 | int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); |
549 | int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s); | 553 | int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s); |