Blame SOURCES/gnutls-3.7.6-fips-pkcs12-des-cbc.patch

e79d4b
From de09280b2a8314eb98ec9a2b84eebe3eec2f49bd Mon Sep 17 00:00:00 2001
e79d4b
From: Daiki Ueno <ueno@gnu.org>
e79d4b
Date: Thu, 4 Aug 2022 16:37:51 +0900
e79d4b
Subject: [PATCH] _gnutls_decrypt_pbes1_des_md5_data: use public crypto API
e79d4b
e79d4b
This is a follow-up of e7f9267342bc2231149a640163c82b63c86f1dfd.  In
e79d4b
the decryption code path with PBES1, algorithm checks for FIPS was not
e79d4b
applied, because it used internal functions that bypass those checks.
e79d4b
e79d4b
Signed-off-by: Daiki Ueno <ueno@gnu.org>
e79d4b
---
e79d4b
 lib/x509/privkey_pkcs8_pbes1.c | 10 ++++------
e79d4b
 1 file changed, 4 insertions(+), 6 deletions(-)
e79d4b
e79d4b
diff --git a/lib/x509/privkey_pkcs8_pbes1.c b/lib/x509/privkey_pkcs8_pbes1.c
e79d4b
index c296807974..983530e46a 100644
e79d4b
--- a/lib/x509/privkey_pkcs8_pbes1.c
e79d4b
+++ b/lib/x509/privkey_pkcs8_pbes1.c
e79d4b
@@ -140,7 +140,7 @@ _gnutls_decrypt_pbes1_des_md5_data(const char *password,
e79d4b
 {
e79d4b
 	int result;
e79d4b
 	gnutls_datum_t dkey, d_iv;
e79d4b
-	cipher_hd_st ch;
e79d4b
+	gnutls_cipher_hd_t ch;
e79d4b
 	uint8_t key[16];
e79d4b
 	const unsigned block_size = 8;
e79d4b
 
e79d4b
@@ -158,16 +158,14 @@ _gnutls_decrypt_pbes1_des_md5_data(const char *password,
e79d4b
 	dkey.size = 8;
e79d4b
 	d_iv.data = &key[8];
e79d4b
 	d_iv.size = 8;
e79d4b
-	result =
e79d4b
-	    _gnutls_cipher_init(&ch, cipher_to_entry(GNUTLS_CIPHER_DES_CBC),
e79d4b
-				&dkey, &d_iv, 0);
e79d4b
+	result = gnutls_cipher_init(&ch, GNUTLS_CIPHER_DES_CBC, &dkey, &d_iv);
e79d4b
 	if (result < 0) {
e79d4b
 		_gnutls_switch_fips_state(GNUTLS_FIPS140_OP_ERROR);
e79d4b
 		return gnutls_assert_val(result);
e79d4b
 	}
e79d4b
 	_gnutls_switch_fips_state(GNUTLS_FIPS140_OP_NOT_APPROVED);
e79d4b
 
e79d4b
-	result = _gnutls_cipher_decrypt(&ch, encrypted_data->data, encrypted_data->size);
e79d4b
+	result = gnutls_cipher_decrypt(ch, encrypted_data->data, encrypted_data->size);
e79d4b
 	if (result < 0) {
e79d4b
 		gnutls_assert();
e79d4b
 		goto error;
e79d4b
@@ -184,7 +182,7 @@ _gnutls_decrypt_pbes1_des_md5_data(const char *password,
e79d4b
 
e79d4b
 	result = 0;
e79d4b
  error:
e79d4b
-	_gnutls_cipher_deinit(&ch);
e79d4b
+	gnutls_cipher_deinit(ch);
e79d4b
 
e79d4b
 	return result;
e79d4b
 }
e79d4b
-- 
e79d4b
2.37.1
e79d4b