comparison libtomcrypt/src/pk/ecc/ltc_ecc_mulmod_timing.c @ 1710:1ff2a1034c52

Fix whitespace changes vs upstream libtomcrypt
author Matt Johnston <matt@ucc.asn.au>
date Wed, 10 Jun 2020 23:01:33 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1709:04155ce30759 1710:1ff2a1034c52
15 #include "tomcrypt.h" 15 #include "tomcrypt.h"
16 16
17 /** 17 /**
18 @file ltc_ecc_mulmod_timing.c 18 @file ltc_ecc_mulmod_timing.c
19 ECC Crypto, Tom St Denis 19 ECC Crypto, Tom St Denis
20 */ 20 */
21 21
22 #ifdef LTC_MECC 22 #ifdef LTC_MECC
23 23
24 #ifdef LTC_ECC_TIMING_RESISTANT 24 #ifdef LTC_ECC_TIMING_RESISTANT
25 25
57 mp_clear(mu); 57 mp_clear(mu);
58 mp_montgomery_free(mp); 58 mp_montgomery_free(mp);
59 return err; 59 return err;
60 } 60 }
61 61
62 /* alloc ram for window temps */ 62 /* alloc ram for window temps */
63 for (i = 0; i < 3; i++) { 63 for (i = 0; i < 3; i++) {
64 M[i] = ltc_ecc_new_point(); 64 M[i] = ltc_ecc_new_point();
65 if (M[i] == NULL) { 65 if (M[i] == NULL) {
66 for (j = 0; j < i; j++) { 66 for (j = 0; j < i; j++) {
67 ltc_ecc_del_point(M[j]); 67 ltc_ecc_del_point(M[j]);
68 } 68 }
69 mp_clear(mu); 69 mp_clear(mu);
70 mp_montgomery_free(mp); 70 mp_montgomery_free(mp);
71 return CRYPT_MEM; 71 return CRYPT_MEM;
72 } 72 }
73 } 73 }
74 74
75 /* make a copy of G incase R==G */ 75 /* make a copy of G incase R==G */
76 tG = ltc_ecc_new_point(); 76 tG = ltc_ecc_new_point();
77 if (tG == NULL) { err = CRYPT_MEM; goto done; } 77 if (tG == NULL) { err = CRYPT_MEM; goto done; }
78 78
80 if ((err = mp_mulmod(G->x, mu, modulus, tG->x)) != CRYPT_OK) { goto done; } 80 if ((err = mp_mulmod(G->x, mu, modulus, tG->x)) != CRYPT_OK) { goto done; }
81 if ((err = mp_mulmod(G->y, mu, modulus, tG->y)) != CRYPT_OK) { goto done; } 81 if ((err = mp_mulmod(G->y, mu, modulus, tG->y)) != CRYPT_OK) { goto done; }
82 if ((err = mp_mulmod(G->z, mu, modulus, tG->z)) != CRYPT_OK) { goto done; } 82 if ((err = mp_mulmod(G->z, mu, modulus, tG->z)) != CRYPT_OK) { goto done; }
83 mp_clear(mu); 83 mp_clear(mu);
84 mu = NULL; 84 mu = NULL;
85 85
86 /* calc the M tab */ 86 /* calc the M tab */
87 /* M[0] == G */ 87 /* M[0] == G */
88 if ((err = mp_copy(tG->x, M[0]->x)) != CRYPT_OK) { goto done; } 88 if ((err = mp_copy(tG->x, M[0]->x)) != CRYPT_OK) { goto done; }
89 if ((err = mp_copy(tG->y, M[0]->y)) != CRYPT_OK) { goto done; } 89 if ((err = mp_copy(tG->y, M[0]->y)) != CRYPT_OK) { goto done; }
90 if ((err = mp_copy(tG->z, M[0]->z)) != CRYPT_OK) { goto done; } 90 if ((err = mp_copy(tG->z, M[0]->z)) != CRYPT_OK) { goto done; }