1*d3273b5bSchristos /* $NetBSD: bn_reverse.c,v 1.2 2017/01/28 21:31:47 christos Exp $ */ 2ca1c9b0cSelric 3ca1c9b0cSelric #include <tommath.h> 4ca1c9b0cSelric #ifdef BN_REVERSE_C 5ca1c9b0cSelric /* LibTomMath, multiple-precision integer library -- Tom St Denis 6ca1c9b0cSelric * 7ca1c9b0cSelric * LibTomMath is a library that provides multiple-precision 8ca1c9b0cSelric * integer arithmetic as well as number theoretic functionality. 9ca1c9b0cSelric * 10ca1c9b0cSelric * The library was designed directly after the MPI library by 11ca1c9b0cSelric * Michael Fromberger but has been written from scratch with 12ca1c9b0cSelric * additional optimizations in place. 13ca1c9b0cSelric * 14ca1c9b0cSelric * The library is free for all purposes without any express 15ca1c9b0cSelric * guarantee it works. 16ca1c9b0cSelric * 17ca1c9b0cSelric * Tom St Denis, tomstdenis@gmail.com, http://libtom.org 18ca1c9b0cSelric */ 19ca1c9b0cSelric 20ca1c9b0cSelric /* reverse an array, used for radix code */ 21ca1c9b0cSelric void bn_reverse(unsigned char * s,int len)22ca1c9b0cSelricbn_reverse (unsigned char *s, int len) 23ca1c9b0cSelric { 24ca1c9b0cSelric int ix, iy; 25ca1c9b0cSelric unsigned char t; 26ca1c9b0cSelric 27ca1c9b0cSelric ix = 0; 28ca1c9b0cSelric iy = len - 1; 29ca1c9b0cSelric while (ix < iy) { 30ca1c9b0cSelric t = s[ix]; 31ca1c9b0cSelric s[ix] = s[iy]; 32ca1c9b0cSelric s[iy] = t; 33ca1c9b0cSelric ++ix; 34ca1c9b0cSelric --iy; 35ca1c9b0cSelric } 36ca1c9b0cSelric } 37ca1c9b0cSelric #endif 38ca1c9b0cSelric 39ca1c9b0cSelric /* Source: /cvs/libtom/libtommath/bn_reverse.c,v */ 40ca1c9b0cSelric /* Revision: 1.4 */ 41ca1c9b0cSelric /* Date: 2006/12/28 01:25:13 */ 42