|
|
a74aed |
From 51b721b69fd08ef1c4c4989f5e12b643e170ff56 Mon Sep 17 00:00:00 2001
|
|
|
a74aed |
From: Pedro Monreal <pmgdeb@gmail.com>
|
|
|
a74aed |
Date: Thu, 16 Feb 2023 17:02:38 +0100
|
|
|
a74aed |
Subject: [PATCH] pk: extend pair-wise consistency to cover DH key generation
|
|
|
a74aed |
|
|
|
a74aed |
Perform SP800 56A (rev 3) 5.6.2.1.4 Owner Assurance of Pair-wise
|
|
|
a74aed |
Consistency check, even if we only support ephemeral DH, as it is
|
|
|
a74aed |
required by FIPS 140-3 IG 10.3.A.
|
|
|
a74aed |
|
|
|
a74aed |
Signed-off-by: Pedro Monreal <pmgdeb@gmail.com>
|
|
|
a74aed |
Co-authored-by: Daiki Ueno <ueno@gnu.org>
|
|
|
a74aed |
---
|
|
|
a74aed |
lib/nettle/pk.c | 29 +++++++++++++++++++++++++++++
|
|
|
a74aed |
1 file changed, 29 insertions(+)
|
|
|
a74aed |
|
|
|
a74aed |
diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c
|
|
|
a74aed |
index d30bca594f..bd9c1b4c74 100644
|
|
|
a74aed |
--- a/lib/nettle/pk.c
|
|
|
a74aed |
+++ b/lib/nettle/pk.c
|
|
|
a74aed |
@@ -2642,6 +2642,35 @@ static int pct_test(gnutls_pk_algorithm_t algo,
|
|
|
a74aed |
}
|
|
|
a74aed |
break;
|
|
|
a74aed |
case GNUTLS_PK_DH:
|
|
|
a74aed |
+ {
|
|
|
a74aed |
+ mpz_t y;
|
|
|
a74aed |
+
|
|
|
a74aed |
+ /* Perform SP800 56A (rev 3) 5.6.2.1.4 Owner Assurance
|
|
|
a74aed |
+ * of Pair-wise Consistency check, even if we only
|
|
|
a74aed |
+ * support ephemeral DH, as it is required by FIPS
|
|
|
a74aed |
+ * 140-3 IG 10.3.A.
|
|
|
a74aed |
+ *
|
|
|
a74aed |
+ * Use the private key, x, along with the generator g
|
|
|
a74aed |
+ * and prime modulus p included in the domain
|
|
|
a74aed |
+ * parameters associated with the key pair to compute
|
|
|
a74aed |
+ * g^x mod p. Compare the result to the public key, y.
|
|
|
a74aed |
+ */
|
|
|
a74aed |
+ mpz_init(y);
|
|
|
a74aed |
+ mpz_powm(y,
|
|
|
a74aed |
+ TOMPZ(params->params[DSA_G]),
|
|
|
a74aed |
+ TOMPZ(params->params[DSA_X]),
|
|
|
a74aed |
+ TOMPZ(params->params[DSA_P]));
|
|
|
a74aed |
+ if (unlikely
|
|
|
a74aed |
+ (mpz_cmp(y, TOMPZ(params->params[DSA_Y])) != 0)) {
|
|
|
a74aed |
+ ret =
|
|
|
a74aed |
+ gnutls_assert_val
|
|
|
a74aed |
+ (GNUTLS_E_PK_GENERATION_ERROR);
|
|
|
a74aed |
+ mpz_clear(y);
|
|
|
a74aed |
+ goto cleanup;
|
|
|
a74aed |
+ }
|
|
|
a74aed |
+ mpz_clear(y);
|
|
|
a74aed |
+ break;
|
|
|
a74aed |
+ }
|
|
|
a74aed |
case GNUTLS_PK_ECDH_X25519:
|
|
|
a74aed |
case GNUTLS_PK_ECDH_X448:
|
|
|
a74aed |
ret = 0;
|
|
|
a74aed |
--
|
|
|
a74aed |
2.39.2
|
|
|
a74aed |
|