comparison libtommath/tommath.h @ 511:582cb38e4eb5 insecure-nocrypto

propagate from branch 'au.asn.ucc.matt.dropbear' (head cdcc3c729e29544e8b98a408e2dc60e4483dfd2a) to branch 'au.asn.ucc.matt.dropbear.insecure-nocrypto' (head 0ca38a1cf349f7426ac9de34ebe4c3e3735effab)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 06 Nov 2008 13:16:55 +0000
parents 5ff8218bcee9
children 60fc6476e044
comparison
equal deleted inserted replaced
361:461c4b1fb35f 511:582cb38e4eb5
8 * additional optimizations in place. 8 * additional optimizations in place.
9 * 9 *
10 * The library is free for all purposes without any express 10 * The library is free for all purposes without any express
11 * guarantee it works. 11 * guarantee it works.
12 * 12 *
13 * Tom St Denis, [email protected], http://math.libtomcrypt.org 13 * Tom St Denis, [email protected], http://math.libtomcrypt.com
14 */ 14 */
15 #ifndef BN_H_ 15 #ifndef BN_H_
16 #define BN_H_ 16 #define BN_H_
17 17
18 #include <stdio.h> 18 #include <stdio.h>
19 #include <string.h> 19 #include <string.h>
20 #include <stdlib.h> 20 #include <stdlib.h>
21 #include <ctype.h> 21 #include <ctype.h>
22 #include <limits.h> 22 #include <limits.h>
23 23
24 #include <tommath_class.h> 24 #include "tommath_class.h"
25 25
26 #undef MIN 26 #ifndef MIN
27 #define MIN(x,y) ((x)<(y)?(x):(y)) 27 #define MIN(x,y) ((x)<(y)?(x):(y))
28 #undef MAX 28 #endif
29 #define MAX(x,y) ((x)>(y)?(x):(y)) 29
30 #ifndef MAX
31 #define MAX(x,y) ((x)>(y)?(x):(y))
32 #endif
30 33
31 #ifdef __cplusplus 34 #ifdef __cplusplus
32 extern "C" { 35 extern "C" {
33 36
34 /* C++ compilers don't like assigning void * to mp_digit * */ 37 /* C++ compilers don't like assigning void * to mp_digit * */
110 #define XREALLOC realloc 113 #define XREALLOC realloc
111 #define XCALLOC calloc 114 #define XCALLOC calloc
112 #else 115 #else
113 /* prototypes for our heap functions */ 116 /* prototypes for our heap functions */
114 extern void *XMALLOC(size_t n); 117 extern void *XMALLOC(size_t n);
115 extern void *REALLOC(void *p, size_t n); 118 extern void *XREALLOC(void *p, size_t n);
116 extern void *XCALLOC(size_t n, size_t s); 119 extern void *XCALLOC(size_t n, size_t s);
117 extern void XFREE(void *p); 120 extern void XFREE(void *p);
118 #endif 121 #endif
119 #endif 122 #endif
120 123
145 #define MP_NO 0 /* no response */ 148 #define MP_NO 0 /* no response */
146 149
147 /* Primality generation flags */ 150 /* Primality generation flags */
148 #define LTM_PRIME_BBS 0x0001 /* BBS style prime */ 151 #define LTM_PRIME_BBS 0x0001 /* BBS style prime */
149 #define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */ 152 #define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
150 #define LTM_PRIME_2MSB_OFF 0x0004 /* force 2nd MSB to 0 */
151 #define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */ 153 #define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
152 154
153 typedef int mp_err; 155 typedef int mp_err;
154 156
155 /* you'll have to tune these... */ 157 /* you'll have to tune these... */
162 /* #define MP_LOW_MEM */ 164 /* #define MP_LOW_MEM */
163 165
164 /* default precision */ 166 /* default precision */
165 #ifndef MP_PREC 167 #ifndef MP_PREC
166 #ifndef MP_LOW_MEM 168 #ifndef MP_LOW_MEM
167 #define MP_PREC 64 /* default digits of precision */ 169 #define MP_PREC 32 /* default digits of precision */
168 #else 170 #else
169 #define MP_PREC 8 /* default digits of precision */ 171 #define MP_PREC 8 /* default digits of precision */
170 #endif 172 #endif
171 #endif 173 #endif
172 174
516 518
517 /* ---> radix conversion <--- */ 519 /* ---> radix conversion <--- */
518 int mp_count_bits(mp_int *a); 520 int mp_count_bits(mp_int *a);
519 521
520 int mp_unsigned_bin_size(mp_int *a); 522 int mp_unsigned_bin_size(mp_int *a);
521 int mp_read_unsigned_bin(mp_int *a, unsigned char *b, int c); 523 int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c);
522 int mp_to_unsigned_bin(mp_int *a, unsigned char *b); 524 int mp_to_unsigned_bin(mp_int *a, unsigned char *b);
523 int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); 525 int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
524 526
525 int mp_signed_bin_size(mp_int *a); 527 int mp_signed_bin_size(mp_int *a);
526 int mp_read_signed_bin(mp_int *a, unsigned char *b, int c); 528 int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c);
527 int mp_to_signed_bin(mp_int *a, unsigned char *b); 529 int mp_to_signed_bin(mp_int *a, unsigned char *b);
528 int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); 530 int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
529 531
530 int mp_read_radix(mp_int *a, const char *str, int radix); 532 int mp_read_radix(mp_int *a, const char *str, int radix);
531 int mp_toradix(mp_int *a, char *str, int radix); 533 int mp_toradix(mp_int *a, char *str, int radix);
532 int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen); 534 int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
574 } 576 }
575 #endif 577 #endif
576 578
577 #endif 579 #endif
578 580
581
582 /* $Source: /cvs/libtom/libtommath/tommath.h,v $ */
583 /* $Revision: 1.8 $ */
584 /* $Date: 2006/03/31 14:18:44 $ */