Commit c194e75a28 for openssl.org
commit c194e75a28ab365f7ccab71e43d48f5f20ec347f
Author: Jun Aruga <jaruga@redhat.com>
Date: Tue Mar 17 17:01:58 2026 +0000
Improve bad FFC parameters error messages with L, N arguments
Improve the finite field cryptography (FFC) messages with L, N arguments.
Fixes #17108
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Fri Mar 27 16:29:59 2026
(Merged from https://github.com/openssl/openssl/pull/30493)
diff --git a/crypto/ffc/ffc_params_generate.c b/crypto/ffc/ffc_params_generate.c
index d2792383eb..801cb4cd62 100644
--- a/crypto/ffc/ffc_params_generate.c
+++ b/crypto/ffc/ffc_params_generate.c
@@ -46,7 +46,8 @@ static int ffc_validate_LN(size_t L, size_t N, int type, int verify)
if (L == 2048 && (N == 224 || N == 256))
return 112;
#ifndef OPENSSL_NO_DH
- ERR_raise(ERR_LIB_DH, DH_R_BAD_FFC_PARAMETERS);
+ ERR_raise_data(ERR_LIB_DH, DH_R_BAD_FFC_PARAMETERS,
+ "(L, N)=(%zu, %zu) should be (2048, 224) or (2048, 256)", L, N);
#endif
} else if (type == FFC_PARAM_TYPE_DSA) {
/* Valid DSA L,N parameters from FIPS 186-4 Section 4.2 */
@@ -58,7 +59,10 @@ static int ffc_validate_LN(size_t L, size_t N, int type, int verify)
if (L == 3072 && N == 256)
return 128;
#ifndef OPENSSL_NO_DSA
- ERR_raise(ERR_LIB_DSA, DSA_R_BAD_FFC_PARAMETERS);
+ ERR_raise_data(ERR_LIB_DSA, DSA_R_BAD_FFC_PARAMETERS,
+ "(L, N)=(%zu, %zu) should be (1024, 160) (for verification only), "
+ "(2048, 224), (2048, 256), or (3072, 256)",
+ L, N);
#endif
}
return 0;
@@ -74,7 +78,10 @@ static int ffc_validate_LN(size_t L, size_t N, int type, int verify)
if (L == 2048 && (N == 224 || N == 256))
return 112;
#ifndef OPENSSL_NO_DH
- ERR_raise(ERR_LIB_DH, DH_R_BAD_FFC_PARAMETERS);
+ ERR_raise_data(ERR_LIB_DH, DH_R_BAD_FFC_PARAMETERS,
+ "(L, N)=(%zu, %zu) should be (1024, 160), (2048, 224), or "
+ "(2048, 256)",
+ L, N);
#endif
} else if (type == FFC_PARAM_TYPE_DSA) {
if (L >= 3072 && N >= 256)
@@ -84,7 +91,8 @@ static int ffc_validate_LN(size_t L, size_t N, int type, int verify)
if (L >= 1024 && N >= 160)
return 80;
#ifndef OPENSSL_NO_DSA
- ERR_raise(ERR_LIB_DSA, DSA_R_BAD_FFC_PARAMETERS);
+ ERR_raise_data(ERR_LIB_DSA, DSA_R_BAD_FFC_PARAMETERS,
+ "(L, N)=(%zu, %zu) should be at least (1024, 160)", L, N);
#endif
}
return 0;