comparison libtommath/bn_fast_s_mp_sqr.c @ 1436:60fc6476e044

Update to libtommath v1.0
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 22:37:14 +0800
parents 5ff8218bcee9
children 8bba51a55704
comparison
equal deleted inserted replaced
1435:f849a5ca2efc 1436:60fc6476e044
1 #include <tommath.h> 1 #include <tommath_private.h>
2 #ifdef BN_FAST_S_MP_SQR_C 2 #ifdef BN_FAST_S_MP_SQR_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 * 4 *
5 * LibTomMath is a library that provides multiple-precision 5 * LibTomMath is a library that provides multiple-precision
6 * integer arithmetic as well as number theoretic functionality. 6 * integer arithmetic as well as number theoretic functionality.
10 * additional optimizations in place. 10 * additional optimizations in place.
11 * 11 *
12 * The library is free for all purposes without any express 12 * The library is free for all purposes without any express
13 * guarantee it works. 13 * guarantee it works.
14 * 14 *
15 * Tom St Denis, [email protected], http://math.libtomcrypt.com 15 * Tom St Denis, [email protected], http://libtom.org
16 */ 16 */
17 17
18 /* the jist of squaring... 18 /* the jist of squaring...
19 * you do like mult except the offset of the tmpx [one that 19 * you do like mult except the offset of the tmpx [one that
20 * starts closer to zero] can't equal the offset of tmpy. 20 * starts closer to zero] can't equal the offset of tmpy.
64 64
65 /* now for squaring tx can never equal ty 65 /* now for squaring tx can never equal ty
66 * we halve the distance since they approach at a rate of 2x 66 * we halve the distance since they approach at a rate of 2x
67 * and we have to round because odd cases need to be executed 67 * and we have to round because odd cases need to be executed
68 */ 68 */
69 iy = MIN(iy, (ty-tx+1)>>1); 69 iy = MIN(iy, ((ty-tx)+1)>>1);
70 70
71 /* execute loop */ 71 /* execute loop */
72 for (iz = 0; iz < iy; iz++) { 72 for (iz = 0; iz < iy; iz++) {
73 _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); 73 _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
74 } 74 }
107 mp_clamp (b); 107 mp_clamp (b);
108 return MP_OKAY; 108 return MP_OKAY;
109 } 109 }
110 #endif 110 #endif
111 111
112 /* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */ 112 /* $Source$ */
113 /* $Revision: 1.3 $ */ 113 /* $Revision$ */
114 /* $Date: 2006/03/31 14:18:44 $ */ 114 /* $Date$ */