OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * RSA key generation, public key op, private key op. | 6 * RSA key generation, public key op, private key op. |
7 */ | 7 */ |
8 #ifdef FREEBL_NO_DEPEND | 8 #ifdef FREEBL_NO_DEPEND |
9 #include "stubs.h" | 9 #include "stubs.h" |
10 #endif | 10 #endif |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 int modLen = key->modulus.len; | 740 int modLen = key->modulus.len; |
741 if (key->modulus.data[0] == 0) { | 741 if (key->modulus.data[0] == 0) { |
742 modLen--; | 742 modLen--; |
743 } | 743 } |
744 keySizeInBits = modLen * PR_BITS_PER_BYTE; | 744 keySizeInBits = modLen * PR_BITS_PER_BYTE; |
745 SECITEM_TO_MPINT(key->modulus, &n); | 745 SECITEM_TO_MPINT(key->modulus, &n); |
746 hasModulus = PR_TRUE; | 746 hasModulus = PR_TRUE; |
747 } | 747 } |
748 /* if we have the modulus and one prime, calculate the second. */ | 748 /* if we have the modulus and one prime, calculate the second. */ |
749 if ((prime_count == 1) && (hasModulus)) { | 749 if ((prime_count == 1) && (hasModulus)) { |
750 » mp_div(&n,&p,&q,&r); | 750 » if (mp_div(&n,&p,&q,&r) != MP_OKAY || mp_cmp_z(&r) != 0) { |
751 » if (mp_cmp_z(&r) != 0) { | |
752 /* p is not a factor or n, fail */ | 751 /* p is not a factor or n, fail */ |
753 err = MP_BADARG; | 752 err = MP_BADARG; |
754 goto cleanup; | 753 goto cleanup; |
755 } | 754 } |
756 prime_count++; | 755 prime_count++; |
757 } | 756 } |
758 | 757 |
759 /* If we didn't have enough primes try to calculate the primes from | 758 /* If we didn't have enough primes try to calculate the primes from |
760 * the exponents */ | 759 * the exponents */ |
761 if (prime_count < 2) { | 760 if (prime_count < 2) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 /* The last bp->next value was initialized with out | 1088 /* The last bp->next value was initialized with out |
1090 * of rsabp->array pointer and must be set to NULL | 1089 * of rsabp->array pointer and must be set to NULL |
1091 */ | 1090 */ |
1092 rsabp->array[RSA_BLINDING_PARAMS_MAX_CACHE_SIZE - 1].next = NULL; | 1091 rsabp->array[RSA_BLINDING_PARAMS_MAX_CACHE_SIZE - 1].next = NULL; |
1093 | 1092 |
1094 bp = rsabp->array; | 1093 bp = rsabp->array; |
1095 rsabp->bp = NULL; | 1094 rsabp->bp = NULL; |
1096 rsabp->free = bp; | 1095 rsabp->free = bp; |
1097 | 1096 |
1098 /* List elements are keyed using the modulus */ | 1097 /* List elements are keyed using the modulus */ |
1099 SECITEM_CopyItem(NULL, &rsabp->modulus, &key->modulus); | 1098 return SECITEM_CopyItem(NULL, &rsabp->modulus, &key->modulus); |
1100 | |
1101 return SECSuccess; | |
1102 } | 1099 } |
1103 | 1100 |
1104 static SECStatus | 1101 static SECStatus |
1105 get_blinding_params(RSAPrivateKey *key, mp_int *n, unsigned int modLen, | 1102 get_blinding_params(RSAPrivateKey *key, mp_int *n, unsigned int modLen, |
1106 mp_int *f, mp_int *g) | 1103 mp_int *f, mp_int *g) |
1107 { | 1104 { |
1108 RSABlindingParams *rsabp = NULL; | 1105 RSABlindingParams *rsabp = NULL; |
1109 blindingParams *bpUnlinked = NULL; | 1106 blindingParams *bpUnlinked = NULL; |
1110 blindingParams *bp; | 1107 blindingParams *bp; |
1111 PRCList *el; | 1108 PRCList *el; |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 PRBool bl_parentForkedAfterC_Initialize; | 1542 PRBool bl_parentForkedAfterC_Initialize; |
1546 | 1543 |
1547 /* | 1544 /* |
1548 * Set fork flag so it can be tested in SKIP_AFTER_FORK on relevant platforms. | 1545 * Set fork flag so it can be tested in SKIP_AFTER_FORK on relevant platforms. |
1549 */ | 1546 */ |
1550 void BL_SetForkState(PRBool forked) | 1547 void BL_SetForkState(PRBool forked) |
1551 { | 1548 { |
1552 bl_parentForkedAfterC_Initialize = forked; | 1549 bl_parentForkedAfterC_Initialize = forked; |
1553 } | 1550 } |
1554 | 1551 |
OLD | NEW |