diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/evp/bio_enc.c | 31 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp.h | 4 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c index 712222a7cd..7b55998952 100644 --- a/src/lib/libcrypto/evp/bio_enc.c +++ b/src/lib/libcrypto/evp/bio_enc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bio_enc.c,v 1.21 2018/05/02 15:51:41 tb Exp $ */ | 1 | /* $OpenBSD: bio_enc.c,v 1.22 2018/08/24 19:30:24 tb 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 | * |
| @@ -404,23 +404,32 @@ EVP_CIPHER_ctx *c; | |||
| 404 | } | 404 | } |
| 405 | */ | 405 | */ |
| 406 | 406 | ||
| 407 | void | 407 | int |
| 408 | BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, | 408 | BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, |
| 409 | const unsigned char *i, int e) | 409 | const unsigned char *i, int e) |
| 410 | { | 410 | { |
| 411 | BIO_ENC_CTX *ctx; | 411 | BIO_ENC_CTX *ctx; |
| 412 | long (*cb)(BIO *, int, const char *, int, long, long); | ||
| 412 | 413 | ||
| 413 | if (b == NULL) | 414 | if (b == NULL) |
| 414 | return; | 415 | return 0; |
| 415 | 416 | ||
| 416 | if ((b->callback != NULL) && | 417 | if ((ctx = BIO_get_data(b)) == NULL) |
| 417 | (b->callback(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 0L) <= 0)) | 418 | return 0; |
| 418 | return; | ||
| 419 | 419 | ||
| 420 | b->init = 1; | 420 | if ((cb = BIO_get_callback(b)) != NULL) { |
| 421 | ctx = (BIO_ENC_CTX *)b->ptr; | 421 | if (cb(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 0L) |
| 422 | EVP_CipherInit_ex(&(ctx->cipher), c, NULL, k, i, e); | 422 | <= 0) |
| 423 | return 0; | ||
| 424 | } | ||
| 423 | 425 | ||
| 424 | if (b->callback != NULL) | 426 | BIO_set_init(b, 1); |
| 425 | b->callback(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 1L); | 427 | |
| 428 | if (!EVP_CipherInit_ex(&(ctx->cipher), c, NULL, k, i, e)) | ||
| 429 | return 0; | ||
| 430 | |||
| 431 | if (cb != NULL) | ||
| 432 | return cb(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 1L); | ||
| 433 | |||
| 434 | return 1; | ||
| 426 | } | 435 | } |
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index c557ba9f39..c6ec0e35d8 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.64 2018/05/30 15:40:50 tb Exp $ */ | 1 | /* $OpenBSD: evp.h,v 1.65 2018/08/24 19:30:24 tb 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 | * |
| @@ -655,7 +655,7 @@ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); | |||
| 655 | const BIO_METHOD *BIO_f_md(void); | 655 | const BIO_METHOD *BIO_f_md(void); |
| 656 | const BIO_METHOD *BIO_f_base64(void); | 656 | const BIO_METHOD *BIO_f_base64(void); |
| 657 | const BIO_METHOD *BIO_f_cipher(void); | 657 | const BIO_METHOD *BIO_f_cipher(void); |
| 658 | void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, | 658 | int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, |
| 659 | const unsigned char *i, int enc); | 659 | const unsigned char *i, int enc); |
| 660 | #endif | 660 | #endif |
| 661 | 661 | ||
