]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
dh_to_text: Print the dh->length if set
authorTomas Mraz <tomas@openssl.org>
Fri, 10 Jun 2022 07:46:45 +0000 (09:46 +0200)
committerHugo Landau <hlandau@openssl.org>
Mon, 18 Jul 2022 07:06:17 +0000 (08:06 +0100)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18480)

providers/implementations/encode_decode/encode_key2text.c
test/recipes/30-test_evp_pkey_provided/DH.priv.txt
test/recipes/30-test_evp_pkey_provided/DH.pub.txt

index 80d6f7b35fdcd22fcadd44da3e45c0d97631dea2..7d983f5e51c6dfa9f2d896335a89719fd481b22b 100644 (file)
@@ -220,6 +220,7 @@ static int dh_to_text(BIO *out, const void *key, int selection)
     const BIGNUM *priv_key = NULL, *pub_key = NULL;
     const FFC_PARAMS *params = NULL;
     const BIGNUM *p = NULL;
+    long length;
 
     if (out == NULL || dh == NULL) {
         ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
@@ -272,6 +273,11 @@ static int dh_to_text(BIO *out, const void *key, int selection)
     if (params != NULL
         && !ffc_params_to_text(out, params))
         return 0;
+    length = DH_get_length(dh);
+    if (length > 0
+        && BIO_printf(out, "recommended-private-length: %ld bits\n",
+                      length) <= 0)
+        return 0;
 
     return 1;
 }
index 0e6f9519b4b5344475ed86b2ccf50fa335d690b4..0dd83429f5b6e5ba26e1f1bbbb2807db951e90ee 100644 (file)
@@ -22,3 +22,4 @@ public-key:
     a8:ee:72:13:45:65:15:42:17:aa:d8:ab:cf:33:42:
     83:42
 GROUP: ffdhe2048
+recommended-private-length: 224 bits
index 325e160f36e70a5c71bedd4668dc5ddaf5d71fc6..491f9d9d5e1a65cea5bc9c915d7c4a6beaffc8ce 100644 (file)
@@ -19,3 +19,4 @@ public-key:
     a8:ee:72:13:45:65:15:42:17:aa:d8:ab:cf:33:42:
     83:42
 GROUP: ffdhe2048
+recommended-private-length: 224 bits