make implementation easier to read
damn you negated logic...
This commit is contained in:
parent
f784793891
commit
8fc1af1b7e
@ -38,7 +38,7 @@ int rsa_exptmod(const unsigned char *in, unsigned long inlen,
|
|||||||
void *rnd, *rndi /* inverse of rnd */;
|
void *rnd, *rndi /* inverse of rnd */;
|
||||||
#endif
|
#endif
|
||||||
unsigned long x;
|
unsigned long x;
|
||||||
int err, no_crt;
|
int err, has_crt_parameters;
|
||||||
|
|
||||||
LTC_ARGCHK(in != NULL);
|
LTC_ARGCHK(in != NULL);
|
||||||
LTC_ARGCHK(out != NULL);
|
LTC_ARGCHK(out != NULL);
|
||||||
@ -100,9 +100,11 @@ int rsa_exptmod(const unsigned char *in, unsigned long inlen,
|
|||||||
}
|
}
|
||||||
#endif /* LTC_RSA_BLINDING */
|
#endif /* LTC_RSA_BLINDING */
|
||||||
|
|
||||||
no_crt = (key->dP == NULL) || (mp_get_digit_count(key->dP) == 0);
|
has_crt_parameters = (key->dP != NULL) && (mp_get_digit_count(key->dP) != 0) &&
|
||||||
|
(key->dQ != NULL) && (mp_get_digit_count(key->dQ) != 0) &&
|
||||||
|
(key->qP != NULL) && (mp_get_digit_count(key->qP) != 0);
|
||||||
|
|
||||||
if (no_crt) {
|
if (!has_crt_parameters) {
|
||||||
/*
|
/*
|
||||||
* In case CRT optimization parameters are not provided,
|
* In case CRT optimization parameters are not provided,
|
||||||
* the private key is directly used to exptmod it
|
* the private key is directly used to exptmod it
|
||||||
@ -133,7 +135,7 @@ int rsa_exptmod(const unsigned char *in, unsigned long inlen,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LTC_RSA_CRT_HARDENING
|
#ifdef LTC_RSA_CRT_HARDENING
|
||||||
if (!no_crt) {
|
if (has_crt_parameters) {
|
||||||
if ((err = mp_exptmod(tmp, key->e, key->N, tmpa)) != CRYPT_OK) { goto error; }
|
if ((err = mp_exptmod(tmp, key->e, key->N, tmpa)) != CRYPT_OK) { goto error; }
|
||||||
if ((err = mp_read_unsigned_bin(tmpb, (unsigned char *)in, (int)inlen)) != CRYPT_OK) { goto error; }
|
if ((err = mp_read_unsigned_bin(tmpb, (unsigned char *)in, (int)inlen)) != CRYPT_OK) { goto error; }
|
||||||
if (mp_cmp(tmpa, tmpb) != LTC_MP_EQ) { err = CRYPT_ERROR; goto error; }
|
if (mp_cmp(tmpa, tmpb) != LTC_MP_EQ) { err = CRYPT_ERROR; goto error; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user