aboutsummaryrefslogtreecommitdiff
path: root/crypto/rsa/rsa_chk.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/rsa/rsa_chk.c')
-rw-r--r--crypto/rsa/rsa_chk.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/crypto/rsa/rsa_chk.c b/crypto/rsa/rsa_chk.c
index cccc2d5bac2a..c2549188f556 100644
--- a/crypto/rsa/rsa_chk.c
+++ b/crypto/rsa/rsa_chk.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -124,13 +124,17 @@ static int rsa_validate_keypair_multiprime(const RSA *key, BN_GENCB *cb)
ret = -1;
goto err;
}
+ if (!BN_div(m, NULL, l, m, ctx)) { /* remainder is 0 */
+ ret = -1;
+ goto err;
+ }
for (idx = 0; idx < ex_primes; idx++) {
pinfo = sk_RSA_PRIME_INFO_value(key->prime_infos, idx);
if (!BN_sub(k, pinfo->r, BN_value_one())) {
ret = -1;
goto err;
}
- if (!BN_mul(l, l, k, ctx)) {
+ if (!BN_mul(l, m, k, ctx)) {
ret = -1;
goto err;
}
@@ -138,12 +142,12 @@ static int rsa_validate_keypair_multiprime(const RSA *key, BN_GENCB *cb)
ret = -1;
goto err;
}
+ if (!BN_div(m, NULL, l, m, ctx)) { /* remainder is 0 */
+ ret = -1;
+ goto err;
+ }
}
- if (!BN_div(k, NULL, l, m, ctx)) { /* remainder is 0 */
- ret = -1;
- goto err;
- }
- if (!BN_mod_mul(i, key->d, key->e, k, ctx)) {
+ if (!BN_mod_mul(i, key->d, key->e, m, ctx)) {
ret = -1;
goto err;
}