diff options
Diffstat (limited to 'src/lib/libcrypto/bn/bn_lcl.h')
-rw-r--r-- | src/lib/libcrypto/bn/bn_lcl.h | 107 |
1 files changed, 88 insertions, 19 deletions
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h index edfd788338..85a372695b 100644 --- a/src/lib/libcrypto/bn/bn_lcl.h +++ b/src/lib/libcrypto/bn/bn_lcl.h | |||
@@ -59,23 +59,79 @@ | |||
59 | #ifndef HEADER_BN_LCL_H | 59 | #ifndef HEADER_BN_LCL_H |
60 | #define HEADER_BN_LCL_H | 60 | #define HEADER_BN_LCL_H |
61 | 61 | ||
62 | #include "bn.h" | 62 | #include <openssl/bn.h> |
63 | 63 | ||
64 | #ifdef __cplusplus | 64 | #ifdef __cplusplus |
65 | extern "C" { | 65 | extern "C" { |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | /* Pentium pro 16,16,16,32,64 */ | ||
69 | /* Alpha 16,16,16,16.64 */ | ||
70 | #define BN_MULL_SIZE_NORMAL (16) /* 32 */ | ||
71 | #define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 less than */ | ||
72 | #define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */ | ||
73 | #define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ | ||
74 | #define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ | ||
75 | |||
76 | #if 0 | ||
77 | #ifndef BN_MUL_COMBA | ||
78 | /* #define bn_mul_comba8(r,a,b) bn_mul_normal(r,a,8,b,8) */ | ||
79 | /* #define bn_mul_comba4(r,a,b) bn_mul_normal(r,a,4,b,4) */ | ||
80 | #endif | ||
81 | |||
82 | #ifndef BN_SQR_COMBA | ||
83 | /* This is probably faster than using the C code - I need to check */ | ||
84 | #define bn_sqr_comba8(r,a) bn_mul_normal(r,a,8,a,8) | ||
85 | #define bn_sqr_comba4(r,a) bn_mul_normal(r,a,4,a,4) | ||
86 | #endif | ||
87 | #endif | ||
88 | |||
68 | /************************************************************* | 89 | /************************************************************* |
69 | * Using the long long type | 90 | * Using the long long type |
70 | */ | 91 | */ |
71 | #define Lw(t) (((BN_ULONG)(t))&BN_MASK2) | 92 | #define Lw(t) (((BN_ULONG)(t))&BN_MASK2) |
72 | #define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) | 93 | #define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) |
73 | 94 | ||
74 | #define bn_fix_top(a) \ | 95 | /* These are used for internal error checking and are not normally used */ |
75 | { \ | 96 | #ifdef BN_DEBUG |
76 | BN_ULONG *fix_top_l; \ | 97 | #define bn_check_top(a) \ |
77 | for (fix_top_l= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ | 98 | { if (((a)->top < 0) || ((a)->top > (a)->max)) \ |
78 | if (*(fix_top_l--)) break; \ | 99 | { char *nullp=NULL; *nullp='z'; } } |
100 | #define bn_check_num(a) if ((a) < 0) { char *nullp=NULL; *nullp='z'; } | ||
101 | #else | ||
102 | #define bn_check_top(a) | ||
103 | #define bn_check_num(a) | ||
104 | #endif | ||
105 | |||
106 | /* This macro is to add extra stuff for development checking */ | ||
107 | #ifdef BN_DEBUG | ||
108 | #define bn_set_max(r) ((r)->max=(r)->top,BN_set_flags((r),BN_FLG_STATIC_DATA)) | ||
109 | #else | ||
110 | #define bn_set_max(r) | ||
111 | #endif | ||
112 | |||
113 | /* These macros are used to 'take' a section of a bignum for read only use */ | ||
114 | #define bn_set_low(r,a,n) \ | ||
115 | { \ | ||
116 | (r)->top=((a)->top > (n))?(n):(a)->top; \ | ||
117 | (r)->d=(a)->d; \ | ||
118 | (r)->neg=(a)->neg; \ | ||
119 | (r)->flags|=BN_FLG_STATIC_DATA; \ | ||
120 | bn_set_max(r); \ | ||
121 | } | ||
122 | |||
123 | #define bn_set_high(r,a,n) \ | ||
124 | { \ | ||
125 | if ((a)->top > (n)) \ | ||
126 | { \ | ||
127 | (r)->top=(a)->top-n; \ | ||
128 | (r)->d= &((a)->d[n]); \ | ||
129 | } \ | ||
130 | else \ | ||
131 | (r)->top=0; \ | ||
132 | (r)->neg=(a)->neg; \ | ||
133 | (r)->flags|=BN_FLG_STATIC_DATA; \ | ||
134 | bn_set_max(r); \ | ||
79 | } | 135 | } |
80 | 136 | ||
81 | /* #define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?(n):bn_expand2((n),(b))) */ | 137 | /* #define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?(n):bn_expand2((n),(b))) */ |
@@ -175,22 +231,35 @@ extern "C" { | |||
175 | 231 | ||
176 | #endif | 232 | #endif |
177 | 233 | ||
178 | #ifndef NOPROTO | 234 | OPENSSL_EXTERN int bn_limit_bits; |
235 | OPENSSL_EXTERN int bn_limit_num; /* (1<<bn_limit_bits) */ | ||
236 | /* Recursive 'low' limit */ | ||
237 | OPENSSL_EXTERN int bn_limit_bits_low; | ||
238 | OPENSSL_EXTERN int bn_limit_num_low; /* (1<<bn_limit_bits_low) */ | ||
239 | /* Do modified 'high' part calculation' */ | ||
240 | OPENSSL_EXTERN int bn_limit_bits_high; | ||
241 | OPENSSL_EXTERN int bn_limit_num_high; /* (1<<bn_limit_bits_high) */ | ||
242 | OPENSSL_EXTERN int bn_limit_bits_mont; | ||
243 | OPENSSL_EXTERN int bn_limit_num_mont; /* (1<<bn_limit_bits_mont) */ | ||
179 | 244 | ||
180 | BIGNUM *bn_expand2(BIGNUM *b, int bits); | 245 | BIGNUM *bn_expand2(BIGNUM *b, int bits); |
181 | 246 | ||
182 | #ifdef X86_ASM | 247 | void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb); |
183 | void bn_add_words(BN_ULONG *r,BN_ULONG *a,int num); | 248 | void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); |
184 | #endif | 249 | void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); |
185 | 250 | void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp); | |
186 | #else | 251 | void bn_sqr_comba8(BN_ULONG *r,BN_ULONG *a); |
187 | 252 | void bn_sqr_comba4(BN_ULONG *r,BN_ULONG *a); | |
188 | BIGNUM *bn_expand2(); | 253 | int bn_cmp_words(BN_ULONG *a,BN_ULONG *b,int n); |
189 | #ifdef X86_ASM | 254 | void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t); |
190 | BN_ULONG bn_add_words(); | 255 | void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, |
191 | #endif | 256 | int tn, int n,BN_ULONG *t); |
192 | 257 | void bn_sqr_recursive(BN_ULONG *r,BN_ULONG *a, int n2, BN_ULONG *t); | |
193 | #endif | 258 | void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n); |
259 | void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2, | ||
260 | BN_ULONG *t); | ||
261 | void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2, | ||
262 | BN_ULONG *t); | ||
194 | 263 | ||
195 | #ifdef __cplusplus | 264 | #ifdef __cplusplus |
196 | } | 265 | } |