From: brynet@openbsd.org Date: Thu, 30 Jul 2026 07:40:48 +0000 (+0000) Subject: upstream: Use ssh_mldsa44_ed25519_cleanup consistently to avoid X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;ds=inline;p=thirdparty%2Fopenssh-portable.git upstream: Use ssh_mldsa44_ed25519_cleanup consistently to avoid calling freezero with the wrong size. With help from tb@ ok tb, dtucker@ OpenBSD-Commit-ID: 4de18532e448a62005e12c179786bec512b83fde --- diff --git a/ssh-mldsa-eddsa.c b/ssh-mldsa-eddsa.c index d5cb3d9a0..390b471db 100644 --- a/ssh-mldsa-eddsa.c +++ b/ssh-mldsa-eddsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-mldsa-eddsa.c,v 1.3 2026/07/30 03:13:34 deraadt Exp $ */ +/* $OpenBSD: ssh-mldsa-eddsa.c,v 1.4 2026/07/30 07:40:48 brynet Exp $ */ /* * Copyright (c) 2026 Damien Miller * @@ -343,22 +343,15 @@ ssh_mldsa44_ed25519_deserialize_private(const char *ktype, struct sshbuf *b, static int ssh_mldsa44_ed25519_generate(struct sshkey *k, int bits) { - free(k->mldsa_ed25519_pk); - free(k->mldsa_ed25519_sk); - k->mldsa_ed25519_pk = NULL; - k->mldsa_ed25519_sk = NULL; + ssh_mldsa44_ed25519_cleanup(k); if ((k->mldsa_ed25519_pk = malloc(MLDSA44_ED25519_PK_SZ)) == NULL || (k->mldsa_ed25519_sk = malloc(MLDSA44_ED25519_SK_SZ)) == NULL) { - free(k->mldsa_ed25519_pk); - k->mldsa_ed25519_pk = NULL; + ssh_mldsa44_ed25519_cleanup(k); return SSH_ERR_ALLOC_FAIL; } if (crypto_sign_mldsa44_ed25519_keygen(k->mldsa_ed25519_pk, k->mldsa_ed25519_sk) != 0) { - freezero(k->mldsa_ed25519_pk, MLDSA44_ED25519_PK_SZ); - k->mldsa_ed25519_pk = NULL; - freezero(k->mldsa_ed25519_sk, MLDSA44_ED25519_PK_SZ); - k->mldsa_ed25519_sk = NULL; + ssh_mldsa44_ed25519_cleanup(k); return SSH_ERR_CRYPTO_ERROR; } return 0;