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