Changeset 21422 for trunk/src/rsaenh/tomcrypt.h
- Timestamp:
- Aug 17, 2010, 11:51:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/rsaenh/tomcrypt.h
r21363 r21422 23 23 24 24 /* 25 * This file contains code from the LibTomCrypt cryptographic 25 * This file contains code from the LibTomCrypt cryptographic 26 26 * library written by Tom St Denis (tomstdenis@iahu.ca). LibTomCrypt 27 27 * is in the public domain. The code in this file is tailored to 28 28 * special requirements. Take a look at http://libtomcrypt.org for the 29 * original version. 29 * original version. 30 30 */ 31 31 … … 37 37 #include <stdlib.h> 38 38 #include <limits.h> 39 40 #if defined(__WIN32OS2__) && (__IBMC__ < 400) && (__IBMCPP__ < 360) && !defined(__WATCOMC__) && !defined(__EMX__) 41 42 /* provide a better 64-bit integer storage than double */ 43 typedef struct 44 { 45 int lo; 46 int hi; 47 } __long_long; 48 #define __int64 __long_long 49 50 #define XOR_int64(a, b) ((a).hi ^= (b).hi, (a).lo ^= (b).lo) 51 #define HI_int64(a) ((a).hi) 52 #define LO_int64(a) ((a).lo) 53 #define ASSIGN_int64(a, b) ((a).hi = 0, (a).lo = (int)(b)) 54 55 #else 56 57 #define XOR_int64(a, b) ((a) ^= (b)) 58 #define HI_int64(a) ((a) >> 32) 59 #define LO_int64(a) ((a) & 0xFFFFFFFFUL) 60 #define ASSIGN_int64(a, b) ((a) = (b)) 61 62 #endif 63 39 64 #include "basetsd.h" 40 65 … … 76 101 }; 77 102 103 #if defined(__WIN32OS2__) && (__IBMC__ < 400) && (__IBMCPP__ < 360) && !defined(__WATCOMC__) && !defined(__EMX__) 104 #define CONST64(a,b) { (b), (a) } 105 #else 78 106 #define CONST64(a,b) ((((ULONG64)(a)) << 32) | (b)) 107 #endif 79 108 typedef ULONG64 ulong64; 80 109 81 /* this is the "32-bit at least" data type 82 * Re-define it to suit your platform but it must be at least 32-bits 110 /* this is the "32-bit at least" data type 111 * Re-define it to suit your platform but it must be at least 32-bits 83 112 */ 84 113 typedef ULONG32 ulong32; … … 118 147 #define byte(x, n) (((x) >> (8 * (n))) & 255) 119 148 120 typedef struct tag_rc2_key { 121 unsigned xkey[64]; 149 typedef struct tag_rc2_key { 150 unsigned xkey[64]; 122 151 } rc2_key; 123 152 … … 182 211 * [any size beyond that is ok provided it doesn't overflow the data type] 183 212 */ 213 #if defined(__WIN32OS2__) && (__IBMC__ < 400) && (__IBMCPP__ < 360) && !defined(__WATCOMC__) && !defined(__EMX__) 214 typedef unsigned short mp_digit; 215 typedef unsigned long mp_word; 216 #define DIGIT_BIT 14 217 #else 184 218 typedef unsigned long mp_digit; 185 219 typedef ulong64 mp_word; 186 220 #define DIGIT_BIT 28 187 221 #endif 222 188 223 #define MP_DIGIT_BIT DIGIT_BIT 189 224 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) … … 217 252 /* #define MP_LOW_MEM */ 218 253 254 #if defined(__WIN32OS2__) && (__IBMC__ < 400) && (__IBMCPP__ < 360) && !defined(__WATCOMC__) && !defined(__EMX__) 255 #define MP_PREC 128 /* default digits of precision */ 256 #else 219 257 #define MP_PREC 64 /* default digits of precision */ 258 #endif 220 259 221 260 /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */ … … 497 536 498 537 /* This gives [for a given bit size] the number of trials required 499 * such that Miller-Rabin gives a prob of failure lower than 2^-96 538 * such that Miller-Rabin gives a prob of failure lower than 2^-96 500 539 */ 501 540 int mp_prime_rabin_miller_trials(int size); … … 518 557 519 558 /* makes a truly random prime of a given size (bytes), 520 * call with bbs = 1 if you want it to be congruent to 3 mod 4 559 * call with bbs = 1 if you want it to be congruent to 3 mod 4 521 560 * 522 561 * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can … … 531 570 * 532 571 * Flags are as follows: 533 * 572 * 534 573 * LTM_PRIME_BBS - make prime congruent to 3 mod 4 535 574 * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
Note:
See TracChangeset
for help on using the changeset viewer.