All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/13] pem: Wipe more memory in PKCS#1 private key decoding
@ 2020-12-10 19:31 Andrew Zaborowski
  2020-12-10 19:31 ` [PATCH 02/13] pem: Factor out the PKCS#8 decoding code Andrew Zaborowski
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Andrew Zaborowski @ 2020-12-10 19:31 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

bzero some more potentially sensitive memory that we weren't bzeroing in
the recently added openssl legacy PKCS#1 private key format decoding.
---
 ell/pem.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/ell/pem.c b/ell/pem.c
index 790f2c2..70d1f62 100644
--- a/ell/pem.c
+++ b/ell/pem.c
@@ -581,18 +581,24 @@ static struct l_cipher *cipher_from_dek_info(const char *algid, const char *para
 
 	l_checksum_free(md5);
 
-	if (!ok)
-		return NULL;
+	if (!ok) {
+		cipher = NULL;
+		goto cleanup;
+	}
 
 	cipher  = l_cipher_new(type, key, key_len);
 	if (!cipher)
-		return NULL;
+		goto cleanup;
 
 	if (l_cipher_set_iv(cipher, iv, iv_len))
-		return cipher;
+		goto cleanup;
 
 	l_cipher_free(cipher);
-	return NULL;
+	cipher = NULL;
+
+cleanup:
+	explicit_bzero(key, sizeof(key));
+	return cipher;
 }
 
 static struct l_key *pem_load_private_key(uint8_t *content,
@@ -821,8 +827,10 @@ static struct l_key *pem_load_private_key(uint8_t *content,
 		ptr += sizeof(pkcs1_rsa_encryption);
 		memcpy(ptr, private_key, private_key_len);
 		ptr += private_key_len;
+		explicit_bzero(private_key, private_key_len);
 		l_free(private_key);
 
+		explicit_bzero(content, len);
 		l_free(content);
 		content = one_asymmetric_key;
 		len = ptr - one_asymmetric_key;
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-12-12  0:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 19:31 [PATCH 01/13] pem: Wipe more memory in PKCS#1 private key decoding Andrew Zaborowski
2020-12-10 19:31 ` [PATCH 02/13] pem: Factor out the PKCS#8 decoding code Andrew Zaborowski
2020-12-10 19:31 ` [PATCH 03/13] cipher: Add an RC2 implementation Andrew Zaborowski
2020-12-10 19:31 ` [PATCH 04/13] cipher: Add ARC4 implementation Andrew Zaborowski
2020-12-10 22:46   ` Denis Kenzior
2020-12-10 19:31 ` [PATCH 05/13] pem: Don't expect padding with stream ciphers Andrew Zaborowski
2020-12-10 19:31 ` [PATCH 06/13] pkcs5: Add the PKCS#12 KDF Andrew Zaborowski
2020-12-10 22:51   ` Denis Kenzior
2020-12-11 10:34     ` Andrew Zaborowski
2020-12-11 15:50       ` Denis Kenzior
2020-12-12  0:06         ` Andrew Zaborowski
2020-12-10 19:32 ` [PATCH 07/13] pkcs5: Add PKCS#12 algorithms in pkcs5_cipher_from_alg_id Andrew Zaborowski
2020-12-10 19:32 ` [PATCH 08/13] pem: Add l_pem_load_container_file Andrew Zaborowski
2020-12-10 19:32 ` [PATCH 09/13] pem: Add PKCS#12 parsing Andrew Zaborowski
2020-12-10 22:47 ` [PATCH 01/13] pem: Wipe more memory in PKCS#1 private key decoding Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.