2021-09-03 13:26:43 +02:00
|
|
|
commit 3ab80b72e85583bd727730bc5b57f91e07b89710
|
|
|
|
Author: Hans Petter Jansson <hpj@cl.no>
|
|
|
|
Date: Fri Sep 4 13:41:34 2020 +0200
|
|
|
|
|
|
|
|
Patch 38: nss-fips-stricter-dh.patch
|
|
|
|
|
2023-03-13 09:10:43 +01:00
|
|
|
Index: nss/lib/freebl/dh.c
|
|
|
|
===================================================================
|
|
|
|
--- nss.orig/lib/freebl/dh.c
|
|
|
|
+++ nss/lib/freebl/dh.c
|
|
|
|
@@ -449,7 +449,7 @@ cleanup:
|
2021-09-03 13:26:43 +02:00
|
|
|
PRBool
|
|
|
|
KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime)
|
|
|
|
{
|
|
|
|
- mp_int p, q, y, r;
|
|
|
|
+ mp_int p, q, y, r, psub1;
|
|
|
|
mp_err err;
|
|
|
|
int cmp = 1; /* default is false */
|
|
|
|
if (!Y || !prime || !subPrime) {
|
2023-03-13 09:10:43 +01:00
|
|
|
@@ -460,13 +460,24 @@ KEA_Verify(SECItem *Y, SECItem *prime, S
|
2021-09-03 13:26:43 +02:00
|
|
|
MP_DIGITS(&q) = 0;
|
|
|
|
MP_DIGITS(&y) = 0;
|
|
|
|
MP_DIGITS(&r) = 0;
|
|
|
|
+ MP_DIGITS(&psub1) = 0;
|
|
|
|
CHECK_MPI_OK(mp_init(&p));
|
|
|
|
CHECK_MPI_OK(mp_init(&q));
|
|
|
|
CHECK_MPI_OK(mp_init(&y));
|
|
|
|
CHECK_MPI_OK(mp_init(&r));
|
|
|
|
+ CHECK_MPI_OK(mp_init(&psub1));
|
|
|
|
SECITEM_TO_MPINT(*prime, &p);
|
|
|
|
SECITEM_TO_MPINT(*subPrime, &q);
|
|
|
|
SECITEM_TO_MPINT(*Y, &y);
|
|
|
|
+
|
|
|
|
+ CHECK_MPI_OK(mp_sub_d(&p, 1, &psub1));
|
|
|
|
+
|
|
|
|
+ if (mp_cmp_d(&y, 1) <= 0 ||
|
|
|
|
+ mp_cmp(&y, &psub1) >= 0) {
|
|
|
|
+ err = MP_BADARG;
|
|
|
|
+ goto cleanup;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/* compute r = y**q mod p */
|
|
|
|
CHECK_MPI_OK(mp_exptmod(&y, &q, &p, &r));
|
|
|
|
/* compare to 1 */
|
2023-03-13 09:10:43 +01:00
|
|
|
@@ -476,6 +487,7 @@ cleanup:
|
2021-09-03 13:26:43 +02:00
|
|
|
mp_clear(&q);
|
|
|
|
mp_clear(&y);
|
|
|
|
mp_clear(&r);
|
|
|
|
+ mp_clear(&psub1);
|
|
|
|
if (err) {
|
|
|
|
MP_TO_SEC_ERROR(err);
|
|
|
|
return PR_FALSE;
|