refactor with mp_init_multi

This commit is contained in:
Francois Perrad 2019-09-02 18:32:33 +02:00
parent 8a1656c01c
commit 49abba0937
2 changed files with 5 additions and 9 deletions

View File

@ -26,20 +26,17 @@ mp_err mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y)
return MP_VAL;
}
/* first compute 1/G mod P */
if ((err = mp_init(&tmpG)) != MP_OKAY) {
if ((err = mp_init_multi(&tmpG, &tmpX, NULL)) != MP_OKAY) {
return err;
}
/* first compute 1/G mod P */
if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) {
mp_clear(&tmpG);
mp_clear_multi(&tmpG, &tmpX, NULL);
return err;
}
/* now get |X| */
if ((err = mp_init(&tmpX)) != MP_OKAY) {
mp_clear(&tmpG);
return err;
}
if ((err = mp_abs(X, &tmpX)) != MP_OKAY) {
mp_clear_multi(&tmpG, &tmpX, NULL);
return err;

View File

@ -405,10 +405,9 @@
#if defined(BN_MP_EXPTMOD_C)
# define BN_MP_ABS_C
# define BN_MP_CLEAR_C
# define BN_MP_CLEAR_MULTI_C
# define BN_MP_DR_IS_MODULUS_C
# define BN_MP_INIT_C
# define BN_MP_INIT_MULTI_C
# define BN_MP_INVMOD_C
# define BN_MP_REDUCE_IS_2K_C
# define BN_MP_REDUCE_IS_2K_L_C