Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: nss/lib/freebl/rsa.c

Issue 319593003: Update to NSS 3.16.2 Beta 3. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Remove unused function SEC_NumberOrNameStringToOIDTag Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: nss/lib/freebl/rsa.c
diff --git a/nss/lib/freebl/rsa.c b/nss/lib/freebl/rsa.c
index 04e46e781fb550cdd3936930a422e72931269f6a..fb4b5d058945fc4c7821d6ad0259a6ce94475eb3 100644
--- a/nss/lib/freebl/rsa.c
+++ b/nss/lib/freebl/rsa.c
@@ -1406,6 +1406,17 @@ RSA_PrivateKeyCheck(RSAPrivateKey *key)
CHECK_MPI_OK( mp_init(&d_q) );
CHECK_MPI_OK( mp_init(&qInv) );
CHECK_MPI_OK( mp_init(&res) );
+
+ if (!key->modulus.data || !key->prime1.data || !key->prime2.data ||
+ !key->publicExponent.data || !key->privateExponent.data ||
+ !key->exponent1.data || !key->exponent2.data ||
+ !key->coefficient.data) {
+ /*call RSA_PopulatePrivateKey first, if the application wishes to
+ * recover these parameters */
+ err = MP_BADARG;
+ goto cleanup;
+ }
+
SECITEM_TO_MPINT(key->modulus, &n);
SECITEM_TO_MPINT(key->prime1, &p);
SECITEM_TO_MPINT(key->prime2, &q);
@@ -1458,27 +1469,19 @@ RSA_PrivateKeyCheck(RSAPrivateKey *key)
CHECK_MPI_OK( mp_mulmod(&d, &e, &qsub1, &res) );
VERIFY_MPI_EQUAL_1(&res);
/*
- * The following errors can be recovered from.
+ * The following errors can be recovered from. However, the purpose of this
+ * function is to check consistency, so they are not.
*/
/* d_p == d mod p-1 */
CHECK_MPI_OK( mp_mod(&d, &psub1, &res) );
- if (mp_cmp(&d_p, &res) != 0) {
- /* swap in the correct value */
- CHECK_SEC_OK( swap_in_key_value(key->arena, &res, &key->exponent1) );
- }
+ VERIFY_MPI_EQUAL(&res, &d_p);
/* d_q == d mod q-1 */
CHECK_MPI_OK( mp_mod(&d, &qsub1, &res) );
- if (mp_cmp(&d_q, &res) != 0) {
- /* swap in the correct value */
- CHECK_SEC_OK( swap_in_key_value(key->arena, &res, &key->exponent2) );
- }
+ VERIFY_MPI_EQUAL(&res, &d_q);
/* q * q**-1 == 1 mod p */
CHECK_MPI_OK( mp_mulmod(&q, &qInv, &p, &res) );
- if (mp_cmp_d(&res, 1) != 0) {
- /* compute the correct value */
- CHECK_MPI_OK( mp_invmod(&q, &p, &qInv) );
- CHECK_SEC_OK( swap_in_key_value(key->arena, &qInv, &key->coefficient) );
- }
+ VERIFY_MPI_EQUAL_1(&res);
+
cleanup:
mp_clear(&n);
mp_clear(&p);

Powered by Google App Engine
This is Rietveld 408576698