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