summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-03-01 11:16:06 +0000
committertb <>2023-03-01 11:16:06 +0000
commitf5e0861acadab7b2625681b497a31647ae1ac5e2 (patch)
treeddd86c921e987eb4b4fd9638484ec09a25f73f4a
parent570f472a828e4bb99852360fc02874847bbe787a (diff)
downloadopenbsd-f5e0861acadab7b2625681b497a31647ae1ac5e2.tar.gz
openbsd-f5e0861acadab7b2625681b497a31647ae1ac5e2.tar.bz2
openbsd-f5e0861acadab7b2625681b497a31647ae1ac5e2.zip
Make the cleanup() method return an int again
This partially reverts jsing's OpenBSD commit b8185953, but without adding back the error check that potentialy results in dumb leaks. No cleanup() method in the wild returns anything but 1. Since that's the signature in the EVP_CIPHER_meth_* API, we have no choice... ok jsing
-rw-r--r--src/lib/libcrypto/evp/e_aes.c6
-rw-r--r--src/lib/libcrypto/evp/e_chacha20poly1305.c6
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c3
-rw-r--r--src/lib/libcrypto/evp/evp_local.h4
4 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index 0d7daf43e3..790b26384d 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_aes.c,v 1.50 2022/11/26 16:08:52 tb Exp $ */ 1/* $OpenBSD: e_aes.c,v 1.51 2023/03/01 11:16:06 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -1255,7 +1255,7 @@ EVP_aes_256_ctr(void)
1255#endif 1255#endif
1256} 1256}
1257 1257
1258static void 1258static int
1259aes_gcm_cleanup(EVP_CIPHER_CTX *c) 1259aes_gcm_cleanup(EVP_CIPHER_CTX *c)
1260{ 1260{
1261 EVP_AES_GCM_CTX *gctx = c->cipher_data; 1261 EVP_AES_GCM_CTX *gctx = c->cipher_data;
@@ -1264,6 +1264,8 @@ aes_gcm_cleanup(EVP_CIPHER_CTX *c)
1264 free(gctx->iv); 1264 free(gctx->iv);
1265 1265
1266 explicit_bzero(gctx, sizeof(*gctx)); 1266 explicit_bzero(gctx, sizeof(*gctx));
1267
1268 return 1;
1267} 1269}
1268 1270
1269/* increment counter (64-bit int) by 1 */ 1271/* increment counter (64-bit int) by 1 */
diff --git a/src/lib/libcrypto/evp/e_chacha20poly1305.c b/src/lib/libcrypto/evp/e_chacha20poly1305.c
index 2635b6f675..1bd04c1f1f 100644
--- a/src/lib/libcrypto/evp/e_chacha20poly1305.c
+++ b/src/lib/libcrypto/evp/e_chacha20poly1305.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_chacha20poly1305.c,v 1.27 2022/11/26 16:08:52 tb Exp $ */ 1/* $OpenBSD: e_chacha20poly1305.c,v 1.28 2023/03/01 11:16:06 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
@@ -530,12 +530,14 @@ chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
530 return len; 530 return len;
531} 531}
532 532
533static void 533static int
534chacha20_poly1305_cleanup(EVP_CIPHER_CTX *ctx) 534chacha20_poly1305_cleanup(EVP_CIPHER_CTX *ctx)
535{ 535{
536 struct chacha20_poly1305_ctx *cpx = ctx->cipher_data; 536 struct chacha20_poly1305_ctx *cpx = ctx->cipher_data;
537 537
538 explicit_bzero(cpx, sizeof(*cpx)); 538 explicit_bzero(cpx, sizeof(*cpx));
539
540 return 1;
539} 541}
540 542
541static int 543static int
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index c64390d599..df818e3a62 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_enc.c,v 1.49 2022/12/26 07:18:52 jmc Exp $ */ 1/* $OpenBSD: evp_enc.c,v 1.50 2023/03/01 11:16:06 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 *
@@ -601,6 +601,7 @@ int
601EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) 601EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
602{ 602{
603 if (c->cipher != NULL) { 603 if (c->cipher != NULL) {
604 /* XXX - Avoid leaks, so ignore return value of cleanup()... */
604 if (c->cipher->cleanup != NULL) 605 if (c->cipher->cleanup != NULL)
605 c->cipher->cleanup(c); 606 c->cipher->cleanup(c);
606 if (c->cipher_data != NULL) 607 if (c->cipher_data != NULL)
diff --git a/src/lib/libcrypto/evp/evp_local.h b/src/lib/libcrypto/evp/evp_local.h
index 3ffaf555ba..9905b82dd5 100644
--- a/src/lib/libcrypto/evp/evp_local.h
+++ b/src/lib/libcrypto/evp/evp_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ 1/* $OpenBSD: evp_local.h,v 1.3 2023/03/01 11:16:06 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 2000. 3 * project 2000.
4 */ 4 */
@@ -153,7 +153,7 @@ struct evp_cipher_st {
153 const unsigned char *iv, int enc); /* init key */ 153 const unsigned char *iv, int enc); /* init key */
154 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, 154 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
155 const unsigned char *in, size_t inl);/* encrypt/decrypt data */ 155 const unsigned char *in, size_t inl);/* encrypt/decrypt data */
156 void (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ 156 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
157 int ctx_size; /* how big ctx->cipher_data needs to be */ 157 int ctx_size; /* how big ctx->cipher_data needs to be */
158 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ 158 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
159 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ 159 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */