summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-02-18 15:44:10 +0000
committertb <>2024-02-18 15:44:10 +0000
commit39b6299876ec6c908309c9f47f3940eb84b3be12 (patch)
treeb0632599c491a36f1093cf7c7c9f79bfda606b0a
parent6098295db7aa89d96198a327d46d76586bd54ee0 (diff)
downloadopenbsd-39b6299876ec6c908309c9f47f3940eb84b3be12.tar.gz
openbsd-39b6299876ec6c908309c9f47f3940eb84b3be12.tar.bz2
openbsd-39b6299876ec6c908309c9f47f3940eb84b3be12.zip
Use EVP_CIPHER_CTX_legacy_clear() internally
ok jsing
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c4
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c6
-rw-r--r--src/lib/libcrypto/evp/p_legacy.c6
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c6
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c4
5 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 8b6d1929b3..8ee752c020 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p5_pbev2.c,v 1.30 2023/07/07 19:37:52 beck Exp $ */ 1/* $OpenBSD: p5_pbev2.c,v 1.31 2024/02/18 15:44:10 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999-2004. 3 * project 1999-2004.
4 */ 4 */
@@ -218,7 +218,7 @@ PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt,
218 arc4random_buf(iv, EVP_CIPHER_iv_length(cipher)); 218 arc4random_buf(iv, EVP_CIPHER_iv_length(cipher));
219 } 219 }
220 220
221 EVP_CIPHER_CTX_init(&ctx); 221 EVP_CIPHER_CTX_legacy_clear(&ctx);
222 222
223 /* Dummy cipherinit to just setup the IV, and PRF */ 223 /* Dummy cipherinit to just setup the IV, and PRF */
224 if (!EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0)) 224 if (!EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0))
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c
index d2132adb4e..dd3840074f 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.29 2023/07/07 19:37:53 beck Exp $ */ 1/* $OpenBSD: bio_enc.c,v 1.30 2024/02/18 15:44:10 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 *
@@ -115,7 +115,7 @@ enc_new(BIO *bi)
115 ctx = malloc(sizeof(BIO_ENC_CTX)); 115 ctx = malloc(sizeof(BIO_ENC_CTX));
116 if (ctx == NULL) 116 if (ctx == NULL)
117 return (0); 117 return (0);
118 EVP_CIPHER_CTX_init(&ctx->cipher); 118 EVP_CIPHER_CTX_legacy_clear(&ctx->cipher);
119 119
120 ctx->buf_len = 0; 120 ctx->buf_len = 0;
121 ctx->buf_off = 0; 121 ctx->buf_off = 0;
@@ -360,7 +360,7 @@ again:
360 case BIO_CTRL_DUP: 360 case BIO_CTRL_DUP:
361 dbio = (BIO *)ptr; 361 dbio = (BIO *)ptr;
362 dctx = (BIO_ENC_CTX *)dbio->ptr; 362 dctx = (BIO_ENC_CTX *)dbio->ptr;
363 EVP_CIPHER_CTX_init(&dctx->cipher); 363 EVP_CIPHER_CTX_legacy_clear(&dctx->cipher);
364 ret = EVP_CIPHER_CTX_copy(&dctx->cipher, &ctx->cipher); 364 ret = EVP_CIPHER_CTX_copy(&dctx->cipher, &ctx->cipher);
365 if (ret) 365 if (ret)
366 dbio->init = 1; 366 dbio->init = 1;
diff --git a/src/lib/libcrypto/evp/p_legacy.c b/src/lib/libcrypto/evp/p_legacy.c
index f73a6a9dae..2036258dc5 100644
--- a/src/lib/libcrypto/evp/p_legacy.c
+++ b/src/lib/libcrypto/evp/p_legacy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p_legacy.c,v 1.2 2023/12/20 13:52:17 tb Exp $ */ 1/* $OpenBSD: p_legacy.c,v 1.3 2024/02/18 15:44:10 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 *
@@ -99,7 +99,7 @@ EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
99 int i, size = 0, ret = 0; 99 int i, size = 0, ret = 0;
100 100
101 if (type) { 101 if (type) {
102 EVP_CIPHER_CTX_init(ctx); 102 EVP_CIPHER_CTX_legacy_clear(ctx);
103 if (!EVP_DecryptInit_ex(ctx, type, NULL, NULL, NULL)) 103 if (!EVP_DecryptInit_ex(ctx, type, NULL, NULL, NULL))
104 return 0; 104 return 0;
105 } 105 }
@@ -154,7 +154,7 @@ EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
154 int i, iv_len; 154 int i, iv_len;
155 155
156 if (type) { 156 if (type) {
157 EVP_CIPHER_CTX_init(ctx); 157 EVP_CIPHER_CTX_legacy_clear(ctx);
158 if (!EVP_EncryptInit_ex(ctx, type, NULL, NULL, NULL)) 158 if (!EVP_EncryptInit_ex(ctx, type, NULL, NULL, NULL))
159 return 0; 159 return 0;
160 } 160 }
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index d4e6599a77..30db092c3e 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_lib.c,v 1.55 2023/11/29 21:35:57 tb Exp $ */ 1/* $OpenBSD: pem_lib.c,v 1.56 2024/02/18 15:44:10 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 *
@@ -412,7 +412,7 @@ PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
412 PEM_dek_info(buf, objstr, enc->iv_len, (char *)iv); 412 PEM_dek_info(buf, objstr, enc->iv_len, (char *)iv);
413 /* k=strlen(buf); */ 413 /* k=strlen(buf); */
414 414
415 EVP_CIPHER_CTX_init(&ctx); 415 EVP_CIPHER_CTX_legacy_clear(&ctx);
416 ret = 1; 416 ret = 1;
417 if (!EVP_EncryptInit_ex(&ctx, enc, NULL, key, iv) || 417 if (!EVP_EncryptInit_ex(&ctx, enc, NULL, key, iv) ||
418 !EVP_EncryptUpdate(&ctx, data, &j, data, i) || 418 !EVP_EncryptUpdate(&ctx, data, &j, data, i) ||
@@ -466,7 +466,7 @@ PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
466 return 0; 466 return 0;
467 467
468 j = (int)len; 468 j = (int)len;
469 EVP_CIPHER_CTX_init(&ctx); 469 EVP_CIPHER_CTX_legacy_clear(&ctx);
470 o = EVP_DecryptInit_ex(&ctx, cipher->cipher, NULL, key, 470 o = EVP_DecryptInit_ex(&ctx, cipher->cipher, NULL, key,
471 &(cipher->iv[0])); 471 &(cipher->iv[0]));
472 if (o) 472 if (o)
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index ea7f6a5ffa..04818acd13 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_decr.c,v 1.24 2023/02/16 08:38:17 tb Exp $ */ 1/* $OpenBSD: p12_decr.c,v 1.25 2024/02/18 15:44:10 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -77,7 +77,7 @@ PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, int passlen,
77 int outlen, i; 77 int outlen, i;
78 EVP_CIPHER_CTX ctx; 78 EVP_CIPHER_CTX ctx;
79 79
80 EVP_CIPHER_CTX_init(&ctx); 80 EVP_CIPHER_CTX_legacy_clear(&ctx);
81 /* Decrypt data */ 81 /* Decrypt data */
82 if (!EVP_PBE_CipherInit(algor->algorithm, pass, passlen, 82 if (!EVP_PBE_CipherInit(algor->algorithm, pass, passlen,
83 algor->parameter, &ctx, en_de)) { 83 algor->parameter, &ctx, en_de)) {