Переглянути джерело

Merge pull request #7032 from SparkiDev/sp_int_neg_mont_red

SP int neg sp_mont_red_ex: disallow negative numbers
JacobBarthelmeh 9 місяців тому
батько
коміт
0ffb586030
1 змінених файлів з 5 додано та 0 видалено
  1. 5 0
      wolfcrypt/src/sp_int.c

+ 5 - 0
wolfcrypt/src/sp_int.c

@@ -17524,6 +17524,11 @@ int sp_mont_red_ex(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
     if ((a == NULL) || (m == NULL) || sp_iszero(m)) {
         err = MP_VAL;
     }
+#ifdef WOLFSSL_SP_INT_NEGATIVE
+    else if ((a->sign == MP_NEG) || (m->sign == MP_NEG)) {
+        err = MP_VAL;
+    }
+#endif
     /* Ensure a has enough space for calculation. */
     else if (a->size < m->used * 2 + 1) {
         err = MP_VAL;