line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#define checkOpenSslCall( result ) if( ! ( result ) ) \ |
9
|
|
|
|
|
|
|
croak( "OpenSSL error: %s", ERR_reason_error_string( ERR_get_error() ) ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
typedef BIGNUM *Crypt__OpenSSL__Bignum; |
12
|
|
|
|
|
|
|
typedef BN_CTX *Crypt__OpenSSL__Bignum__CTX; |
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
|
|
|
SV* new_obj( void* obj ) |
15
|
|
|
|
|
|
|
{ |
16
|
8
|
|
|
|
|
|
SV * tmp = sv_newmortal(); |
17
|
8
|
|
|
|
|
|
sv_setref_pv(tmp, "Crypt::OpenSSL::Bignum", (void*)obj); |
18
|
8
|
|
|
|
|
|
return tmp; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
7
|
|
|
|
|
|
BIGNUM* sv2bn( SV* sv ) |
22
|
|
|
|
|
|
|
{ |
23
|
7
|
50
|
|
|
|
|
if (SvROK(sv) && sv_derived_from(sv, "Crypt::OpenSSL::Bignum")) { |
|
|
50
|
|
|
|
|
|
24
|
7
|
50
|
|
|
|
|
return INT2PTR(Crypt__OpenSSL__Bignum, SvIV((SV*)SvRV(sv))); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
else Perl_croak(aTHX_ "argument is not a Crypt::OpenSSL::Bignum object"); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
MODULE = Crypt::OpenSSL::Bignum PACKAGE = Crypt::OpenSSL::Bignum PREFIX = BN_ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
BOOT: |
32
|
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) |
33
|
|
|
|
|
|
|
OPENSSL_init_crypto(0, NULL); |
34
|
|
|
|
|
|
|
#else |
35
|
2
|
|
|
|
|
|
ERR_load_crypto_strings(); |
36
|
|
|
|
|
|
|
#endif |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
void |
39
|
|
|
|
|
|
|
DESTROY(Crypt::OpenSSL::Bignum self) |
40
|
|
|
|
|
|
|
CODE: |
41
|
43
|
|
|
|
|
|
BN_clear_free( self ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
44
|
|
|
|
|
|
|
new_from_word(CLASS, p_word) |
45
|
|
|
|
|
|
|
unsigned long p_word; |
46
|
|
|
|
|
|
|
PREINIT: |
47
|
|
|
|
|
|
|
BIGNUM* bn; |
48
|
|
|
|
|
|
|
CODE: |
49
|
10
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
50
|
10
|
50
|
|
|
|
|
checkOpenSslCall( BN_set_word( bn, p_word ) ); |
51
|
10
|
|
|
|
|
|
RETVAL = bn; |
52
|
|
|
|
|
|
|
OUTPUT: |
53
|
|
|
|
|
|
|
RETVAL |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
56
|
|
|
|
|
|
|
new_from_decimal(CLASS, p_dec_string) |
57
|
|
|
|
|
|
|
char* p_dec_string; |
58
|
|
|
|
|
|
|
PREINIT: |
59
|
|
|
|
|
|
|
BIGNUM* bn; |
60
|
|
|
|
|
|
|
CODE: |
61
|
5
|
|
|
|
|
|
bn = NULL; |
62
|
5
|
50
|
|
|
|
|
checkOpenSslCall( BN_dec2bn( &bn, p_dec_string ) ); |
63
|
5
|
|
|
|
|
|
RETVAL = bn; |
64
|
|
|
|
|
|
|
OUTPUT: |
65
|
|
|
|
|
|
|
RETVAL |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
68
|
|
|
|
|
|
|
new_from_hex(CLASS, p_hex_string) |
69
|
|
|
|
|
|
|
char* p_hex_string; |
70
|
|
|
|
|
|
|
PREINIT: |
71
|
|
|
|
|
|
|
BIGNUM* bn; |
72
|
|
|
|
|
|
|
CODE: |
73
|
1
|
|
|
|
|
|
bn = NULL; |
74
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_hex2bn( &bn, p_hex_string ) ); |
75
|
1
|
|
|
|
|
|
RETVAL = bn; |
76
|
|
|
|
|
|
|
OUTPUT: |
77
|
|
|
|
|
|
|
RETVAL |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
80
|
|
|
|
|
|
|
new_from_bin(CLASS, p_bin_string_SV) |
81
|
|
|
|
|
|
|
SV* p_bin_string_SV; |
82
|
|
|
|
|
|
|
PREINIT: |
83
|
|
|
|
|
|
|
BIGNUM* bn; |
84
|
|
|
|
|
|
|
unsigned char* bin; |
85
|
|
|
|
|
|
|
STRLEN bin_length; |
86
|
|
|
|
|
|
|
CODE: |
87
|
2
|
50
|
|
|
|
|
bin = (unsigned char*) SvPV( p_bin_string_SV, bin_length ); |
88
|
2
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_bin2bn( bin, bin_length, NULL ) ); |
89
|
2
|
|
|
|
|
|
RETVAL = bn; |
90
|
|
|
|
|
|
|
OUTPUT: |
91
|
|
|
|
|
|
|
RETVAL |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
94
|
|
|
|
|
|
|
BN_new(CLASS) |
95
|
|
|
|
|
|
|
PREINIT: |
96
|
|
|
|
|
|
|
BIGNUM* bn; |
97
|
|
|
|
|
|
|
CODE: |
98
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
99
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_set_word( bn, 0 ) ); |
100
|
1
|
|
|
|
|
|
RETVAL = bn; |
101
|
|
|
|
|
|
|
OUTPUT: |
102
|
|
|
|
|
|
|
RETVAL |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
105
|
|
|
|
|
|
|
BN_zero(CLASS) |
106
|
|
|
|
|
|
|
PREINIT: |
107
|
|
|
|
|
|
|
BIGNUM *bn; |
108
|
|
|
|
|
|
|
CODE: |
109
|
2
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
110
|
2
|
50
|
|
|
|
|
checkOpenSslCall( BN_set_word( bn, 0 ) ); |
111
|
2
|
|
|
|
|
|
RETVAL = bn; |
112
|
|
|
|
|
|
|
OUTPUT: |
113
|
|
|
|
|
|
|
RETVAL |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
116
|
|
|
|
|
|
|
BN_one(CLASS) |
117
|
|
|
|
|
|
|
PREINIT: |
118
|
|
|
|
|
|
|
BIGNUM *bn; |
119
|
|
|
|
|
|
|
CODE: |
120
|
2
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
121
|
2
|
50
|
|
|
|
|
checkOpenSslCall( BN_one( bn ) ); |
122
|
2
|
|
|
|
|
|
RETVAL = bn; |
123
|
|
|
|
|
|
|
OUTPUT: |
124
|
|
|
|
|
|
|
RETVAL |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
127
|
|
|
|
|
|
|
BN_rand(CLASS, int bits, int top, int bottom) |
128
|
|
|
|
|
|
|
PREINIT: |
129
|
|
|
|
|
|
|
BIGNUM* bn; |
130
|
|
|
|
|
|
|
CODE: |
131
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
132
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_rand( bn, bits, top, bottom) ); |
133
|
1
|
|
|
|
|
|
RETVAL = bn; |
134
|
|
|
|
|
|
|
OUTPUT: |
135
|
|
|
|
|
|
|
RETVAL |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
138
|
|
|
|
|
|
|
BN_pseudo_rand(CLASS, int bits, int top, int bottom) |
139
|
|
|
|
|
|
|
PREINIT: |
140
|
|
|
|
|
|
|
BIGNUM* bn; |
141
|
|
|
|
|
|
|
CODE: |
142
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
143
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_pseudo_rand( bn, bits, top, bottom) ); |
144
|
1
|
|
|
|
|
|
RETVAL = bn; |
145
|
|
|
|
|
|
|
OUTPUT: |
146
|
|
|
|
|
|
|
RETVAL |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
149
|
|
|
|
|
|
|
BN_rand_range(CLASS, Crypt::OpenSSL::Bignum r) |
150
|
|
|
|
|
|
|
PREINIT: |
151
|
|
|
|
|
|
|
BIGNUM* bn; |
152
|
|
|
|
|
|
|
CODE: |
153
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
154
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_rand_range( bn, r) ); |
155
|
1
|
|
|
|
|
|
RETVAL = bn; |
156
|
|
|
|
|
|
|
OUTPUT: |
157
|
|
|
|
|
|
|
RETVAL |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
void |
160
|
|
|
|
|
|
|
BN_bless_pointer(CLASS, void *pointer) |
161
|
|
|
|
|
|
|
PPCODE: |
162
|
1
|
|
|
|
|
|
ST(0) = new_obj(pointer); |
163
|
1
|
|
|
|
|
|
XSRETURN(1); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
char* |
166
|
|
|
|
|
|
|
BN_to_decimal(Crypt::OpenSSL::Bignum self) |
167
|
|
|
|
|
|
|
CODE: |
168
|
9
|
50
|
|
|
|
|
checkOpenSslCall( RETVAL = BN_bn2dec( self ) ); |
169
|
|
|
|
|
|
|
OUTPUT: |
170
|
|
|
|
|
|
|
RETVAL |
171
|
|
|
|
|
|
|
CLEANUP: |
172
|
9
|
|
|
|
|
|
OPENSSL_free( RETVAL ); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
char* |
175
|
|
|
|
|
|
|
BN_to_hex(Crypt::OpenSSL::Bignum self) |
176
|
|
|
|
|
|
|
CODE: |
177
|
1
|
50
|
|
|
|
|
checkOpenSslCall( RETVAL = BN_bn2hex( self ) ); |
178
|
|
|
|
|
|
|
OUTPUT: |
179
|
|
|
|
|
|
|
RETVAL |
180
|
|
|
|
|
|
|
CLEANUP: |
181
|
1
|
|
|
|
|
|
OPENSSL_free( RETVAL ); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
SV* |
184
|
|
|
|
|
|
|
BN_to_bin(Crypt::OpenSSL::Bignum self) |
185
|
|
|
|
|
|
|
PREINIT: |
186
|
|
|
|
|
|
|
unsigned char* bin; |
187
|
|
|
|
|
|
|
int length; |
188
|
|
|
|
|
|
|
CODE: |
189
|
3
|
|
|
|
|
|
length = BN_num_bytes( self ); |
190
|
3
|
50
|
|
|
|
|
if (length>0) { |
191
|
3
|
|
|
|
|
|
RETVAL = NEWSV(0, length); |
192
|
3
|
|
|
|
|
|
SvPOK_only(RETVAL); |
193
|
3
|
|
|
|
|
|
SvCUR_set(RETVAL, length); |
194
|
3
|
50
|
|
|
|
|
bin = (unsigned char *)SvPV_nolen(RETVAL); |
195
|
3
|
|
|
|
|
|
BN_bn2bin( self, bin ); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
else { |
198
|
0
|
|
|
|
|
|
RETVAL = newSVpvn("", 0); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
OUTPUT: |
201
|
|
|
|
|
|
|
RETVAL |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
unsigned long |
204
|
|
|
|
|
|
|
BN_get_word(Crypt::OpenSSL::Bignum self) |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
int |
207
|
|
|
|
|
|
|
BN_is_zero(Crypt::OpenSSL::Bignum self) |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
int |
210
|
|
|
|
|
|
|
BN_is_one(Crypt::OpenSSL::Bignum self) |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
int |
213
|
|
|
|
|
|
|
BN_is_odd(Crypt::OpenSSL::Bignum self) |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
void |
216
|
|
|
|
|
|
|
BN_add(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum b, ...) |
217
|
|
|
|
|
|
|
PREINIT: |
218
|
|
|
|
|
|
|
BIGNUM *bn; |
219
|
|
|
|
|
|
|
PPCODE: |
220
|
2
|
50
|
|
|
|
|
if( items > 3 ) |
221
|
0
|
|
|
|
|
|
croak( "usage: $bn->add( $bn2[, $target] )" ); |
222
|
2
|
100
|
|
|
|
|
bn = ( items < 3 ) ? BN_new() : sv2bn( ST(2) ); |
223
|
2
|
50
|
|
|
|
|
checkOpenSslCall( BN_add( bn, self, b ) ); |
224
|
2
|
100
|
|
|
|
|
ST(0) = ( (items < 3 ) ? new_obj( bn ) : ST(2) ); |
225
|
2
|
|
|
|
|
|
XSRETURN(1); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
void |
228
|
|
|
|
|
|
|
BN_sub(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum b, ...) |
229
|
|
|
|
|
|
|
PREINIT: |
230
|
|
|
|
|
|
|
BIGNUM *bn; |
231
|
|
|
|
|
|
|
PPCODE: |
232
|
2
|
50
|
|
|
|
|
if( items > 3 ) |
233
|
0
|
|
|
|
|
|
croak( "usage: $bn->sub( $bn2[, $target] )" ); |
234
|
2
|
100
|
|
|
|
|
bn = ( items < 3 ) ? BN_new() : sv2bn( ST(2) ); |
235
|
2
|
50
|
|
|
|
|
checkOpenSslCall( BN_sub( bn, self, b ) ); |
236
|
2
|
100
|
|
|
|
|
ST(0) = ( (items < 3 ) ? new_obj( bn ) : ST(2) ); |
237
|
2
|
|
|
|
|
|
XSRETURN(1); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
void |
240
|
|
|
|
|
|
|
BN_mul(self, b, ctx, ...) |
241
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
242
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum b; |
243
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
244
|
|
|
|
|
|
|
PREINIT: |
245
|
|
|
|
|
|
|
BIGNUM* bn; |
246
|
|
|
|
|
|
|
PPCODE: |
247
|
2
|
50
|
|
|
|
|
if( items > 4 ) |
248
|
0
|
|
|
|
|
|
croak( "usage: $bn->mul( $bn2, $ctx, [, $target] )" ); |
249
|
2
|
100
|
|
|
|
|
bn = ( items < 4 ) ? BN_new() : sv2bn( ST(3) ); |
250
|
2
|
50
|
|
|
|
|
checkOpenSslCall( BN_mul( bn, self, b, ctx ) ); |
251
|
2
|
100
|
|
|
|
|
ST(0) = ( (items < 4 ) ? new_obj( bn ) : ST(3) ); |
252
|
2
|
|
|
|
|
|
XSRETURN(1); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
void |
255
|
|
|
|
|
|
|
BN_div(self, b, ctx, ...) |
256
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
257
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum b; |
258
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
259
|
|
|
|
|
|
|
PREINIT: |
260
|
|
|
|
|
|
|
BIGNUM* quotient; |
261
|
|
|
|
|
|
|
BIGNUM* remainder; |
262
|
|
|
|
|
|
|
PPCODE: |
263
|
3
|
50
|
|
|
|
|
if( items > 5 ) |
264
|
0
|
|
|
|
|
|
croak( "usage: $bn->div( $bn2, $ctx, [, $quotient [, $remainder ] ] )" ); |
265
|
3
|
100
|
|
|
|
|
quotient = ( items < 4 ) ? BN_new() : sv2bn( ST(3) ); |
266
|
3
|
100
|
|
|
|
|
remainder = ( items < 5 ) ? BN_new() : sv2bn( ST(4) ); |
267
|
3
|
50
|
|
|
|
|
checkOpenSslCall( BN_div( quotient, remainder, self, b, ctx ) ); |
268
|
3
|
100
|
|
|
|
|
ST(0) = ( (items < 4 ) ? new_obj( quotient ) : ST(3) ); |
269
|
3
|
100
|
|
|
|
|
ST(1) = ( (items < 5 ) ? new_obj( remainder ) : ST(4) ); |
270
|
3
|
|
|
|
|
|
XSRETURN(2); |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
273
|
|
|
|
|
|
|
BN_sqr(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum::CTX ctx) |
274
|
|
|
|
|
|
|
PREINIT: |
275
|
|
|
|
|
|
|
BIGNUM* bn; |
276
|
|
|
|
|
|
|
CODE: |
277
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
278
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_sqr( bn, self, ctx ) ); |
279
|
1
|
|
|
|
|
|
RETVAL = bn; |
280
|
|
|
|
|
|
|
OUTPUT: |
281
|
|
|
|
|
|
|
RETVAL |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
void |
284
|
|
|
|
|
|
|
BN_mod(self, b, ctx, ...) |
285
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
286
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum b; |
287
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
288
|
|
|
|
|
|
|
PREINIT: |
289
|
|
|
|
|
|
|
BIGNUM* bn; |
290
|
|
|
|
|
|
|
PPCODE: |
291
|
2
|
50
|
|
|
|
|
if( items > 4 ) |
292
|
0
|
|
|
|
|
|
croak( "usage: $bn->mod( $bn2, $ctx, [, $target] )" ); |
293
|
2
|
100
|
|
|
|
|
bn = ( items < 4 ) ? BN_new() : sv2bn( ST(3) ); |
294
|
2
|
50
|
|
|
|
|
checkOpenSslCall( BN_mod( bn, self, b, ctx ) ); |
295
|
2
|
100
|
|
|
|
|
ST(0) = ( (items < 4 ) ? new_obj( bn ) : ST(3) ); |
296
|
2
|
|
|
|
|
|
XSRETURN(1); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
299
|
|
|
|
|
|
|
BN_mod_mul(self, b, m, ctx) |
300
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
301
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum b; |
302
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum m; |
303
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
304
|
|
|
|
|
|
|
PREINIT: |
305
|
|
|
|
|
|
|
BIGNUM* bn; |
306
|
|
|
|
|
|
|
CODE: |
307
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
308
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_mod_mul( bn, self, b, m, ctx ) ); |
309
|
1
|
|
|
|
|
|
RETVAL = bn; |
310
|
|
|
|
|
|
|
OUTPUT: |
311
|
|
|
|
|
|
|
RETVAL |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
314
|
|
|
|
|
|
|
BN_exp(self, exp, ctx) |
315
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
316
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum exp; |
317
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
318
|
|
|
|
|
|
|
PREINIT: |
319
|
|
|
|
|
|
|
BIGNUM* bn; |
320
|
|
|
|
|
|
|
CODE: |
321
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
322
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_exp( bn, self, exp, ctx ) ); |
323
|
1
|
|
|
|
|
|
RETVAL = bn; |
324
|
|
|
|
|
|
|
OUTPUT: |
325
|
|
|
|
|
|
|
RETVAL |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
328
|
|
|
|
|
|
|
BN_mod_exp(self, exp, mod, ctx) |
329
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
330
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum exp; |
331
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum mod; |
332
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
333
|
|
|
|
|
|
|
PREINIT: |
334
|
|
|
|
|
|
|
BIGNUM* bn; |
335
|
|
|
|
|
|
|
CODE: |
336
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
337
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_mod_exp( bn, self, exp, mod, ctx ) ); |
338
|
1
|
|
|
|
|
|
RETVAL = bn; |
339
|
|
|
|
|
|
|
OUTPUT: |
340
|
|
|
|
|
|
|
RETVAL |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
343
|
|
|
|
|
|
|
BN_mod_inverse(self, n, ctx) |
344
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
345
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum n; |
346
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
347
|
|
|
|
|
|
|
PREINIT: |
348
|
|
|
|
|
|
|
BIGNUM* bn; |
349
|
|
|
|
|
|
|
CODE: |
350
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
351
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_mod_inverse( bn, self, n, ctx ) ); |
352
|
1
|
|
|
|
|
|
RETVAL = bn; |
353
|
|
|
|
|
|
|
OUTPUT: |
354
|
|
|
|
|
|
|
RETVAL |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
357
|
|
|
|
|
|
|
BN_gcd(self, b, ctx) |
358
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum self; |
359
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum b; |
360
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX ctx; |
361
|
|
|
|
|
|
|
PREINIT: |
362
|
|
|
|
|
|
|
BIGNUM* bn; |
363
|
|
|
|
|
|
|
CODE: |
364
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
365
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_gcd( bn, self, b, ctx ) ); |
366
|
1
|
|
|
|
|
|
RETVAL = bn; |
367
|
|
|
|
|
|
|
OUTPUT: |
368
|
|
|
|
|
|
|
RETVAL |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
int |
371
|
|
|
|
|
|
|
BN_equals(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum b) |
372
|
|
|
|
|
|
|
CODE: |
373
|
4
|
|
|
|
|
|
RETVAL = BN_cmp(self, b) == 0 ? 1 : 0; |
374
|
|
|
|
|
|
|
OUTPUT: |
375
|
|
|
|
|
|
|
RETVAL |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
int |
378
|
|
|
|
|
|
|
BN_cmp(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum b) |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
int |
381
|
|
|
|
|
|
|
BN_num_bits(Crypt::OpenSSL::Bignum self) |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
int |
384
|
|
|
|
|
|
|
BN_num_bytes(Crypt::OpenSSL::Bignum self) |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
387
|
|
|
|
|
|
|
BN_rshift(Crypt::OpenSSL::Bignum self, int n) |
388
|
|
|
|
|
|
|
PREINIT: |
389
|
|
|
|
|
|
|
BIGNUM* bn; |
390
|
|
|
|
|
|
|
CODE: |
391
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
392
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_rshift( bn, self, n ) ); |
393
|
1
|
|
|
|
|
|
RETVAL = bn; |
394
|
|
|
|
|
|
|
OUTPUT: |
395
|
|
|
|
|
|
|
RETVAL |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
398
|
|
|
|
|
|
|
BN_lshift(Crypt::OpenSSL::Bignum self, int n) |
399
|
|
|
|
|
|
|
PREINIT: |
400
|
|
|
|
|
|
|
BIGNUM* bn; |
401
|
|
|
|
|
|
|
CODE: |
402
|
1
|
50
|
|
|
|
|
checkOpenSslCall( bn = BN_new() ); |
403
|
1
|
50
|
|
|
|
|
checkOpenSslCall( BN_lshift( bn, self, n ) ); |
404
|
1
|
|
|
|
|
|
RETVAL = bn; |
405
|
|
|
|
|
|
|
OUTPUT: |
406
|
|
|
|
|
|
|
RETVAL |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
int |
409
|
|
|
|
|
|
|
BN_ucmp(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum b) |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
void |
412
|
|
|
|
|
|
|
BN_swap(Crypt::OpenSSL::Bignum self, Crypt::OpenSSL::Bignum b) |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum |
415
|
|
|
|
|
|
|
BN_copy(Crypt::OpenSSL::Bignum self) |
416
|
|
|
|
|
|
|
CODE: |
417
|
1
|
50
|
|
|
|
|
checkOpenSslCall( RETVAL = BN_dup(self) ); |
418
|
|
|
|
|
|
|
OUTPUT: |
419
|
|
|
|
|
|
|
RETVAL |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
IV |
422
|
|
|
|
|
|
|
BN_pointer_copy(Crypt::OpenSSL::Bignum self) |
423
|
|
|
|
|
|
|
CODE: |
424
|
1
|
50
|
|
|
|
|
checkOpenSslCall( RETVAL = PTR2IV(BN_dup(self)) ); |
425
|
|
|
|
|
|
|
OUTPUT: |
426
|
|
|
|
|
|
|
RETVAL |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
MODULE = Crypt::OpenSSL::Bignum PACKAGE = Crypt::OpenSSL::Bignum::CTX |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
Crypt::OpenSSL::Bignum::CTX |
431
|
|
|
|
|
|
|
new(CLASS) |
432
|
|
|
|
|
|
|
CODE: |
433
|
1
|
|
|
|
|
|
RETVAL = BN_CTX_new(); |
434
|
|
|
|
|
|
|
OUTPUT: |
435
|
|
|
|
|
|
|
RETVAL |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
void |
438
|
|
|
|
|
|
|
DESTROY(Crypt::OpenSSL::Bignum::CTX self) |
439
|
|
|
|
|
|
|
CODE: |
440
|
1
|
|
|
|
|
|
BN_CTX_free(self); |