sync with OpenBSD -current
This commit is contained in:
parent
ddb52a44ab
commit
11b1e48835
37 changed files with 817 additions and 681 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: evp_enc.c,v 1.79 2023/12/23 13:05:06 tb Exp $ */
|
||||
/* $OpenBSD: evp_enc.c,v 1.81 2023/12/26 09:04:30 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -72,8 +72,6 @@ int
|
|||
EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, const unsigned char *iv, int enc)
|
||||
{
|
||||
if (cipher != NULL)
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
|
||||
}
|
||||
|
||||
|
@ -93,23 +91,18 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine,
|
|||
}
|
||||
|
||||
/*
|
||||
* If the ctx is reused and a cipher is passed in, reset the ctx but
|
||||
* remember enc and whether key wrap was enabled.
|
||||
* Set up cipher and context. Allocate cipher data and initialize ctx.
|
||||
* On ctx reuse only retain encryption direction and key wrap flag.
|
||||
*/
|
||||
if (cipher != NULL && ctx->cipher != NULL) {
|
||||
if (cipher != NULL) {
|
||||
unsigned long flags = ctx->flags;
|
||||
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
|
||||
ctx->encrypt = enc;
|
||||
ctx->flags = flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW;
|
||||
}
|
||||
|
||||
/* Set up cipher. Allocate cipher data and initialize if necessary. */
|
||||
if (cipher != NULL) {
|
||||
ctx->cipher = cipher;
|
||||
ctx->key_len = cipher->key_len;
|
||||
ctx->flags &= EVP_CIPHER_CTX_FLAG_WRAP_ALLOW;
|
||||
|
||||
if (ctx->cipher->ctx_size != 0) {
|
||||
ctx->cipher_data = calloc(1, ctx->cipher->ctx_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue