diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/evp/digest.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index 6d8ed9b499..ee1f955959 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.26 2015/02/11 03:19:37 doug Exp $ */ | 1 | /* $OpenBSD: digest.c,v 1.27 2017/01/29 17:49:23 beck 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 | * |
| @@ -162,8 +162,7 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) | |||
| 162 | ENGINE_finish(ctx->engine); | 162 | ENGINE_finish(ctx->engine); |
| 163 | if (impl) { | 163 | if (impl) { |
| 164 | if (!ENGINE_init(impl)) { | 164 | if (!ENGINE_init(impl)) { |
| 165 | EVPerr(EVP_F_EVP_DIGESTINIT_EX, | 165 | EVPerror(EVP_R_INITIALIZATION_ERROR); |
| 166 | EVP_R_INITIALIZATION_ERROR); | ||
| 167 | return 0; | 166 | return 0; |
| 168 | } | 167 | } |
| 169 | } else | 168 | } else |
| @@ -174,8 +173,7 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) | |||
| 174 | const EVP_MD *d = ENGINE_get_digest(impl, type->type); | 173 | const EVP_MD *d = ENGINE_get_digest(impl, type->type); |
| 175 | if (!d) { | 174 | if (!d) { |
| 176 | /* Same comment from evp_enc.c */ | 175 | /* Same comment from evp_enc.c */ |
| 177 | EVPerr(EVP_F_EVP_DIGESTINIT_EX, | 176 | EVPerror(EVP_R_INITIALIZATION_ERROR); |
| 178 | EVP_R_INITIALIZATION_ERROR); | ||
| 179 | ENGINE_finish(impl); | 177 | ENGINE_finish(impl); |
| 180 | return 0; | 178 | return 0; |
| 181 | } | 179 | } |
| @@ -188,7 +186,7 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) | |||
| 188 | } else | 186 | } else |
| 189 | ctx->engine = NULL; | 187 | ctx->engine = NULL; |
| 190 | } else if (!ctx->digest) { | 188 | } else if (!ctx->digest) { |
| 191 | EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_NO_DIGEST_SET); | 189 | EVPerror(EVP_R_NO_DIGEST_SET); |
| 192 | return 0; | 190 | return 0; |
| 193 | } | 191 | } |
| 194 | #endif | 192 | #endif |
| @@ -206,8 +204,7 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) | |||
| 206 | if (ctx->md_data == NULL) { | 204 | if (ctx->md_data == NULL) { |
| 207 | EVP_PKEY_CTX_free(ctx->pctx); | 205 | EVP_PKEY_CTX_free(ctx->pctx); |
| 208 | ctx->pctx = NULL; | 206 | ctx->pctx = NULL; |
| 209 | EVPerr(EVP_F_EVP_DIGESTINIT_EX, | 207 | EVPerror(ERR_R_MALLOC_FAILURE); |
| 210 | ERR_R_MALLOC_FAILURE); | ||
| 211 | return 0; | 208 | return 0; |
| 212 | } | 209 | } |
| 213 | } | 210 | } |
| @@ -251,7 +248,7 @@ EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) | |||
| 251 | int ret; | 248 | int ret; |
| 252 | 249 | ||
| 253 | if ((size_t)ctx->digest->md_size > EVP_MAX_MD_SIZE) { | 250 | if ((size_t)ctx->digest->md_size > EVP_MAX_MD_SIZE) { |
| 254 | EVPerr(EVP_F_EVP_DIGESTFINAL_EX, EVP_R_TOO_LARGE); | 251 | EVPerror(EVP_R_TOO_LARGE); |
| 255 | return 0; | 252 | return 0; |
| 256 | } | 253 | } |
| 257 | ret = ctx->digest->final(ctx, md); | 254 | ret = ctx->digest->final(ctx, md); |
| @@ -278,13 +275,13 @@ EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) | |||
| 278 | unsigned char *tmp_buf; | 275 | unsigned char *tmp_buf; |
| 279 | 276 | ||
| 280 | if ((in == NULL) || (in->digest == NULL)) { | 277 | if ((in == NULL) || (in->digest == NULL)) { |
| 281 | EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED); | 278 | EVPerror(EVP_R_INPUT_NOT_INITIALIZED); |
| 282 | return 0; | 279 | return 0; |
| 283 | } | 280 | } |
| 284 | #ifndef OPENSSL_NO_ENGINE | 281 | #ifndef OPENSSL_NO_ENGINE |
| 285 | /* Make sure it's safe to copy a digest context using an ENGINE */ | 282 | /* Make sure it's safe to copy a digest context using an ENGINE */ |
| 286 | if (in->engine && !ENGINE_init(in->engine)) { | 283 | if (in->engine && !ENGINE_init(in->engine)) { |
| 287 | EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB); | 284 | EVPerror(ERR_R_ENGINE_LIB); |
| 288 | return 0; | 285 | return 0; |
| 289 | } | 286 | } |
| 290 | #endif | 287 | #endif |
| @@ -303,8 +300,7 @@ EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) | |||
| 303 | else { | 300 | else { |
| 304 | out->md_data = malloc(out->digest->ctx_size); | 301 | out->md_data = malloc(out->digest->ctx_size); |
| 305 | if (!out->md_data) { | 302 | if (!out->md_data) { |
| 306 | EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, | 303 | EVPerror(ERR_R_MALLOC_FAILURE); |
| 307 | ERR_R_MALLOC_FAILURE); | ||
| 308 | return 0; | 304 | return 0; |
| 309 | } | 305 | } |
| 310 | } | 306 | } |
| @@ -386,19 +382,18 @@ EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) | |||
| 386 | int ret; | 382 | int ret; |
| 387 | 383 | ||
| 388 | if (!ctx->digest) { | 384 | if (!ctx->digest) { |
| 389 | EVPerr(EVP_F_EVP_MD_CTX_CTRL, EVP_R_NO_CIPHER_SET); | 385 | EVPerror(EVP_R_NO_CIPHER_SET); |
| 390 | return 0; | 386 | return 0; |
| 391 | } | 387 | } |
| 392 | 388 | ||
| 393 | if (!ctx->digest->md_ctrl) { | 389 | if (!ctx->digest->md_ctrl) { |
| 394 | EVPerr(EVP_F_EVP_MD_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED); | 390 | EVPerror(EVP_R_CTRL_NOT_IMPLEMENTED); |
| 395 | return 0; | 391 | return 0; |
| 396 | } | 392 | } |
| 397 | 393 | ||
| 398 | ret = ctx->digest->md_ctrl(ctx, type, arg, ptr); | 394 | ret = ctx->digest->md_ctrl(ctx, type, arg, ptr); |
| 399 | if (ret == -1) { | 395 | if (ret == -1) { |
| 400 | EVPerr(EVP_F_EVP_MD_CTX_CTRL, | 396 | EVPerror(EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED); |
| 401 | EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED); | ||
| 402 | return 0; | 397 | return 0; |
| 403 | } | 398 | } |
| 404 | return ret; | 399 | return ret; |
