Mercurial > dropbear
diff libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c @ 1471:6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 21:44:05 +0800 |
parents | f849a5ca2efc |
children |
line wrap: on
line diff
--- a/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c Thu Feb 08 23:11:40 2018 +0800 +++ b/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c Fri Feb 09 21:44:05 2018 +0800 @@ -5,8 +5,6 @@ * * The library is free for all purposes without any express * guarantee it works. - * - * Tom St Denis, [email protected], http://libtom.org */ /* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b @@ -19,7 +17,7 @@ /** @file ltc_ecc_mul2add.c ECC Crypto, Shamir's Trick, Tom St Denis -*/ +*/ #ifdef LTC_MECC @@ -31,9 +29,9 @@ @param B Second point to multiply @param kB What to multiple B by @param C [out] Destination point (can overlap with A or B - @param modulus Modulus for curve + @param modulus Modulus for curve @return CRYPT_OK on success -*/ +*/ int ltc_ecc_mul2add(ecc_point *A, void *kA, ecc_point *B, void *kB, ecc_point *C, @@ -44,7 +42,7 @@ unsigned char *tA, *tB; int err, first; void *mp, *mu; - + /* argchks */ LTC_ARGCHK(A != NULL); LTC_ARGCHK(B != NULL); @@ -93,16 +91,16 @@ } } - /* init montgomery reduction */ - if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { + /* init montgomery reduction */ + if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto ERR_P; - } - if ((err = mp_init(&mu)) != CRYPT_OK) { + } + if ((err = mp_init(&mu)) != CRYPT_OK) { goto ERR_MP; - } - if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) { + } + if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) { goto ERR_MU; - } + } /* copy ones ... */ if ((err = mp_mulmod(A->x, mu, modulus, precomp[1]->x)) != CRYPT_OK) { goto ERR_MU; } @@ -126,7 +124,7 @@ for (y = 1; y < 4; y++) { if ((err = ltc_mp.ecc_ptadd(precomp[x], precomp[(y<<2)], precomp[x+(y<<2)], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } } - } + } nibble = 3; first = 1; @@ -134,20 +132,21 @@ bitbufB = tB[0]; /* for every byte of the multiplicands */ - for (x = -1;; ) { + for (x = 0;; ) { /* grab a nibble */ if (++nibble == 4) { - ++x; if (x == len) break; + if (x == len) break; bitbufA = tA[x]; bitbufB = tB[x]; nibble = 0; + ++x; } /* extract two bits from both, shift/update */ nA = (bitbufA >> 6) & 0x03; nB = (bitbufB >> 6) & 0x03; - bitbufA = (bitbufA << 2) & 0xFF; - bitbufB = (bitbufB << 2) & 0xFF; + bitbufA = (bitbufA << 2) & 0xFF; + bitbufB = (bitbufB << 2) & 0xFF; /* if both zero, if first, continue */ if ((nA == 0) && (nB == 0) && (first == 1)) { @@ -202,6 +201,6 @@ #endif #endif -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */