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
-/* $OpenBSD: e_aes.c,v 1.50 2022/11/26 16:08:52 tb Exp $ */
+/* $OpenBSD: e_aes.c,v 1.51 2023/03/01 11:16:06 tb Exp $ */
/* ====================================================================
* Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
*
#endif
}
-static void
+static int
aes_gcm_cleanup(EVP_CIPHER_CTX *c)
{
EVP_AES_GCM_CTX *gctx = c->cipher_data;
free(gctx->iv);
explicit_bzero(gctx, sizeof(*gctx));
+
+ return 1;
}
/* increment counter (64-bit int) by 1 */
-/* $OpenBSD: e_chacha20poly1305.c,v 1.27 2022/11/26 16:08:52 tb Exp $ */
+/* $OpenBSD: e_chacha20poly1305.c,v 1.28 2023/03/01 11:16:06 tb Exp $ */
/*
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
return len;
}
-static void
+static int
chacha20_poly1305_cleanup(EVP_CIPHER_CTX *ctx)
{
struct chacha20_poly1305_ctx *cpx = ctx->cipher_data;
explicit_bzero(cpx, sizeof(*cpx));
+
+ return 1;
}
static int
-/* $OpenBSD: evp_enc.c,v 1.49 2022/12/26 07:18:52 jmc Exp $ */
+/* $OpenBSD: evp_enc.c,v 1.50 2023/03/01 11:16:06 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
{
if (c->cipher != NULL) {
+ /* XXX - Avoid leaks, so ignore return value of cleanup()... */
if (c->cipher->cleanup != NULL)
c->cipher->cleanup(c);
if (c->cipher_data != NULL)
-/* $OpenBSD: evp_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */
+/* $OpenBSD: evp_local.h,v 1.3 2023/03/01 11:16:06 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
const unsigned char *iv, int enc); /* init key */
int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl);/* encrypt/decrypt data */
- void (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
+ int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
int ctx_size; /* how big ctx->cipher_data needs to be */
int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */