|
|
4eda52 |
From 387ba3f36092f2072ee6a05abeac27deaca177bd Mon Sep 17 00:00:00 2001
|
|
|
4eda52 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
4eda52 |
Date: Wed, 29 Sep 2021 15:03:44 +0200
|
|
|
4eda52 |
Subject: [PATCH] openssl-util: use EVP API to get RSA bits
|
|
|
4eda52 |
|
|
|
4eda52 |
(cherry picked from commit 7f12adc3000c08a370f74bd16c654506c8a99e92)
|
|
|
4eda52 |
|
|
|
4eda52 |
Resolves: #2016042
|
|
|
4eda52 |
---
|
|
|
4eda52 |
src/shared/openssl-util.c | 7 +------
|
|
|
4eda52 |
1 file changed, 1 insertion(+), 6 deletions(-)
|
|
|
4eda52 |
|
|
|
4eda52 |
diff --git a/src/shared/openssl-util.c b/src/shared/openssl-util.c
|
|
|
4eda52 |
index bb47ae5e87..bd728e6c7c 100644
|
|
|
4eda52 |
--- a/src/shared/openssl-util.c
|
|
|
4eda52 |
+++ b/src/shared/openssl-util.c
|
|
|
4eda52 |
@@ -46,7 +46,6 @@ int rsa_pkey_to_suitable_key_size(
|
|
|
4eda52 |
size_t *ret_suitable_key_size) {
|
|
|
4eda52 |
|
|
|
4eda52 |
size_t suitable_key_size;
|
|
|
4eda52 |
- const RSA *rsa;
|
|
|
4eda52 |
int bits;
|
|
|
4eda52 |
|
|
|
4eda52 |
assert_se(pkey);
|
|
|
4eda52 |
@@ -58,11 +57,7 @@ int rsa_pkey_to_suitable_key_size(
|
|
|
4eda52 |
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA)
|
|
|
4eda52 |
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "X.509 certificate does not refer to RSA key.");
|
|
|
4eda52 |
|
|
|
4eda52 |
- rsa = EVP_PKEY_get0_RSA(pkey);
|
|
|
4eda52 |
- if (!rsa)
|
|
|
4eda52 |
- return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Failed to acquire RSA public key from X.509 certificate.");
|
|
|
4eda52 |
-
|
|
|
4eda52 |
- bits = RSA_bits(rsa);
|
|
|
4eda52 |
+ bits = EVP_PKEY_bits(pkey);
|
|
|
4eda52 |
log_debug("Bits in RSA key: %i", bits);
|
|
|
4eda52 |
|
|
|
4eda52 |
/* We use PKCS#1 padding for the RSA cleartext, hence let's leave some extra space for it, hence only
|