summaryrefslogtreecommitdiff
path: root/thirdparty/mbedtls/library/rsa.c
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2020-12-19 13:11:02 +0100
committerGitHub <noreply@github.com>2020-12-19 13:11:02 +0100
commit229fb888a3b8538952858e688ada21e2ff53bb15 (patch)
tree6de1cd90ee7bb98225c86e44e4515dfc5b6ac40a /thirdparty/mbedtls/library/rsa.c
parentbb53e35ab884b6f0f8658e58fe3cedfb2416ff4d (diff)
parent2872006039f77748479a2feeb3a8dcf5a0bc9d90 (diff)
Merge pull request #44505 from akien-mga/mbedtls-2.16.9
mbedtls: Update to upstream version 2.16.9
Diffstat (limited to 'thirdparty/mbedtls/library/rsa.c')
-rw-r--r--thirdparty/mbedtls/library/rsa.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/thirdparty/mbedtls/library/rsa.c b/thirdparty/mbedtls/library/rsa.c
index 42becbf17b..a25c633bc6 100644
--- a/thirdparty/mbedtls/library/rsa.c
+++ b/thirdparty/mbedtls/library/rsa.c
@@ -841,15 +841,14 @@ static int rsa_prepare_blinding( mbedtls_rsa_context *ctx,
* which one, we just loop and choose new values for both of them.
* (Each iteration succeeds with overwhelming probability.) */
ret = mbedtls_mpi_inv_mod( &ctx->Vi, &ctx->Vi, &ctx->N );
- if( ret == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE )
- continue;
- if( ret != 0 )
+ if( ret != 0 && ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE )
goto cleanup;
- /* Finish the computation of Vf^-1 = R * (R Vf)^-1 */
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &R ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->N ) );
- } while( 0 );
+ } while( ret == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE );
+
+ /* Finish the computation of Vf^-1 = R * (R Vf)^-1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &R ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->N ) );
/* Blinding value: Vi = Vf^(-e) mod N
* (Vi already contains Vf^-1 at this point) */