Skip to content

Commit d59008f

Browse files
author
jsing
committed
Stop pretending that EVP_CIPHER cleanup can fail.
Now that EVP_CIPHER is opaque, stop pretending that EVP_CIPHER cleanup can fail. ok tb@
1 parent 9be2277 commit d59008f

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/lib/libcrypto/evp/e_aes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: e_aes.c,v 1.48 2022/09/10 17:45:10 jsing Exp $ */
1+
/* $OpenBSD: e_aes.c,v 1.49 2022/09/13 04:59:18 jsing Exp $ */
22
/* ====================================================================
33
* Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
44
*
@@ -1255,15 +1255,15 @@ EVP_aes_256_ctr(void)
12551255
#endif
12561256
}
12571257

1258-
static int
1258+
static void
12591259
aes_gcm_cleanup(EVP_CIPHER_CTX *c)
12601260
{
12611261
EVP_AES_GCM_CTX *gctx = c->cipher_data;
12621262

12631263
if (gctx->iv != c->iv)
12641264
free(gctx->iv);
1265+
12651266
explicit_bzero(gctx, sizeof(*gctx));
1266-
return 1;
12671267
}
12681268

12691269
/* increment counter (64-bit int) by 1 */

src/lib/libcrypto/evp/e_chacha20poly1305.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: e_chacha20poly1305.c,v 1.25 2022/08/30 19:33:26 tb Exp $ */
1+
/* $OpenBSD: e_chacha20poly1305.c,v 1.26 2022/09/13 04:59:18 jsing Exp $ */
22

33
/*
44
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
@@ -530,14 +530,12 @@ chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
530530
return len;
531531
}
532532

533-
static int
533+
static void
534534
chacha20_poly1305_cleanup(EVP_CIPHER_CTX *ctx)
535535
{
536536
struct chacha20_poly1305_ctx *cpx = ctx->cipher_data;
537537

538538
explicit_bzero(cpx, sizeof(*cpx));
539-
540-
return 1;
541539
}
542540

543541
static int

src/lib/libcrypto/evp/evp_enc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: evp_enc.c,v 1.46 2022/09/04 13:34:13 jsing Exp $ */
1+
/* $OpenBSD: evp_enc.c,v 1.47 2022/09/13 04:59:18 jsing Exp $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -601,18 +601,21 @@ int
601601
EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
602602
{
603603
if (c->cipher != NULL) {
604-
if (c->cipher->cleanup && !c->cipher->cleanup(c))
605-
return 0;
606-
/* Cleanse cipher context data */
607-
if (c->cipher_data)
604+
if (c->cipher->cleanup != NULL)
605+
c->cipher->cleanup(c);
606+
if (c->cipher_data != NULL)
608607
explicit_bzero(c->cipher_data, c->cipher->ctx_size);
609608
}
609+
610610
/* XXX - store size of cipher_data so we can always freezero(). */
611611
free(c->cipher_data);
612+
612613
#ifndef OPENSSL_NO_ENGINE
613614
ENGINE_finish(c->engine);
614615
#endif
616+
615617
explicit_bzero(c, sizeof(EVP_CIPHER_CTX));
618+
616619
return 1;
617620
}
618621

src/lib/libcrypto/evp/evp_locl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: evp_locl.h,v 1.27 2022/09/04 09:56:30 jsing Exp $ */
1+
/* $OpenBSD: evp_locl.h,v 1.28 2022/09/13 04:59:18 jsing Exp $ */
22
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
33
* project 2000.
44
*/
@@ -143,7 +143,7 @@ struct evp_cipher_st {
143143
const unsigned char *iv, int enc); /* init key */
144144
int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
145145
const unsigned char *in, size_t inl);/* encrypt/decrypt data */
146-
int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
146+
void (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
147147
int ctx_size; /* how big ctx->cipher_data needs to be */
148148
int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
149149
int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */

0 commit comments

Comments
 (0)