Update upstream source from tag 'upstream/0.064'
Update to upstream version '0.064'
with Debian dir 37fbee5058e1bbc46d6d5ac05b8ca2fffb4bd405
gregor herrmann
4 years ago
0 | 0 | Changes for CryptX |
1 | ||
2 | 0.064 2019-06-14 | |
3 | - fix #50 libtommath patch - building on HP-UX 11.11 / PA-RISC | |
4 | - necessary XS adaptation to the latest libtommath | |
5 | - bundled libtomcrypt update branch:develop (commit:c600d81e 2019-06-09) | |
1 | 6 | |
2 | 7 | 0.063 2018-11-28 |
3 | 8 | - proper patch for #46 (related to Math::BigInt::LTM) |
402 | 402 | mp_int mpi; |
403 | 403 | |
404 | 404 | if (in == NULL) XSRETURN_UNDEF; |
405 | if (mp_init(&mpi) != CRYPT_OK) XSRETURN_UNDEF; | |
405 | if (mp_init(&mpi) != MP_OKAY) XSRETURN_UNDEF; | |
406 | 406 | if (strlen(in) == 0) { |
407 | 407 | RETVAL = newSVpvn("", 0); |
408 | 408 | } |
416 | 416 | SvPOK_only(RETVAL); |
417 | 417 | SvCUR_set(RETVAL, len); |
418 | 418 | out_data = (unsigned char *)SvPVX(RETVAL); |
419 | mp_to_unsigned_bin(&mpi, out_data); | |
419 | if (mp_to_unsigned_bin(&mpi, out_data) != MP_OKAY) { | |
420 | SvREFCNT_dec(RETVAL); | |
421 | RETVAL = newSVpvn(NULL, 0); /* undef */ | |
422 | } | |
420 | 423 | } |
421 | 424 | } |
422 | 425 | else { |
436 | 439 | char *out_data; |
437 | 440 | mp_int mpi, tmp; |
438 | 441 | mp_digit d; |
442 | mp_err merr; | |
439 | 443 | int digits = 0; |
440 | 444 | |
441 | 445 | if (!SvPOK(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
442 | 446 | in_data = (unsigned char *) SvPVbyte(in, len); |
443 | mp_init_multi(&mpi, &tmp, NULL); | |
447 | if (mp_init_multi(&mpi, &tmp, NULL) != MP_OKAY) XSRETURN_UNDEF; | |
444 | 448 | if (len == 0) { |
445 | 449 | RETVAL = newSVpvn("", 0); |
446 | 450 | } |
447 | 451 | else { |
448 | 452 | if (mp_read_unsigned_bin(&mpi, in_data, (unsigned long)len) == CRYPT_OK) { |
449 | mp_copy(&mpi, &tmp); | |
450 | while (mp_iszero(&tmp) == MP_NO) { | |
451 | mp_div_d(&tmp, (mp_digit)radix, &tmp, &d); | |
453 | merr = mp_copy(&mpi, &tmp); | |
454 | while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { | |
455 | merr = mp_div_d(&tmp, (mp_digit)radix, &tmp, &d); | |
452 | 456 | digits++; |
453 | 457 | } |
454 | if (digits == 0) { | |
458 | if (merr != MP_OKAY) { | |
459 | RETVAL = newSVpvn(NULL, 0); /* undef */ | |
460 | } | |
461 | else if (digits == 0) { | |
455 | 462 | RETVAL = newSVpvn("", 0); |
456 | 463 | } |
457 | 464 | else { |
458 | 465 | RETVAL = NEWSV(0, digits + 2); /* +2 for sign and NUL byte */ |
459 | 466 | SvPOK_only(RETVAL); |
460 | 467 | out_data = SvPVX(RETVAL); |
461 | mp_toradix(&mpi, out_data, radix); | |
462 | SvCUR_set(RETVAL, strlen(out_data)); | |
468 | if (mp_toradix(&mpi, out_data, radix) == MP_OKAY) { | |
469 | SvCUR_set(RETVAL, strlen(out_data)); | |
470 | } | |
471 | else { | |
472 | SvREFCNT_dec(RETVAL); | |
473 | RETVAL = newSVpvn(NULL, 0); /* undef */ | |
474 | } | |
463 | 475 | } |
464 | 476 | } |
465 | 477 | else { |
456 | 456 | src/ltc/pk/asn1/oid/pk_oid_cmp.c |
457 | 457 | src/ltc/pk/asn1/oid/pk_oid_str.c |
458 | 458 | src/ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.c |
459 | src/ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.c | |
459 | 460 | src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c |
460 | 461 | src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c |
461 | 462 | src/ltc/pk/dh/dh.c |
615 | 616 | src/ltm/bn_mp_fread.c |
616 | 617 | src/ltm/bn_mp_fwrite.c |
617 | 618 | src/ltm/bn_mp_gcd.c |
619 | src/ltm/bn_mp_get_bit.c | |
618 | 620 | src/ltm/bn_mp_get_int.c |
619 | 621 | src/ltm/bn_mp_get_long.c |
620 | 622 | src/ltm/bn_mp_grow.c |
631 | 633 | src/ltm/bn_mp_jacobi.c |
632 | 634 | src/ltm/bn_mp_karatsuba_mul.c |
633 | 635 | src/ltm/bn_mp_karatsuba_sqr.c |
636 | src/ltm/bn_mp_kronecker.c | |
634 | 637 | src/ltm/bn_mp_lcm.c |
635 | 638 | src/ltm/bn_mp_lshd.c |
636 | 639 | src/ltm/bn_mp_mod.c |
649 | 652 | src/ltm/bn_mp_neg.c |
650 | 653 | src/ltm/bn_mp_or.c |
651 | 654 | src/ltm/bn_mp_prime_fermat.c |
655 | src/ltm/bn_mp_prime_frobenius_underwood.c | |
652 | 656 | src/ltm/bn_mp_prime_is_divisible.c |
653 | 657 | src/ltm/bn_mp_prime_is_prime.c |
654 | 658 | src/ltm/bn_mp_prime_miller_rabin.c |
655 | 659 | src/ltm/bn_mp_prime_next_prime.c |
656 | 660 | src/ltm/bn_mp_prime_rabin_miller_trials.c |
657 | 661 | src/ltm/bn_mp_prime_random_ex.c |
662 | src/ltm/bn_mp_prime_strong_lucas_selfridge.c | |
658 | 663 | src/ltm/bn_mp_radix_size.c |
659 | 664 | src/ltm/bn_mp_radix_smap.c |
660 | 665 | src/ltm/bn_mp_rand.c |
44 | 44 | "url" : "https://github.com/DCIT/perl-CryptX" |
45 | 45 | } |
46 | 46 | }, |
47 | "version" : "0.063", | |
47 | "version" : "0.064", | |
48 | 48 | "x_serialization_backend" : "JSON::PP version 2.94" |
49 | 49 | } |
21 | 21 | resources: |
22 | 22 | bugtracker: https://github.com/DCIT/perl-CryptX/issues |
23 | 23 | repository: https://github.com/DCIT/perl-CryptX |
24 | version: '0.063' | |
24 | version: '0.064' | |
25 | 25 | x_serialization_backend: 'CPAN::Meta::YAML version 0.018' |
6 | 6 | |
7 | 7 | Math::BigInt::LTM |
8 | 8 | _new(Class, SV *x) |
9 | CODE: | |
10 | Newz(0, RETVAL, 1, mp_int); | |
11 | mp_init(RETVAL); | |
9 | PREINIT: | |
10 | mp_err merr; | |
11 | CODE: | |
12 | Newz(0, RETVAL, 1, mp_int); | |
13 | merr = mp_init(RETVAL); | |
14 | #ifdef BN_MP_SET_INT_C | |
12 | 15 | if ((SvUOK(x) || SvIOK(x)) && (sizeof(UV) <= sizeof(unsigned long) || SvUV(x) == (unsigned long)SvUV(x))) { |
13 | 16 | mp_set_int(RETVAL, (unsigned long)SvUV(x)); |
14 | 17 | } |
15 | else { | |
16 | mp_read_radix(RETVAL, SvPV_nolen(x), 10); | |
17 | } | |
18 | #elif IVSIZE == 8 | |
19 | if (SvUOK(x)) { | |
20 | mp_set_u64(RETVAL, (unsigned long long)SvUV(x)); | |
21 | } | |
22 | else if (SvIOK(x)) { | |
23 | mp_set_i64(RETVAL, (long long)SvIV(x)); | |
24 | } | |
25 | #else | |
26 | if (SvUOK(x)) { | |
27 | mp_set_u32(RETVAL, (unsigned int)SvUV(x)); | |
28 | } | |
29 | else if (SvIOK(x)) { | |
30 | mp_set_i32(RETVAL, (int)SvIV(x)); | |
31 | } | |
32 | #endif | |
33 | else { | |
34 | /* fallback - read the decimal number from string */ | |
35 | merr = mp_read_radix(RETVAL, SvPV_nolen(x), 10); | |
36 | } | |
37 | PERL_UNUSED_VAR(merr); | |
18 | 38 | OUTPUT: |
19 | 39 | RETVAL |
20 | 40 | |
24 | 44 | Math::BigInt::LTM |
25 | 45 | _from_bin(Class, SV *x) |
26 | 46 | PREINIT: |
47 | mp_err merr; | |
27 | 48 | char *str, *start; |
28 | 49 | CODE: |
29 | 50 | Newz(0, RETVAL, 1, mp_int); |
30 | mp_init(RETVAL); | |
51 | merr = mp_init(RETVAL); | |
31 | 52 | str = SvPV_nolen(x); |
32 | 53 | start = (strlen(str)>2 && str[0] == '0' && str[1] == 'b') ? str+2 : str; |
33 | mp_read_radix(RETVAL, start, 2); | |
54 | merr = mp_read_radix(RETVAL, start, 2); | |
55 | PERL_UNUSED_VAR(merr); | |
34 | 56 | OUTPUT: |
35 | 57 | RETVAL |
36 | 58 | |
40 | 62 | Math::BigInt::LTM |
41 | 63 | _from_hex(Class, SV *x) |
42 | 64 | PREINIT: |
65 | mp_err merr; | |
43 | 66 | char *str, *start; |
44 | 67 | CODE: |
45 | 68 | Newz(0, RETVAL, 1, mp_int); |
46 | mp_init(RETVAL); | |
69 | merr = mp_init(RETVAL); | |
47 | 70 | str = SvPV_nolen(x); |
48 | 71 | start = (strlen(str)>2 && str[0] == '0' && str[1] == 'x') ? str+2 : str; |
49 | mp_read_radix(RETVAL, start, 16); | |
72 | merr = mp_read_radix(RETVAL, start, 16); | |
73 | PERL_UNUSED_VAR(merr); | |
50 | 74 | OUTPUT: |
51 | 75 | RETVAL |
52 | 76 | |
55 | 79 | |
56 | 80 | Math::BigInt::LTM |
57 | 81 | _from_oct(Class, SV *x) |
58 | CODE: | |
59 | Newz(0, RETVAL, 1, mp_int); | |
60 | mp_init(RETVAL); | |
61 | mp_read_radix(RETVAL, SvPV_nolen(x), 8); | |
82 | PREINIT: | |
83 | mp_err merr; | |
84 | CODE: | |
85 | Newz(0, RETVAL, 1, mp_int); | |
86 | merr = mp_init(RETVAL); | |
87 | merr = mp_read_radix(RETVAL, SvPV_nolen(x), 8); | |
88 | PERL_UNUSED_VAR(merr); | |
62 | 89 | OUTPUT: |
63 | 90 | RETVAL |
64 | 91 | |
67 | 94 | |
68 | 95 | Math::BigInt::LTM |
69 | 96 | _from_base(Class, SV *x, int base) |
70 | CODE: | |
71 | Newz(0, RETVAL, 1, mp_int); | |
72 | mp_init(RETVAL); | |
73 | mp_read_radix(RETVAL, SvPV_nolen(x), base); | |
97 | PREINIT: | |
98 | mp_err merr; | |
99 | CODE: | |
100 | Newz(0, RETVAL, 1, mp_int); | |
101 | merr = mp_init(RETVAL); | |
102 | merr = mp_read_radix(RETVAL, SvPV_nolen(x), base); | |
103 | PERL_UNUSED_VAR(merr); | |
74 | 104 | OUTPUT: |
75 | 105 | RETVAL |
76 | 106 | |
80 | 110 | Math::BigInt::LTM |
81 | 111 | _from_bytes(Class, SV *x) |
82 | 112 | PREINIT: |
113 | mp_err merr; | |
83 | 114 | STRLEN buf_len; |
84 | 115 | unsigned char *buf_ptr; |
85 | 116 | CODE: |
86 | 117 | Newz(0, RETVAL, 1, mp_int); |
87 | mp_init(RETVAL); | |
118 | merr = mp_init(RETVAL); | |
88 | 119 | buf_ptr = (unsigned char *)SvPVbyte(x, buf_len); |
89 | mp_read_unsigned_bin(RETVAL, buf_ptr, buf_len); | |
120 | merr = mp_read_unsigned_bin(RETVAL, buf_ptr, buf_len); | |
121 | PERL_UNUSED_VAR(merr); | |
90 | 122 | OUTPUT: |
91 | 123 | RETVAL |
92 | 124 | |
95 | 127 | |
96 | 128 | void |
97 | 129 | _set(Class, Math::BigInt::LTM n, SV *x) |
98 | CODE: | |
99 | mp_set_int(n, (unsigned long)SvIV(x)); | |
130 | PREINIT: | |
131 | mp_err merr; | |
132 | CODE: | |
133 | #ifdef BN_MP_SET_INT_C | |
134 | if ((SvUOK(x) || SvIOK(x)) && (sizeof(UV) <= sizeof(unsigned long) || SvUV(x) == (unsigned long)SvUV(x))) { | |
135 | mp_set_int(n, (unsigned long)SvIV(x)); | |
136 | } | |
137 | #elif IVSIZE == 8 | |
138 | if (SvUOK(x)) { | |
139 | mp_set_u64(n, (unsigned long long)SvUV(x)); | |
140 | } | |
141 | else if (SvIOK(x)) { | |
142 | mp_set_i64(n, (long long)SvIV(x)); | |
143 | } | |
144 | #else | |
145 | if (SvUOK(x)) { | |
146 | mp_set_u32(n, (unsigned int)SvUV(x)); | |
147 | } | |
148 | else if (SvIOK(x)) { | |
149 | mp_set_i32(n, (int)SvIV(x)); | |
150 | } | |
151 | #endif | |
152 | else { | |
153 | /* fallback - read the decimal number from string */ | |
154 | merr = mp_read_radix(n, SvPV_nolen(x), 10); | |
155 | PERL_UNUSED_VAR(merr); | |
156 | } | |
100 | 157 | |
101 | 158 | ############################################################################## |
102 | 159 | # _zero() |
103 | 160 | |
104 | 161 | Math::BigInt::LTM |
105 | 162 | _zero(Class) |
106 | CODE: | |
107 | Newz(0, RETVAL, 1, mp_int); | |
108 | mp_init(RETVAL); | |
109 | mp_set_int(RETVAL, 0); | |
163 | PREINIT: | |
164 | mp_err merr; | |
165 | CODE: | |
166 | Newz(0, RETVAL, 1, mp_int); | |
167 | merr = mp_init(RETVAL); | |
168 | mp_zero(RETVAL); | |
169 | PERL_UNUSED_VAR(merr); | |
110 | 170 | OUTPUT: |
111 | 171 | RETVAL |
112 | 172 | |
115 | 175 | |
116 | 176 | Math::BigInt::LTM |
117 | 177 | _one(Class) |
118 | CODE: | |
119 | Newz(0, RETVAL, 1, mp_int); | |
120 | mp_init(RETVAL); | |
178 | PREINIT: | |
179 | mp_err merr; | |
180 | CODE: | |
181 | Newz(0, RETVAL, 1, mp_int); | |
182 | merr = mp_init(RETVAL); | |
183 | #ifdef BN_MP_SET_INT_C | |
121 | 184 | mp_set_int(RETVAL, 1); |
185 | #else | |
186 | mp_set_u32(RETVAL, 1); | |
187 | #endif | |
188 | PERL_UNUSED_VAR(merr); | |
122 | 189 | OUTPUT: |
123 | 190 | RETVAL |
124 | 191 | |
127 | 194 | |
128 | 195 | Math::BigInt::LTM |
129 | 196 | _two(Class) |
130 | CODE: | |
131 | Newz(0, RETVAL, 1, mp_int); | |
132 | mp_init(RETVAL); | |
197 | PREINIT: | |
198 | mp_err merr; | |
199 | CODE: | |
200 | Newz(0, RETVAL, 1, mp_int); | |
201 | merr = mp_init(RETVAL); | |
202 | #ifdef BN_MP_SET_INT_C | |
133 | 203 | mp_set_int(RETVAL, 2); |
204 | #else | |
205 | mp_set_u32(RETVAL, 2); | |
206 | #endif | |
207 | PERL_UNUSED_VAR(merr); | |
134 | 208 | OUTPUT: |
135 | 209 | RETVAL |
136 | 210 | |
139 | 213 | |
140 | 214 | Math::BigInt::LTM |
141 | 215 | _ten(Class) |
142 | CODE: | |
143 | Newz(0, RETVAL, 1, mp_int); | |
144 | mp_init(RETVAL); | |
216 | PREINIT: | |
217 | mp_err merr; | |
218 | CODE: | |
219 | Newz(0, RETVAL, 1, mp_int); | |
220 | merr = mp_init(RETVAL); | |
221 | #ifdef BN_MP_SET_INT_C | |
145 | 222 | mp_set_int(RETVAL, 10); |
223 | #else | |
224 | mp_set_u32(RETVAL, 10); | |
225 | #endif | |
226 | PERL_UNUSED_VAR(merr); | |
146 | 227 | OUTPUT: |
147 | 228 | RETVAL |
148 | 229 | |
151 | 232 | |
152 | 233 | Math::BigInt::LTM |
153 | 234 | _1ex(Class, int x) |
154 | CODE: | |
155 | Newz(0, RETVAL, 1, mp_int); | |
156 | mp_init(RETVAL); | |
235 | PREINIT: | |
236 | mp_err merr; | |
237 | CODE: | |
238 | Newz(0, RETVAL, 1, mp_int); | |
239 | merr = mp_init(RETVAL); | |
240 | #ifdef BN_MP_SET_INT_C | |
157 | 241 | mp_set_int(RETVAL, 10); |
158 | mp_expt_d(RETVAL, x, RETVAL); | |
242 | #else | |
243 | mp_set_u32(RETVAL, 10); | |
244 | #endif | |
245 | merr = mp_expt_d(RETVAL, x, RETVAL); | |
246 | PERL_UNUSED_VAR(merr); | |
159 | 247 | OUTPUT: |
160 | 248 | RETVAL |
161 | 249 | |
176 | 264 | SV * |
177 | 265 | _str(Class, Math::BigInt::LTM n) |
178 | 266 | PREINIT: |
267 | mp_err merr; | |
179 | 268 | int len; |
180 | 269 | char *buf; |
181 | 270 | CODE: |
185 | 274 | else { |
186 | 275 | len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */ |
187 | 276 | Newz(0, buf, len, char); |
188 | mp_toradix_n(n, buf, 10, len); | |
277 | merr = mp_toradix_n(n, buf, 10, len); | |
189 | 278 | RETVAL = newSVpv(buf, 0); |
190 | 279 | Safefree(buf); |
191 | 280 | } |
281 | PERL_UNUSED_VAR(merr); | |
192 | 282 | OUTPUT: |
193 | 283 | RETVAL |
194 | 284 | |
198 | 288 | int |
199 | 289 | _len(Class, Math::BigInt::LTM n) |
200 | 290 | PREINIT: |
291 | mp_err merr; | |
201 | 292 | int len; |
202 | 293 | char *buf; |
203 | 294 | CODE: |
207 | 298 | else { |
208 | 299 | len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */ |
209 | 300 | Newz(0, buf, len, char); |
210 | mp_toradix_n(n, buf, 10, len); | |
301 | merr = mp_toradix_n(n, buf, 10, len); | |
211 | 302 | RETVAL = (int)strlen(buf); |
212 | 303 | Safefree(buf); |
213 | 304 | } |
305 | PERL_UNUSED_VAR(merr); | |
214 | 306 | OUTPUT: |
215 | 307 | RETVAL |
216 | 308 | |
239 | 331 | int |
240 | 332 | _zeros(Class, Math::BigInt::LTM n) |
241 | 333 | PREINIT: |
334 | mp_err merr; | |
242 | 335 | int len; |
243 | 336 | char *buf; |
244 | 337 | CODE: |
248 | 341 | else { |
249 | 342 | len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */ |
250 | 343 | Newz(0, buf, len, char); |
251 | mp_toradix_n(n, buf, 10, len); | |
344 | merr = mp_toradix_n(n, buf, 10, len); | |
252 | 345 | len = (int)strlen(buf); |
253 | 346 | RETVAL = 0; |
254 | 347 | while (len > 0) { |
258 | 351 | } |
259 | 352 | Safefree(buf); |
260 | 353 | } |
354 | PERL_UNUSED_VAR(merr); | |
261 | 355 | OUTPUT: |
262 | 356 | RETVAL |
263 | 357 | |
267 | 361 | SV * |
268 | 362 | _to_hex(Class, Math::BigInt::LTM n) |
269 | 363 | PREINIT: |
364 | mp_err merr; | |
270 | 365 | int i, len; |
271 | 366 | char *buf; |
272 | 367 | CODE: |
274 | 369 | RETVAL = newSV(len); |
275 | 370 | SvPOK_on(RETVAL); |
276 | 371 | buf = SvPVX(RETVAL); |
277 | mp_tohex(n, buf); | |
372 | merr = mp_toradix(n, buf, 16); /* to hex */ | |
278 | 373 | for (i=0; i<len && buf[i]>0; i++) buf[i] = toLOWER(buf[i]); |
279 | 374 | SvCUR_set(RETVAL, strlen(buf)); |
375 | PERL_UNUSED_VAR(merr); | |
280 | 376 | OUTPUT: |
281 | 377 | RETVAL |
282 | 378 | |
286 | 382 | SV * |
287 | 383 | _to_bin(Class, Math::BigInt::LTM n) |
288 | 384 | PREINIT: |
385 | mp_err merr; | |
289 | 386 | int len; |
290 | 387 | char *buf; |
291 | 388 | CODE: |
293 | 390 | RETVAL = newSV(len); |
294 | 391 | SvPOK_on(RETVAL); |
295 | 392 | buf = SvPVX(RETVAL); |
296 | mp_tobinary(n, buf); | |
393 | merr = mp_toradix(n, buf, 2); /* to binary */ | |
297 | 394 | SvCUR_set(RETVAL, strlen(buf)); |
395 | PERL_UNUSED_VAR(merr); | |
298 | 396 | OUTPUT: |
299 | 397 | RETVAL |
300 | 398 | |
304 | 402 | SV * |
305 | 403 | _to_oct(Class, Math::BigInt::LTM n) |
306 | 404 | PREINIT: |
405 | mp_err merr; | |
307 | 406 | int len; |
308 | 407 | char *buf; |
309 | 408 | CODE: |
311 | 410 | RETVAL = newSV(len); |
312 | 411 | SvPOK_on(RETVAL); |
313 | 412 | buf = SvPVX(RETVAL); |
314 | mp_tooctal(n, buf); | |
413 | merr = mp_toradix(n, buf, 8); /* to octal */ | |
315 | 414 | SvCUR_set(RETVAL, strlen(buf)); |
415 | PERL_UNUSED_VAR(merr); | |
316 | 416 | OUTPUT: |
317 | 417 | RETVAL |
318 | 418 | |
322 | 422 | SV * |
323 | 423 | _to_base(Class, Math::BigInt::LTM n, int base) |
324 | 424 | PREINIT: |
425 | mp_err merr; | |
325 | 426 | int len; |
326 | 427 | char *buf; |
327 | 428 | CODE: |
330 | 431 | SvPOK_on(RETVAL); |
331 | 432 | buf = SvPVX(RETVAL); |
332 | 433 | if (len > 0) { |
333 | mp_toradix_n(n, buf, base, len); | |
434 | merr = mp_toradix_n(n, buf, base, len); | |
334 | 435 | SvCUR_set(RETVAL, strlen(buf)); |
335 | 436 | } |
336 | 437 | else { |
337 | 438 | buf[0] = '0'; |
338 | 439 | SvCUR_set(RETVAL, 1); |
339 | 440 | } |
441 | PERL_UNUSED_VAR(merr); | |
340 | 442 | OUTPUT: |
341 | 443 | RETVAL |
342 | 444 | |
349 | 451 | ALIAS: |
350 | 452 | _as_bytes = 1 |
351 | 453 | PREINIT: |
454 | mp_err merr; | |
352 | 455 | int len; |
353 | 456 | unsigned char *buf; |
354 | 457 | CODE: |
358 | 461 | SvPOK_on(RETVAL); |
359 | 462 | buf = (unsigned char*)SvPVX(RETVAL); |
360 | 463 | if (len > 0) { |
361 | mp_to_unsigned_bin(n, buf); | |
464 | merr = mp_to_unsigned_bin(n, buf); | |
362 | 465 | SvCUR_set(RETVAL, len); |
363 | 466 | } |
364 | 467 | else { |
365 | 468 | buf[0] = 0; |
366 | 469 | SvCUR_set(RETVAL, 1); |
367 | 470 | } |
471 | PERL_UNUSED_VAR(merr); | |
368 | 472 | OUTPUT: |
369 | 473 | RETVAL |
370 | 474 | |
373 | 477 | |
374 | 478 | Math::BigInt::LTM |
375 | 479 | _modpow(Class, Math::BigInt::LTM n, Math::BigInt::LTM exp, Math::BigInt::LTM mod) |
376 | CODE: | |
377 | Newz(0, RETVAL, 1, mp_int); | |
378 | mp_init(RETVAL); | |
480 | PREINIT: | |
481 | mp_err merr; | |
482 | CODE: | |
483 | Newz(0, RETVAL, 1, mp_int); | |
484 | merr = mp_init(RETVAL); | |
379 | 485 | if (mp_cmp_d(mod, 1) == MP_EQ) { |
380 | mp_set_int(RETVAL, 0); | |
381 | } | |
382 | else { | |
383 | mp_exptmod(n, exp, mod, RETVAL); | |
384 | } | |
486 | mp_zero(RETVAL); | |
487 | } | |
488 | else { | |
489 | merr = mp_exptmod(n, exp, mod, RETVAL); | |
490 | } | |
491 | PERL_UNUSED_VAR(merr); | |
385 | 492 | OUTPUT: |
386 | 493 | RETVAL |
387 | 494 | |
391 | 498 | void |
392 | 499 | _modinv(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
393 | 500 | PREINIT: |
501 | mp_err merr; | |
394 | 502 | int rc; |
395 | 503 | SV* s; |
396 | 504 | mp_int* RETVAL; |
397 | 505 | PPCODE: |
398 | 506 | Newz(0, RETVAL, 1, mp_int); |
399 | mp_init(RETVAL); | |
507 | merr = mp_init(RETVAL); | |
400 | 508 | rc = mp_invmod(x, y, RETVAL); |
401 | 509 | EXTEND(SP, 2); /* we return two values */ |
402 | 510 | if (rc != MP_OKAY) { |
412 | 520 | sv_setpvn(s, "+", 1); |
413 | 521 | PUSHs(s); |
414 | 522 | } |
523 | PERL_UNUSED_VAR(merr); | |
415 | 524 | |
416 | 525 | ############################################################################## |
417 | 526 | # _add() - add $y to $x in place |
418 | 527 | |
419 | 528 | void |
420 | 529 | _add(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
421 | PPCODE: | |
422 | mp_add(x, y, x); | |
530 | PREINIT: | |
531 | mp_err merr; | |
532 | PPCODE: | |
533 | merr = mp_add(x, y, x); | |
534 | PERL_UNUSED_VAR(merr); | |
423 | 535 | XPUSHs(ST(1)); /* x */ |
424 | 536 | |
425 | 537 | ############################################################################## |
427 | 539 | |
428 | 540 | void |
429 | 541 | _inc(Class, Math::BigInt::LTM x) |
430 | PPCODE: | |
431 | mp_add_d(x, 1, x); | |
542 | PREINIT: | |
543 | mp_err merr; | |
544 | PPCODE: | |
545 | merr = mp_add_d(x, 1, x); | |
546 | PERL_UNUSED_VAR(merr); | |
432 | 547 | XPUSHs(ST(1)); /* x */ |
433 | 548 | |
434 | 549 | ############################################################################## |
436 | 551 | |
437 | 552 | void |
438 | 553 | _dec(Class, Math::BigInt::LTM x) |
439 | PPCODE: | |
440 | mp_sub_d(x, 1, x); | |
554 | PREINIT: | |
555 | mp_err merr; | |
556 | PPCODE: | |
557 | merr = mp_sub_d(x, 1, x); | |
558 | PERL_UNUSED_VAR(merr); | |
441 | 559 | XPUSHs(ST(1)); /* x */ |
442 | 560 | |
443 | 561 | ############################################################################## |
446 | 564 | |
447 | 565 | void |
448 | 566 | _sub(Class, Math::BigInt::LTM x, Math::BigInt::LTM y, ...) |
567 | PREINIT: | |
568 | mp_err merr; | |
449 | 569 | PPCODE: |
450 | 570 | if ( items == 4 && SvTRUE(ST(3)) ) { |
451 | 571 | /* y -= x */ |
452 | mp_sub(x, y, y); | |
572 | merr = mp_sub(x, y, y); | |
453 | 573 | XPUSHs(ST(2)); /* y */ |
454 | 574 | } |
455 | 575 | else { |
456 | 576 | /* x -= y */ |
457 | mp_sub(x, y, x); | |
577 | merr = mp_sub(x, y, x); | |
458 | 578 | XPUSHs(ST(1)); /* x */ |
459 | 579 | } |
580 | PERL_UNUSED_VAR(merr); | |
460 | 581 | |
461 | 582 | ############################################################################## |
462 | 583 | # _rsft() |
464 | 585 | void |
465 | 586 | _rsft(Class, Math::BigInt::LTM x, Math::BigInt::LTM y, unsigned long base_int) |
466 | 587 | PREINIT: |
588 | mp_err merr; | |
467 | 589 | mp_int* BASE; |
468 | 590 | PPCODE: |
469 | 591 | Newz(0, BASE, 1, mp_int); |
470 | mp_init_set_int(BASE, base_int); | |
471 | mp_expt_d(BASE, mp_get_long(y), BASE); | |
472 | mp_div(x, BASE, x, NULL); | |
592 | merr = mp_init(BASE); | |
593 | #ifdef BN_MP_SET_INT_C | |
594 | mp_set_int(BASE, base_int); | |
595 | #else | |
596 | mp_set_ul(BASE, base_int); | |
597 | #endif | |
598 | #ifdef BN_MP_GET_LONG_C | |
599 | merr = mp_expt_d(BASE, mp_get_long(y), BASE); | |
600 | #else | |
601 | merr = mp_expt_d(BASE, mp_get_ul(y), BASE); | |
602 | #endif | |
603 | merr = mp_div(x, BASE, x, NULL); | |
604 | PERL_UNUSED_VAR(merr); | |
473 | 605 | mp_clear(BASE); |
474 | 606 | Safefree(BASE); |
475 | 607 | XPUSHs(ST(1)); /* x */ |
480 | 612 | void |
481 | 613 | _lsft(Class, Math::BigInt::LTM x, Math::BigInt::LTM y, unsigned long base_int) |
482 | 614 | PREINIT: |
615 | mp_err merr; | |
483 | 616 | mp_int* BASE; |
484 | 617 | PPCODE: |
485 | 618 | Newz(0, BASE, 1, mp_int); |
486 | mp_init_set_int(BASE, base_int); | |
487 | mp_expt_d(BASE, mp_get_long(y), BASE); | |
488 | mp_mul(x, BASE, x); | |
619 | merr = mp_init(BASE); | |
620 | #ifdef BN_MP_SET_INT_C | |
621 | mp_set_int(BASE, base_int); | |
622 | #else | |
623 | mp_set_ul(BASE, base_int); | |
624 | #endif | |
625 | #ifdef BN_MP_GET_LONG_C | |
626 | merr = mp_expt_d(BASE, mp_get_long(y), BASE); | |
627 | #else | |
628 | merr = mp_expt_d(BASE, mp_get_ul(y), BASE); | |
629 | #endif | |
630 | merr = mp_mul(x, BASE, x); | |
631 | PERL_UNUSED_VAR(merr); | |
489 | 632 | mp_clear(BASE); |
490 | 633 | Safefree(BASE); |
491 | 634 | XPUSHs(ST(1)); /* x */ |
495 | 638 | |
496 | 639 | void |
497 | 640 | _mul(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
498 | PPCODE: | |
499 | mp_mul(x, y, x); | |
641 | PREINIT: | |
642 | mp_err merr; | |
643 | PPCODE: | |
644 | merr = mp_mul(x, y, x); | |
645 | PERL_UNUSED_VAR(merr); | |
500 | 646 | XPUSHs(ST(1)); /* x */ |
501 | 647 | |
502 | 648 | ############################################################################## |
505 | 651 | void |
506 | 652 | _div(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
507 | 653 | PREINIT: |
654 | mp_err merr; | |
508 | 655 | mp_int * rem; |
509 | 656 | PPCODE: |
510 | 657 | if (GIMME_V == G_ARRAY) { |
511 | 658 | Newz(0, rem, 1, mp_int); |
512 | mp_init(rem); | |
513 | mp_div(x, y, x, rem); | |
659 | merr = mp_init(rem); | |
660 | merr = mp_div(x, y, x, rem); | |
514 | 661 | EXTEND(SP, 2); |
515 | 662 | PUSHs(ST(1)); /* x */ |
516 | 663 | PUSHs(sv_2mortal(sv_from_mpi(rem))); |
517 | 664 | } |
518 | 665 | else { |
519 | mp_div(x, y, x, NULL); | |
666 | merr = mp_div(x, y, x, NULL); | |
520 | 667 | XPUSHs(ST(1)); /* x */ |
521 | 668 | } |
669 | PERL_UNUSED_VAR(merr); | |
522 | 670 | |
523 | 671 | ############################################################################## |
524 | 672 | # _mod() - x %= y |
525 | 673 | |
526 | 674 | void |
527 | 675 | _mod(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
528 | PPCODE: | |
529 | mp_mod(x, y, x); | |
676 | PREINIT: | |
677 | mp_err merr; | |
678 | PPCODE: | |
679 | merr = mp_mod(x, y, x); | |
680 | PERL_UNUSED_VAR(merr); | |
530 | 681 | XPUSHs(ST(1)); /* x */ |
531 | 682 | |
532 | 683 | ############################################################################## |
586 | 737 | |
587 | 738 | void |
588 | 739 | _pow(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
589 | PPCODE: | |
590 | mp_expt_d(x, mp_get_long(y), x); | |
740 | PREINIT: | |
741 | mp_err merr; | |
742 | PPCODE: | |
743 | #ifdef BN_MP_GET_LONG_C | |
744 | merr = mp_expt_d(x, mp_get_long(y), x); | |
745 | #else | |
746 | merr = mp_expt_d(x, mp_get_ul(y), x); | |
747 | #endif | |
748 | PERL_UNUSED_VAR(merr); | |
591 | 749 | XPUSHs(ST(1)); /* x */ |
592 | 750 | |
593 | 751 | ############################################################################## |
595 | 753 | |
596 | 754 | Math::BigInt::LTM |
597 | 755 | _gcd(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
598 | CODE: | |
599 | Newz(0, RETVAL, 1, mp_int); | |
600 | mp_init(RETVAL); | |
601 | mp_gcd(x, y, RETVAL); | |
756 | PREINIT: | |
757 | mp_err merr; | |
758 | CODE: | |
759 | Newz(0, RETVAL, 1, mp_int); | |
760 | merr = mp_init(RETVAL); | |
761 | merr = mp_gcd(x, y, RETVAL); | |
762 | PERL_UNUSED_VAR(merr); | |
602 | 763 | OUTPUT: |
603 | 764 | RETVAL |
604 | 765 | |
607 | 768 | |
608 | 769 | void |
609 | 770 | _and(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
610 | PPCODE: | |
611 | mp_and(x, y, x); | |
771 | PREINIT: | |
772 | mp_err merr; | |
773 | PPCODE: | |
774 | merr = mp_and(x, y, x); | |
775 | PERL_UNUSED_VAR(merr); | |
612 | 776 | XPUSHs(ST(1)); /* x */ |
613 | 777 | |
614 | 778 | ############################################################################## |
616 | 780 | |
617 | 781 | void |
618 | 782 | _xor(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
619 | PPCODE: | |
620 | mp_xor(x, y, x); | |
783 | PREINIT: | |
784 | mp_err merr; | |
785 | PPCODE: | |
786 | merr = mp_xor(x, y, x); | |
787 | PERL_UNUSED_VAR(merr); | |
621 | 788 | XPUSHs(ST(1)); /* x */ |
622 | 789 | |
623 | 790 | ############################################################################## |
625 | 792 | |
626 | 793 | void |
627 | 794 | _or(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
628 | PPCODE: | |
629 | mp_or(x, y, x); | |
795 | PREINIT: | |
796 | mp_err merr; | |
797 | PPCODE: | |
798 | merr = mp_or(x, y, x); | |
799 | PERL_UNUSED_VAR(merr); | |
630 | 800 | XPUSHs(ST(1)); /* x */ |
631 | 801 | |
632 | 802 | ############################################################################## |
634 | 804 | |
635 | 805 | Math::BigInt::LTM |
636 | 806 | _copy(Class, Math::BigInt::LTM m) |
637 | CODE: | |
638 | Newz(0, RETVAL, 1, mp_int); | |
639 | mp_init(RETVAL); | |
640 | mp_copy(m, RETVAL); | |
807 | PREINIT: | |
808 | mp_err merr; | |
809 | CODE: | |
810 | Newz(0, RETVAL, 1, mp_int); | |
811 | merr = mp_init(RETVAL); | |
812 | merr = mp_copy(m, RETVAL); | |
813 | PERL_UNUSED_VAR(merr); | |
641 | 814 | OUTPUT: |
642 | 815 | RETVAL |
643 | 816 | |
666 | 839 | |
667 | 840 | void |
668 | 841 | _sqrt(Class, Math::BigInt::LTM x) |
669 | PPCODE: | |
670 | mp_sqrt(x, x); | |
842 | PREINIT: | |
843 | mp_err merr; | |
844 | PPCODE: | |
845 | merr = mp_sqrt(x, x); | |
846 | PERL_UNUSED_VAR(merr); | |
671 | 847 | XPUSHs(ST(1)); /* x */ |
672 | 848 | |
673 | 849 | ############################################################################## |
675 | 851 | |
676 | 852 | void |
677 | 853 | _root(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
678 | PPCODE: | |
679 | mp_n_root(x, mp_get_long(y), x); | |
854 | PREINIT: | |
855 | mp_err merr; | |
856 | PPCODE: | |
857 | #ifdef BN_MP_GET_LONG_C | |
858 | merr = mp_n_root(x, mp_get_long(y), x); | |
859 | #else | |
860 | merr = mp_n_root(x, mp_get_ul(y), x); | |
861 | #endif | |
862 | PERL_UNUSED_VAR(merr); | |
680 | 863 | XPUSHs(ST(1)); /* x */ |
681 | 864 | |
682 | 865 | ############################################################################## |
683 | 866 | # _lcm() - least common multiple |
684 | 867 | void |
685 | 868 | _lcm(Class, Math::BigInt::LTM x, Math::BigInt::LTM y) |
686 | PPCODE: | |
687 | mp_lcm(x, y, x) ; | |
869 | PREINIT: | |
870 | mp_err merr; | |
871 | PPCODE: | |
872 | merr = mp_lcm(x, y, x) ; | |
873 | PERL_UNUSED_VAR(merr); | |
688 | 874 | XPUSHs(ST(1)); /* x */ |
689 | 875 | |
690 | 876 | ############################################################################## |
696 | 882 | SV *cloning = NO_INIT |
697 | 883 | SV *serialized |
698 | 884 | PREINIT: |
885 | mp_err merr; | |
699 | 886 | SV *target; |
700 | 887 | mp_int *mpi; |
701 | 888 | PPCODE: |
702 | 889 | PERL_UNUSED_VAR(cloning); |
703 | 890 | if (SvROK(blank_obj) && sv_isa(blank_obj, "Math::BigInt::LTM")) { |
704 | 891 | Newz(0, mpi, 1, mp_int); |
705 | mp_init(mpi); | |
706 | mp_read_radix(mpi, SvPV_nolen(serialized), 10); | |
892 | merr = mp_init(mpi); | |
893 | merr = mp_read_radix(mpi, SvPV_nolen(serialized), 10); | |
894 | PERL_UNUSED_VAR(merr); | |
707 | 895 | target = SvRV(blank_obj); |
708 | 896 | SvIV_set(target, PTR2IV(mpi)); |
709 | 897 | SvIOK_on(target); |
718 | 906 | Math::BigInt::LTM self |
719 | 907 | SV *cloning = NO_INIT |
720 | 908 | PREINIT: |
909 | mp_err merr; | |
721 | 910 | unsigned long len; |
722 | 911 | char *buf; |
723 | 912 | CODE: |
728 | 917 | else { |
729 | 918 | len = mp_count_bits(self) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */ |
730 | 919 | Newz(0, buf, len, char); |
731 | mp_toradix_n(self, buf, 10, len); | |
920 | merr = mp_toradix_n(self, buf, 10, len); | |
921 | PERL_UNUSED_VAR(merr); | |
732 | 922 | RETVAL = newSVpv(buf, 0); |
733 | 923 | Safefree(buf); |
734 | 924 | } |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | ### not used |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::Checksum Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::Checksum Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Cipher); |
9 | 9 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use Carp; |
7 | 7 | $Carp::Internal{(__PACKAGE__)}++; |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( chaes chaes_hex chaes_b64 chaes_b64u chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( keccak384 keccak384_hex keccak384_b64 keccak384_b64u keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( keccak512 keccak512_hex keccak512_b64 keccak512_b64u keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( md2 md2_hex md2_b64 md2_b64u md2_file md2_file_hex md2_file_b64 md2_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( md4 md4_hex md4_b64 md4_b64u md4_file md4_file_hex md4_file_b64 md4_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( md5 md5_hex md5_b64 md5_b64u md5_file md5_file_hex md5_file_b64 md5_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha1 sha1_hex sha1_b64 sha1_b64u sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha224 sha224_hex sha224_b64 sha224_b64u sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha256 sha256_hex sha256_b64 sha256_b64u sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha384 sha384_hex sha384_b64 sha384_b64u sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha512 sha512_hex sha512_b64 sha512_b64u sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha512_224 sha512_224_hex sha512_224_b64 sha512_224_b64u sha512_224_file sha512_224_file_hex sha512_224_file_b64 sha512_224_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use Carp; |
7 | 7 | $Carp::Internal{(__PACKAGE__)}++; |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( tiger192 tiger192_hex tiger192_b64 tiger192_b64u tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Digest Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(pbkdf1 pbkdf2 hkdf hkdf_expand hkdf_extract)] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2b blake2b_hex blake2b_b64 blake2b_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( f9 f9_hex f9_b64 f9_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( hmac hmac_hex hmac_b64 hmac_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 omac_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( pmac pmac_hex pmac_b64 pmac_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( pelican pelican_hex pelican_b64 pelican_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( poly1305 poly1305_hex poly1305_b64 poly1305_b64u )] ); |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use base qw(Crypt::Mac Exporter); |
9 | 9 | our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 xcbc_b64u )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use Carp; |
7 | 7 | $Carp::Internal{(__PACKAGE__)}++; |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import'; |
7 | 7 | use Carp 'croak'; |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use Crypt::Cipher; |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use Crypt::Cipher; |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use Crypt::Cipher; |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use Crypt::Cipher; |
9 | 9 |
3 | 3 | |
4 | 4 | use strict; |
5 | 5 | use warnings; |
6 | our $VERSION = '0.063'; | |
6 | our $VERSION = '0.064'; | |
7 | 7 | |
8 | 8 | use Crypt::Cipher; |
9 | 9 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | ### not used |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( dh_shared_secret )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( dsa_encrypt dsa_decrypt dsa_sign_message dsa_verify_message dsa_sign_hash dsa_verify_hash )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw( ecc_encrypt ecc_decrypt ecc_sign_message ecc_verify_message ecc_sign_hash ecc_verify_hash ecc_shared_secret )] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(rsa_encrypt rsa_decrypt rsa_sign_message rsa_verify_message rsa_sign_hash rsa_verify_hash)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use Carp; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::PRNG Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::PRNG Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::PRNG Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::PRNG Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use base qw(Crypt::PRNG Exporter); |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import'; |
7 | 7 | our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] ); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings ; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | require XSLoader; |
7 | 7 | XSLoader::load('CryptX', $VERSION); |
1 | 1 | |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | our $VERSION = '0.063'; | |
4 | our $VERSION = '0.064'; | |
5 | 5 | |
6 | 6 | use CryptX; |
7 | 7 | use Carp; |
3 | 3 | /* |
4 | 4 | ---------------------------------------------------------------------- |
5 | 5 | |
6 | ppport.h -- Perl/Pollution/Portability Version 3.36 | |
7 | ||
8 | Automatically created by Devel::PPPort running under perl 5.022003. | |
6 | ppport.h -- Perl/Pollution/Portability Version 3.52 | |
7 | ||
8 | Automatically created by Devel::PPPort running under perl 5.026003. | |
9 | 9 | |
10 | 10 | Do NOT edit this file directly! -- Edit PPPort_pm.PL and the |
11 | 11 | includes in parts/inc/ instead. |
20 | 20 | |
21 | 21 | =head1 NAME |
22 | 22 | |
23 | ppport.h - Perl/Pollution/Portability version 3.36 | |
23 | ppport.h - Perl/Pollution/Portability version 3.52 | |
24 | 24 | |
25 | 25 | =head1 SYNOPSIS |
26 | 26 | |
45 | 45 | --nochanges don't suggest changes |
46 | 46 | --nofilter don't filter input files |
47 | 47 | |
48 | --strip strip all script and doc functionality from | |
49 | ppport.h | |
48 | --strip strip all script and doc functionality | |
49 | from ppport.h | |
50 | 50 | |
51 | 51 | --list-provided list provided API |
52 | 52 | --list-unsupported list unsupported API |
55 | 55 | =head1 COMPATIBILITY |
56 | 56 | |
57 | 57 | This version of F<ppport.h> is designed to support operation with Perl |
58 | installations back to 5.003, and has been tested up to 5.20. | |
58 | installations back to 5.003, and has been tested up to 5.30. | |
59 | 59 | |
60 | 60 | =head1 OPTIONS |
61 | 61 | |
220 | 220 | PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL |
221 | 221 | SvRX() NEED_SvRX NEED_SvRX_GLOBAL |
222 | 222 | caller_cx() NEED_caller_cx NEED_caller_cx_GLOBAL |
223 | croak_xs_usage() NEED_croak_xs_usage NEED_croak_xs_usage_GLOBAL | |
224 | die_sv() NEED_die_sv NEED_die_sv_GLOBAL | |
223 | 225 | eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL |
224 | 226 | grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL |
225 | 227 | grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL |
228 | 230 | grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL |
229 | 231 | gv_fetchpvn_flags() NEED_gv_fetchpvn_flags NEED_gv_fetchpvn_flags_GLOBAL |
230 | 232 | load_module() NEED_load_module NEED_load_module_GLOBAL |
233 | mess() NEED_mess NEED_mess_GLOBAL | |
234 | mess_nocontext() NEED_mess_nocontext NEED_mess_nocontext_GLOBAL | |
235 | mess_sv() NEED_mess_sv NEED_mess_sv_GLOBAL | |
231 | 236 | mg_findext() NEED_mg_findext NEED_mg_findext_GLOBAL |
232 | 237 | my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL |
233 | 238 | my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL |
234 | 239 | my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL |
235 | 240 | my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL |
241 | my_strnlen() NEED_my_strnlen NEED_my_strnlen_GLOBAL | |
236 | 242 | newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL |
237 | 243 | newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL |
238 | 244 | newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL |
249 | 255 | sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL |
250 | 256 | sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL |
251 | 257 | sv_unmagicext() NEED_sv_unmagicext NEED_sv_unmagicext_GLOBAL |
258 | utf8_to_uvchr_buf() NEED_utf8_to_uvchr_buf NEED_utf8_to_uvchr_buf_GLOBAL | |
252 | 259 | vload_module() NEED_vload_module NEED_vload_module_GLOBAL |
260 | vmess() NEED_vmess NEED_vmess_GLOBAL | |
253 | 261 | vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL |
254 | 262 | warner() NEED_warner NEED_warner_GLOBAL |
255 | 263 | |
329 | 337 | |
330 | 338 | If F<ppport.h> was generated using the latest version of |
331 | 339 | C<Devel::PPPort> and is causing failure of this module, please |
332 | file a bug report here: L<https://github.com/mhx/Devel-PPPort/issues/> | |
340 | send a bug report to L<perlbug@perl.org|mailto:perlbug@perl.org>. | |
333 | 341 | |
334 | 342 | Please include the following information: |
335 | 343 | |
380 | 388 | use strict; |
381 | 389 | |
382 | 390 | # Disable broken TRIE-optimization |
383 | BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } | |
384 | ||
385 | my $VERSION = 3.36; | |
391 | BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if "$]" >= 5.009004 && "$]" <= 5.009005 } | |
392 | ||
393 | my $VERSION = 3.52; | |
386 | 394 | |
387 | 395 | my %opt = ( |
388 | 396 | quiet => 0, |
449 | 457 | (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), |
450 | 458 | } ) |
451 | 459 | : die "invalid spec: $_" } qw( |
452 | ASCII_TO_NEED||5.007001|n | |
453 | 460 | AvFILLp|5.004050||p |
454 | 461 | AvFILL||| |
462 | BOM_UTF8||| | |
455 | 463 | BhkDISABLE||5.024000| |
456 | 464 | BhkENABLE||5.024000| |
457 | 465 | BhkENTRY_set||5.024000| |
540 | 548 | IVTYPE|5.006000||p |
541 | 549 | IVdf|5.006000||p |
542 | 550 | LEAVE||| |
551 | LIKELY|||p | |
543 | 552 | LINKLIST||5.013006| |
544 | 553 | LVRET||| |
545 | 554 | MARK||| |
551 | 560 | MY_CXT|5.007003||p |
552 | 561 | MoveD|5.009002|5.004050|p |
553 | 562 | Move||| |
554 | NATIVE_TO_NEED||5.007001|n | |
555 | 563 | NOOP|5.005000||p |
556 | 564 | NUM2PTR|5.006000||p |
557 | 565 | NVTYPE|5.006000||p |
596 | 604 | PERLIO_FUNCS_CAST|5.009003||p |
597 | 605 | PERLIO_FUNCS_DECL|5.009003||p |
598 | 606 | PERL_ABS|5.008001||p |
607 | PERL_ARGS_ASSERT_CROAK_XS_USAGE|||p | |
599 | 608 | PERL_BCDVERSION|5.024000||p |
600 | 609 | PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p |
601 | 610 | PERL_HASH|5.003070||p |
743 | 752 | PL_sv_no|5.004050||pn |
744 | 753 | PL_sv_undef|5.004050||pn |
745 | 754 | PL_sv_yes|5.004050||pn |
755 | PL_sv_zero|||n | |
746 | 756 | PL_tainted|5.004050||p |
747 | 757 | PL_tainting|5.004050||p |
748 | 758 | PL_tokenbuf|5.024000||p |
819 | 829 | PerlIO_tell||5.007003| |
820 | 830 | PerlIO_unread||5.007003| |
821 | 831 | PerlIO_write||5.007003| |
822 | Perl_signbit||5.009005|n | |
832 | PerlLIO_dup2_cloexec||| | |
833 | PerlLIO_dup_cloexec||| | |
834 | PerlLIO_open3_cloexec||| | |
835 | PerlLIO_open_cloexec||| | |
836 | PerlProc_pipe_cloexec||| | |
837 | PerlSock_accept_cloexec||| | |
838 | PerlSock_socket_cloexec||| | |
839 | PerlSock_socketpair_cloexec||| | |
840 | Perl_langinfo|||n | |
841 | Perl_setlocale|||n | |
823 | 842 | PoisonFree|5.009004||p |
824 | 843 | PoisonNew|5.009004||p |
825 | 844 | PoisonWith|5.009004||p |
826 | 845 | Poison|5.008000||p |
827 | 846 | READ_XDIGIT||5.017006| |
847 | REPLACEMENT_CHARACTER_UTF8||| | |
828 | 848 | RESTORE_LC_NUMERIC||5.024000| |
829 | 849 | RETVAL|||n |
830 | 850 | Renewc||| |
926 | 946 | SvPOK_on||| |
927 | 947 | SvPOKp||| |
928 | 948 | SvPOK||| |
949 | SvPVCLEAR||| | |
929 | 950 | SvPVX_const|5.009003||p |
930 | 951 | SvPVX_mutable|5.009003||p |
931 | 952 | SvPVX||| |
963 | 984 | SvPVutf8||5.006000| |
964 | 985 | SvPVx||| |
965 | 986 | SvPV||| |
987 | SvREADONLY_off||| | |
988 | SvREADONLY_on||| | |
989 | SvREADONLY||| | |
966 | 990 | SvREFCNT_dec_NN||5.017007| |
967 | 991 | SvREFCNT_dec||| |
968 | 992 | SvREFCNT_inc_NN|5.009004||p |
1014 | 1038 | SvVSTRING_mg|5.009004||p |
1015 | 1039 | THIS|||n |
1016 | 1040 | UNDERBAR|5.009002||p |
1041 | UNICODE_REPLACEMENT|||p | |
1042 | UNLIKELY|||p | |
1017 | 1043 | UTF8SKIP||5.006000| |
1044 | UTF8_IS_INVARIANT||| | |
1045 | UTF8_IS_NONCHAR||| | |
1046 | UTF8_IS_SUPER||| | |
1047 | UTF8_IS_SURROGATE||| | |
1018 | 1048 | UTF8_MAXBYTES|5.009002||p |
1049 | UTF8_SAFE_SKIP|||p | |
1050 | UVCHR_IS_INVARIANT||| | |
1019 | 1051 | UVCHR_SKIP||5.022000| |
1020 | 1052 | UVSIZE|5.006000||p |
1021 | 1053 | UVTYPE|5.006000||p |
1113 | 1145 | XopFLAGS||5.013007| |
1114 | 1146 | ZeroD|5.009002||p |
1115 | 1147 | Zero||| |
1148 | __ASSERT_|||p | |
1116 | 1149 | _aMY_CXT|5.007003||p |
1117 | _add_range_to_invlist||| | |
1118 | _append_range_to_invlist||| | |
1119 | _core_swash_init||| | |
1120 | _get_encoding||| | |
1121 | _get_regclass_nonbitmap_data||| | |
1122 | _get_swash_invlist||| | |
1123 | _invlistEQ||| | |
1124 | _invlist_array_init|||n | |
1125 | _invlist_contains_cp|||n | |
1126 | _invlist_dump||| | |
1127 | _invlist_intersection_maybe_complement_2nd||| | |
1128 | _invlist_intersection||| | |
1129 | _invlist_invert||| | |
1130 | _invlist_len|||n | |
1131 | _invlist_populate_swatch|||n | |
1132 | _invlist_search|||n | |
1133 | _invlist_subtract||| | |
1134 | _invlist_union_maybe_complement_2nd||| | |
1135 | _invlist_union||| | |
1136 | _is_cur_LC_category_utf8||| | |
1137 | _is_in_locale_category||5.021001| | |
1138 | _is_uni_FOO||5.017008| | |
1139 | _is_uni_perl_idcont||5.017008| | |
1140 | _is_uni_perl_idstart||5.017007| | |
1141 | _is_utf8_FOO||5.017008| | |
1142 | _is_utf8_char_slow||5.021001|n | |
1143 | _is_utf8_idcont||5.021001| | |
1144 | _is_utf8_idstart||5.021001| | |
1145 | _is_utf8_mark||5.017008| | |
1146 | _is_utf8_perl_idcont||5.017008| | |
1147 | _is_utf8_perl_idstart||5.017007| | |
1148 | _is_utf8_xidcont||5.021001| | |
1149 | _is_utf8_xidstart||5.021001| | |
1150 | _load_PL_utf8_foldclosures||| | |
1151 | _make_exactf_invlist||| | |
1150 | _inverse_folds||| | |
1151 | _is_grapheme||| | |
1152 | _is_in_locale_category||| | |
1152 | 1153 | _new_invlist_C_array||| |
1153 | _new_invlist||| | |
1154 | 1154 | _pMY_CXT|5.007003||p |
1155 | _setlocale_debug_string|||n | |
1156 | _setup_canned_invlist||| | |
1157 | _swash_inversion_hash||| | |
1158 | _swash_to_invlist||| | |
1159 | _to_fold_latin1||| | |
1160 | _to_uni_fold_flags||5.014000| | |
1155 | _to_fold_latin1|||n | |
1161 | 1156 | _to_upper_title_latin1||| |
1162 | 1157 | _to_utf8_case||| |
1163 | _to_utf8_fold_flags||5.019009| | |
1164 | _to_utf8_lower_flags||5.019009| | |
1165 | _to_utf8_title_flags||5.019009| | |
1166 | _to_utf8_upper_flags||5.019009| | |
1158 | _variant_byte_number|||n | |
1167 | 1159 | _warn_problematic_locale|||n |
1168 | 1160 | aMY_CXT_|5.007003||p |
1169 | 1161 | aMY_CXT|5.007003||p |
1171 | 1163 | aTHXR|5.024000||p |
1172 | 1164 | aTHX_|5.006000||p |
1173 | 1165 | aTHX|5.006000||p |
1166 | abort_execution||| | |
1174 | 1167 | add_above_Latin1_folds||| |
1175 | add_cp_to_invlist||| | |
1176 | 1168 | add_data|||n |
1177 | 1169 | add_multi_match||| |
1178 | 1170 | add_utf16_textfilter||| |
1180 | 1172 | advance_one_LB||| |
1181 | 1173 | advance_one_SB||| |
1182 | 1174 | advance_one_WB||| |
1183 | alloc_maybe_populate_EXACT||| | |
1184 | alloccopstash||| | |
1185 | 1175 | allocmy||| |
1186 | 1176 | amagic_call||| |
1187 | 1177 | amagic_cmp_locale||| |
1193 | 1183 | anonymise_cv_maybe||| |
1194 | 1184 | any_dup||| |
1195 | 1185 | ao||| |
1196 | append_utf8_from_native_byte||5.019004|n | |
1197 | 1186 | apply_attrs_my||| |
1198 | apply_attrs_string||5.006001| | |
1199 | 1187 | apply_attrs||| |
1200 | 1188 | apply||| |
1189 | argvout_final||| | |
1201 | 1190 | assert_uft8_cache_coherent||| |
1202 | 1191 | assignment_type||| |
1203 | 1192 | atfork_lock||5.007003|n |
1204 | 1193 | atfork_unlock||5.007003|n |
1205 | 1194 | av_arylen_p||5.009003| |
1206 | 1195 | av_clear||| |
1207 | av_create_and_push||5.009005| | |
1208 | av_create_and_unshift_one||5.009005| | |
1209 | 1196 | av_delete||5.006000| |
1210 | 1197 | av_exists||5.006000| |
1211 | 1198 | av_extend_guts||| |
1215 | 1202 | av_iter_p||5.011000| |
1216 | 1203 | av_len||| |
1217 | 1204 | av_make||| |
1205 | av_nonelem||| | |
1218 | 1206 | av_pop||| |
1219 | 1207 | av_push||| |
1220 | 1208 | av_reify||| |
1221 | 1209 | av_shift||| |
1222 | 1210 | av_store||| |
1223 | av_tindex||5.017009| | |
1224 | av_top_index||5.017009| | |
1211 | av_tindex|5.017009|5.017009|p | |
1212 | av_top_index|5.017009|5.017009|p | |
1225 | 1213 | av_undef||| |
1226 | 1214 | av_unshift||| |
1227 | 1215 | ax|||n |
1216 | backup_one_GCB||| | |
1228 | 1217 | backup_one_LB||| |
1229 | 1218 | backup_one_SB||| |
1230 | 1219 | backup_one_WB||| |
1240 | 1229 | boot_core_UNIVERSAL||| |
1241 | 1230 | boot_core_mro||| |
1242 | 1231 | bytes_cmp_utf8||5.013007| |
1243 | bytes_from_utf8||5.007001| | |
1244 | bytes_to_utf8||5.006001| | |
1245 | 1232 | cBOOL|5.013000||p |
1246 | 1233 | call_argv|5.006000||p |
1247 | 1234 | call_atexit||5.006000| |
1256 | 1243 | cast_iv||5.006000|n |
1257 | 1244 | cast_ulong||5.006000|n |
1258 | 1245 | cast_uv||5.006000|n |
1259 | check_locale_boundary_crossing||| | |
1246 | category_name|||n | |
1247 | change_engine_size||| | |
1248 | check_and_deprecate||| | |
1260 | 1249 | check_type_and_open||| |
1261 | 1250 | check_uni||| |
1262 | check_utf8_print||| | |
1263 | 1251 | checkcomma||| |
1252 | ckWARN2_d||| | |
1253 | ckWARN2||| | |
1254 | ckWARN3_d||| | |
1255 | ckWARN3||| | |
1256 | ckWARN4_d||| | |
1257 | ckWARN4||| | |
1258 | ckWARN_d||| | |
1264 | 1259 | ckWARN|5.006000||p |
1265 | 1260 | ck_entersub_args_core||| |
1266 | 1261 | ck_entersub_args_list||5.013006| |
1272 | 1267 | ckwarn_d||5.009003| |
1273 | 1268 | ckwarn||5.009003| |
1274 | 1269 | clear_defarray||5.023008| |
1275 | clear_placeholders||| | |
1276 | 1270 | clear_special_blocks||| |
1277 | 1271 | clone_params_del|||n |
1278 | 1272 | clone_params_new|||n |
1280 | 1274 | cntrl_to_mnemonic|||n |
1281 | 1275 | compute_EXACTish|||n |
1282 | 1276 | construct_ahocorasick_from_trie||| |
1283 | cop_fetch_label||5.015001| | |
1284 | 1277 | cop_free||| |
1285 | 1278 | cop_hints_2hv||5.013007| |
1286 | 1279 | cop_hints_fetch_pvn||5.013007| |
1287 | 1280 | cop_hints_fetch_pvs||5.013007| |
1288 | 1281 | cop_hints_fetch_pv||5.013007| |
1289 | 1282 | cop_hints_fetch_sv||5.013007| |
1290 | cop_store_label||5.015001| | |
1291 | 1283 | cophh_2hv||5.013007| |
1292 | 1284 | cophh_copy||5.013007| |
1293 | 1285 | cophh_delete_pvn||5.013007| |
1307 | 1299 | core_prototype||| |
1308 | 1300 | coresub_op||| |
1309 | 1301 | cr_textfilter||| |
1310 | create_eval_scope||| | |
1311 | croak_memory_wrap||5.019003|n | |
1302 | croak_caller|||vn | |
1303 | croak_memory_wrap|5.019003||pn | |
1312 | 1304 | croak_no_mem|||n |
1313 | croak_no_modify||5.013003|n | |
1314 | croak_nocontext|||vn | |
1305 | croak_no_modify|5.013003||pn | |
1306 | croak_nocontext|||pvn | |
1315 | 1307 | croak_popstack|||n |
1316 | croak_sv||5.013001| | |
1317 | croak_xs_usage||5.010001|n | |
1308 | croak_sv|5.013001||p | |
1309 | croak_xs_usage|5.010001||pn | |
1318 | 1310 | croak|||v |
1319 | 1311 | csighandler||5.009003|n |
1320 | 1312 | current_re_engine||| |
1324 | 1316 | custom_op_name||5.007003| |
1325 | 1317 | custom_op_register||5.013007| |
1326 | 1318 | custom_op_xop||5.013007| |
1327 | cv_ckproto_len_flags||| | |
1328 | 1319 | cv_clone_into||| |
1329 | 1320 | cv_clone||| |
1330 | 1321 | cv_const_sv_or_av|||n |
1331 | 1322 | cv_const_sv||5.003070|n |
1332 | 1323 | cv_dump||| |
1333 | 1324 | cv_forget_slab||| |
1325 | cv_get_call_checker_flags||| | |
1334 | 1326 | cv_get_call_checker||5.013006| |
1335 | 1327 | cv_name||5.021005| |
1336 | 1328 | cv_set_call_checker_flags||5.021004| |
1342 | 1334 | cvstash_set||| |
1343 | 1335 | cx_dump||5.005000| |
1344 | 1336 | cx_dup||| |
1345 | cx_popblock||5.023008| | |
1346 | cx_popeval||5.023008| | |
1347 | cx_popformat||5.023008| | |
1348 | cx_popgiven||5.023008| | |
1349 | cx_poploop||5.023008| | |
1350 | cx_popsub_args||5.023008| | |
1351 | cx_popsub_common||5.023008| | |
1352 | cx_popsub||5.023008| | |
1353 | cx_popwhen||5.023008| | |
1354 | cx_pushblock||5.023008| | |
1355 | cx_pusheval||5.023008| | |
1356 | cx_pushformat||5.023008| | |
1357 | cx_pushgiven||5.023008| | |
1358 | cx_pushloop_for||5.023008| | |
1359 | cx_pushloop_plain||5.023008| | |
1360 | cx_pushsub||5.023008| | |
1361 | cx_pushwhen||5.023008| | |
1362 | cx_topblock||5.023008| | |
1363 | 1337 | cxinc||| |
1364 | 1338 | dAXMARK|5.009003||p |
1365 | 1339 | dAX|5.007002||p |
1395 | 1369 | deb||5.007003|v |
1396 | 1370 | defelem_target||| |
1397 | 1371 | del_sv||| |
1398 | delete_eval_scope||| | |
1372 | delimcpy_no_escape|||n | |
1399 | 1373 | delimcpy||5.004000|n |
1400 | deprecate_commaless_var_list||| | |
1401 | 1374 | despatch_signals||5.007001| |
1402 | 1375 | destroy_matcher||| |
1403 | 1376 | die_nocontext|||vn |
1404 | die_sv||5.013001| | |
1377 | die_sv|5.013001||p | |
1405 | 1378 | die_unwind||| |
1406 | 1379 | die|||v |
1407 | 1380 | dirp_dup||| |
1417 | 1390 | do_dump_pad||| |
1418 | 1391 | do_eof||| |
1419 | 1392 | do_exec3||| |
1420 | do_execfree||| | |
1421 | 1393 | do_exec||| |
1422 | 1394 | do_gv_dump||5.006000| |
1423 | 1395 | do_gvgv_dump||5.006000| |
1431 | 1403 | do_ncmp||| |
1432 | 1404 | do_oddball||| |
1433 | 1405 | do_op_dump||5.006000| |
1434 | do_open6||| | |
1435 | 1406 | do_open9||5.006000| |
1436 | do_open_raw||| | |
1437 | 1407 | do_openn||5.007001| |
1438 | 1408 | do_open||5.003070| |
1439 | 1409 | do_pmop_dump||5.006000| |
1460 | 1430 | do_vecset||| |
1461 | 1431 | do_vop||| |
1462 | 1432 | docatch||| |
1433 | does_utf8_overflow|||n | |
1463 | 1434 | doeval_compile||| |
1464 | 1435 | dofile||| |
1465 | 1436 | dofindlabel||| |
1493 | 1464 | dump_mstats||| |
1494 | 1465 | dump_packsubs_perl||| |
1495 | 1466 | dump_packsubs||5.006000| |
1467 | dump_regex_sets_structures||| | |
1496 | 1468 | dump_sub_perl||| |
1497 | 1469 | dump_sub||5.006000| |
1498 | 1470 | dump_sv_child||| |
1502 | 1474 | dump_vindent||5.006000| |
1503 | 1475 | dumpuntil||| |
1504 | 1476 | dup_attrlist||| |
1477 | dup_warnings||| | |
1505 | 1478 | edit_distance|||n |
1506 | emulate_cop_io||| | |
1479 | emulate_setlocale|||n | |
1507 | 1480 | eval_pv|5.006000||p |
1508 | 1481 | eval_sv|5.006000||p |
1509 | 1482 | exec_failed||| |
1525 | 1498 | find_hash_subscript||| |
1526 | 1499 | find_in_my_stash||| |
1527 | 1500 | find_lexical_cv||| |
1501 | find_next_masked|||n | |
1528 | 1502 | find_runcv_where||| |
1529 | 1503 | find_runcv||5.008001| |
1530 | find_rundefsvoffset||5.009002| | |
1531 | 1504 | find_rundefsv||5.013002| |
1532 | 1505 | find_script||| |
1533 | find_uninit_var||| | |
1506 | find_span_end_mask|||n | |
1507 | find_span_end|||n | |
1534 | 1508 | first_symbol|||n |
1535 | 1509 | fixup_errno_string||| |
1510 | foldEQ_latin1_s2_folded|||n | |
1536 | 1511 | foldEQ_latin1||5.013008|n |
1537 | 1512 | foldEQ_locale||5.013002|n |
1538 | foldEQ_utf8_flags||5.013010| | |
1539 | 1513 | foldEQ_utf8||5.013002| |
1540 | 1514 | foldEQ||5.013002|n |
1541 | 1515 | fold_constants||| |
1549 | 1523 | force_word||| |
1550 | 1524 | forget_pmop||| |
1551 | 1525 | form_nocontext|||vn |
1552 | form_short_octal_warning||| | |
1553 | 1526 | form||5.004000|v |
1554 | 1527 | fp_dup||| |
1555 | 1528 | fprintf_nocontext|||vn |
1558 | 1531 | free_tied_hv_pool||| |
1559 | 1532 | free_tmps||| |
1560 | 1533 | gen_constant_list||| |
1534 | get_ANYOFM_contents||| | |
1561 | 1535 | get_ANYOF_cp_list_for_ssc||| |
1536 | get_and_check_backslash_N_name_wrapper||| | |
1562 | 1537 | get_and_check_backslash_N_name||| |
1563 | 1538 | get_aux_mg||| |
1564 | 1539 | get_av|5.006000||p |
1572 | 1547 | get_debug_opts||| |
1573 | 1548 | get_hash_seed||| |
1574 | 1549 | get_hv|5.006000||p |
1575 | get_invlist_iter_addr|||n | |
1576 | get_invlist_offset_addr|||n | |
1577 | get_invlist_previous_index_addr|||n | |
1578 | 1550 | get_mstats||| |
1579 | 1551 | get_no_modify||| |
1580 | 1552 | get_num||| |
1582 | 1554 | get_op_names||5.005000| |
1583 | 1555 | get_opargs||| |
1584 | 1556 | get_ppaddr||5.006000| |
1585 | get_re_arg||| | |
1586 | 1557 | get_sv|5.006000||p |
1587 | 1558 | get_vtbl||5.005030| |
1588 | 1559 | getcwd_sv||5.007002| |
1595 | 1566 | grok_atoUV|||n |
1596 | 1567 | grok_bin|5.007003||p |
1597 | 1568 | grok_bslash_N||| |
1598 | grok_bslash_c||| | |
1599 | grok_bslash_o||| | |
1600 | grok_bslash_x||| | |
1601 | 1569 | grok_hex|5.007003||p |
1602 | 1570 | grok_infnan||5.021004| |
1603 | 1571 | grok_number_flags||5.021002| |
1631 | 1599 | gv_fetchmeth_sv_autoload||5.015004| |
1632 | 1600 | gv_fetchmeth_sv||5.015004| |
1633 | 1601 | gv_fetchmethod_autoload||5.004000| |
1634 | gv_fetchmethod_pv_flags||5.015004| | |
1635 | gv_fetchmethod_pvn_flags||5.015004| | |
1636 | gv_fetchmethod_sv_flags||5.015004| | |
1637 | 1602 | gv_fetchmethod||| |
1638 | 1603 | gv_fetchmeth||| |
1639 | 1604 | gv_fetchpvn_flags|5.009002||p |
1661 | 1626 | gv_stashpv||| |
1662 | 1627 | gv_stashsvpvn_cached||| |
1663 | 1628 | gv_stashsv||| |
1664 | gv_try_downgrade||| | |
1665 | 1629 | handle_named_backref||| |
1666 | 1630 | handle_possible_posix||| |
1667 | 1631 | handle_regex_sets||| |
1632 | handle_user_defined_property||| | |
1668 | 1633 | he_dup||| |
1669 | 1634 | hek_dup||| |
1670 | 1635 | hfree_next_entry||| |
1671 | hfreeentries||| | |
1672 | 1636 | hsplit||| |
1673 | 1637 | hv_assert||| |
1674 | 1638 | hv_auxinit_internal|||n |
1675 | 1639 | hv_auxinit||| |
1676 | hv_backreferences_p||| | |
1677 | 1640 | hv_clear_placeholders||5.009001| |
1678 | 1641 | hv_clear||| |
1679 | 1642 | hv_common_key_len||5.010000| |
1680 | 1643 | hv_common||5.010000| |
1681 | 1644 | hv_copy_hints_hv||5.009004| |
1682 | 1645 | hv_delayfree_ent||5.004000| |
1683 | hv_delete_common||| | |
1684 | 1646 | hv_delete_ent||5.003070| |
1685 | 1647 | hv_delete||| |
1686 | 1648 | hv_eiter_p||5.009003| |
1694 | 1656 | hv_fetch||| |
1695 | 1657 | hv_fill||5.013002| |
1696 | 1658 | hv_free_ent_ret||| |
1659 | hv_free_entries||| | |
1697 | 1660 | hv_free_ent||5.004000| |
1698 | 1661 | hv_iterinit||| |
1699 | 1662 | hv_iterkeysv||5.003070| |
1700 | 1663 | hv_iterkey||| |
1701 | hv_iternext_flags||5.008000| | |
1702 | 1664 | hv_iternextsv||| |
1703 | 1665 | hv_iternext||| |
1704 | 1666 | hv_iterval||| |
1705 | hv_kill_backrefs||| | |
1706 | 1667 | hv_ksplit||5.003070| |
1707 | 1668 | hv_magic_check|||n |
1708 | 1669 | hv_magic||| |
1711 | 1672 | hv_placeholders_get||5.009003| |
1712 | 1673 | hv_placeholders_p||| |
1713 | 1674 | hv_placeholders_set||5.009003| |
1675 | hv_pushkv||| | |
1714 | 1676 | hv_rand_set||5.018000| |
1715 | 1677 | hv_riter_p||5.009003| |
1716 | 1678 | hv_riter_set||5.009003| |
1717 | 1679 | hv_scalar||5.009001| |
1718 | 1680 | hv_store_ent||5.003070| |
1719 | hv_store_flags||5.008000| | |
1720 | 1681 | hv_stores|5.009004||p |
1721 | 1682 | hv_store||| |
1722 | 1683 | hv_undef_flags||| |
1734 | 1695 | init_dbargs||| |
1735 | 1696 | init_debugger||| |
1736 | 1697 | init_global_struct||| |
1737 | init_i18nl10n||5.006000| | |
1738 | init_i18nl14n||5.006000| | |
1739 | 1698 | init_ids||| |
1740 | 1699 | init_interp||| |
1741 | 1700 | init_main_stash||| |
1701 | init_named_cv||| | |
1742 | 1702 | init_perllib||| |
1743 | 1703 | init_postdump_symbols||| |
1744 | 1704 | init_predump_symbols||| |
1745 | 1705 | init_stacks||5.005000| |
1746 | 1706 | init_tm||5.007002| |
1707 | init_uniprops||| | |
1747 | 1708 | inplace_aassign||| |
1748 | 1709 | instr|||n |
1749 | 1710 | intro_my||5.004000| |
1750 | 1711 | intuit_method||| |
1751 | 1712 | intuit_more||| |
1752 | 1713 | invert||| |
1753 | invlist_array|||n | |
1754 | invlist_clear||| | |
1755 | invlist_clone||| | |
1756 | invlist_contents||| | |
1757 | invlist_extend||| | |
1758 | invlist_highest|||n | |
1759 | invlist_is_iterating|||n | |
1760 | invlist_iterfinish|||n | |
1761 | invlist_iterinit|||n | |
1762 | invlist_iternext|||n | |
1763 | invlist_max|||n | |
1764 | invlist_previous_index|||n | |
1765 | invlist_replace_list_destroys_src||| | |
1766 | invlist_set_len||| | |
1767 | invlist_set_previous_index|||n | |
1768 | invlist_trim|||n | |
1769 | 1714 | invoke_exception_hook||| |
1770 | 1715 | io_close||| |
1716 | isALNUMC_A|||p | |
1771 | 1717 | isALNUMC|5.006000||p |
1772 | isALNUM_lazy||5.021001| | |
1773 | isALPHANUMERIC||5.017008| | |
1774 | isALPHA||| | |
1718 | isALNUM_A|||p | |
1719 | isALNUM|||p | |
1720 | isALPHANUMERIC_A|||p | |
1721 | isALPHANUMERIC|5.017008|5.017008|p | |
1722 | isALPHA_A|||p | |
1723 | isALPHA|||p | |
1724 | isASCII_A|||p | |
1775 | 1725 | isASCII|5.006000||p |
1726 | isBLANK_A|||p | |
1776 | 1727 | isBLANK|5.006001||p |
1728 | isC9_STRICT_UTF8_CHAR|||n | |
1729 | isCNTRL_A|||p | |
1777 | 1730 | isCNTRL|5.006000||p |
1778 | isDIGIT||| | |
1779 | isFOO_lc||| | |
1731 | isDIGIT_A|||p | |
1732 | isDIGIT|||p | |
1733 | isFF_OVERLONG|||n | |
1780 | 1734 | isFOO_utf8_lc||| |
1781 | isGCB|||n | |
1735 | isGCB||| | |
1736 | isGRAPH_A|||p | |
1782 | 1737 | isGRAPH|5.006000||p |
1783 | isIDCONT||5.017008| | |
1784 | isIDFIRST_lazy||5.021001| | |
1785 | isIDFIRST||| | |
1738 | isIDCONT_A|||p | |
1739 | isIDCONT|5.017008|5.017008|p | |
1740 | isIDFIRST_A|||p | |
1741 | isIDFIRST|||p | |
1786 | 1742 | isLB||| |
1787 | isLOWER||| | |
1788 | isOCTAL||5.013005| | |
1743 | isLOWER_A|||p | |
1744 | isLOWER|||p | |
1745 | isOCTAL_A|||p | |
1746 | isOCTAL|5.013005|5.013005|p | |
1747 | isPRINT_A|||p | |
1789 | 1748 | isPRINT|5.004000||p |
1749 | isPSXSPC_A|||p | |
1790 | 1750 | isPSXSPC|5.006001||p |
1751 | isPUNCT_A|||p | |
1791 | 1752 | isPUNCT|5.006000||p |
1792 | 1753 | isSB||| |
1793 | isSPACE||| | |
1794 | isUPPER||| | |
1795 | isUTF8_CHAR||5.021001| | |
1754 | isSCRIPT_RUN||| | |
1755 | isSPACE_A|||p | |
1756 | isSPACE|||p | |
1757 | isSTRICT_UTF8_CHAR|||n | |
1758 | isUPPER_A|||p | |
1759 | isUPPER|||p | |
1760 | isUTF8_CHAR_flags||| | |
1761 | isUTF8_CHAR||5.021001|n | |
1796 | 1762 | isWB||| |
1797 | isWORDCHAR||5.013006| | |
1763 | isWORDCHAR_A|||p | |
1764 | isWORDCHAR|5.013006|5.013006|p | |
1765 | isXDIGIT_A|||p | |
1798 | 1766 | isXDIGIT|5.006000||p |
1799 | 1767 | is_an_int||| |
1800 | is_ascii_string||5.011000| | |
1768 | is_ascii_string||5.011000|n | |
1769 | is_c9strict_utf8_string_loclen|||n | |
1770 | is_c9strict_utf8_string_loc|||n | |
1771 | is_c9strict_utf8_string|||n | |
1801 | 1772 | is_handle_constructor|||n |
1802 | 1773 | is_invariant_string||5.021007|n |
1803 | 1774 | is_lvalue_sub||5.007001| |
1804 | 1775 | is_safe_syscall||5.019004| |
1805 | 1776 | is_ssc_worth_it|||n |
1806 | is_uni_alnum_lc||5.006000| | |
1807 | is_uni_alnumc_lc||5.017007| | |
1808 | is_uni_alnumc||5.017007| | |
1809 | is_uni_alnum||5.006000| | |
1810 | is_uni_alpha_lc||5.006000| | |
1811 | is_uni_alpha||5.006000| | |
1812 | is_uni_ascii_lc||5.006000| | |
1813 | is_uni_ascii||5.006000| | |
1814 | is_uni_blank_lc||5.017002| | |
1815 | is_uni_blank||5.017002| | |
1816 | is_uni_cntrl_lc||5.006000| | |
1817 | is_uni_cntrl||5.006000| | |
1818 | is_uni_digit_lc||5.006000| | |
1819 | is_uni_digit||5.006000| | |
1820 | is_uni_graph_lc||5.006000| | |
1821 | is_uni_graph||5.006000| | |
1822 | is_uni_idfirst_lc||5.006000| | |
1823 | is_uni_idfirst||5.006000| | |
1824 | is_uni_lower_lc||5.006000| | |
1825 | is_uni_lower||5.006000| | |
1826 | is_uni_print_lc||5.006000| | |
1827 | is_uni_print||5.006000| | |
1828 | is_uni_punct_lc||5.006000| | |
1829 | is_uni_punct||5.006000| | |
1830 | is_uni_space_lc||5.006000| | |
1831 | is_uni_space||5.006000| | |
1832 | is_uni_upper_lc||5.006000| | |
1833 | is_uni_upper||5.006000| | |
1834 | is_uni_xdigit_lc||5.006000| | |
1835 | is_uni_xdigit||5.006000| | |
1836 | is_utf8_alnumc||5.017007| | |
1837 | is_utf8_alnum||5.006000| | |
1838 | is_utf8_alpha||5.006000| | |
1839 | is_utf8_ascii||5.006000| | |
1840 | is_utf8_blank||5.017002| | |
1777 | is_strict_utf8_string_loclen|||n | |
1778 | is_strict_utf8_string_loc|||n | |
1779 | is_strict_utf8_string|||n | |
1841 | 1780 | is_utf8_char_buf||5.015008|n |
1842 | is_utf8_char||5.006000|n | |
1843 | is_utf8_cntrl||5.006000| | |
1781 | is_utf8_common_with_len||| | |
1844 | 1782 | is_utf8_common||| |
1845 | is_utf8_digit||5.006000| | |
1846 | is_utf8_graph||5.006000| | |
1847 | is_utf8_idcont||5.008000| | |
1848 | is_utf8_idfirst||5.006000| | |
1849 | is_utf8_lower||5.006000| | |
1850 | is_utf8_mark||5.006000| | |
1851 | is_utf8_perl_space||5.011001| | |
1852 | is_utf8_perl_word||5.011001| | |
1853 | is_utf8_posix_digit||5.011001| | |
1854 | is_utf8_print||5.006000| | |
1855 | is_utf8_punct||5.006000| | |
1856 | is_utf8_space||5.006000| | |
1783 | is_utf8_cp_above_31_bits|||n | |
1784 | is_utf8_fixed_width_buf_flags|||n | |
1785 | is_utf8_fixed_width_buf_loc_flags|||n | |
1786 | is_utf8_fixed_width_buf_loclen_flags|||n | |
1787 | is_utf8_invariant_string_loc|||n | |
1788 | is_utf8_invariant_string|||n | |
1789 | is_utf8_non_invariant_string|||n | |
1790 | is_utf8_overlong_given_start_byte_ok|||n | |
1791 | is_utf8_string_flags|||n | |
1792 | is_utf8_string_loc_flags|||n | |
1793 | is_utf8_string_loclen_flags|||n | |
1857 | 1794 | is_utf8_string_loclen||5.009003|n |
1858 | 1795 | is_utf8_string_loc||5.008001|n |
1859 | 1796 | is_utf8_string||5.006001|n |
1860 | is_utf8_upper||5.006000| | |
1861 | is_utf8_xdigit||5.006000| | |
1862 | is_utf8_xidcont||5.013010| | |
1863 | is_utf8_xidfirst||5.013010| | |
1797 | is_utf8_valid_partial_char_flags|||n | |
1798 | is_utf8_valid_partial_char|||n | |
1864 | 1799 | isa_lookup||| |
1865 | 1800 | isinfnansv||| |
1866 | 1801 | isinfnan||5.021004|n |
1870 | 1805 | join_exact||| |
1871 | 1806 | keyword_plugin_standard||| |
1872 | 1807 | keyword||| |
1873 | leave_adjust_stacks||5.023008| | |
1874 | 1808 | leave_scope||| |
1875 | lex_bufutf8||5.011002| | |
1876 | lex_discard_to||5.011002| | |
1877 | lex_grow_linestr||5.011002| | |
1878 | lex_next_chunk||5.011002| | |
1879 | lex_peek_unichar||5.011002| | |
1880 | lex_read_space||5.011002| | |
1881 | lex_read_to||5.011002| | |
1882 | lex_read_unichar||5.011002| | |
1883 | lex_start||5.009005| | |
1884 | lex_stuff_pvn||5.011002| | |
1885 | 1809 | lex_stuff_pvs||5.013005| |
1886 | lex_stuff_pv||5.013006| | |
1887 | lex_stuff_sv||5.011002| | |
1888 | lex_unstuff||5.011002| | |
1889 | 1810 | listkids||| |
1890 | 1811 | list||| |
1891 | 1812 | load_module_nocontext|||vn |
1950 | 1871 | magic_setlvref||| |
1951 | 1872 | magic_setmglob||| |
1952 | 1873 | magic_setnkeys||| |
1874 | magic_setnonelem||| | |
1953 | 1875 | magic_setpack||| |
1954 | 1876 | magic_setpos||| |
1955 | 1877 | magic_setregexp||| |
1982 | 1904 | mem_log_free|||n |
1983 | 1905 | mem_log_realloc|||n |
1984 | 1906 | mess_alloc||| |
1985 | mess_nocontext|||vn | |
1986 | mess_sv||5.013001| | |
1987 | mess||5.006000|v | |
1907 | mess_nocontext|||pvn | |
1908 | mess_sv|5.013001||p | |
1909 | mess|5.006000||pv | |
1988 | 1910 | mfree||5.007002|n |
1989 | 1911 | mg_clear||| |
1990 | 1912 | mg_copy||| |
1993 | 1915 | mg_findext|5.013008||pn |
1994 | 1916 | mg_find|||n |
1995 | 1917 | mg_free_type||5.013006| |
1918 | mg_freeext||| | |
1996 | 1919 | mg_free||| |
1997 | 1920 | mg_get||| |
1998 | mg_length||5.005000| | |
1999 | 1921 | mg_localize||| |
2000 | 1922 | mg_magical|||n |
2001 | 1923 | mg_set||| |
2024 | 1946 | mro_set_mro||5.010001| |
2025 | 1947 | mro_set_private_data||5.010001| |
2026 | 1948 | mul128||| |
2027 | mulexp10|||n | |
1949 | multiconcat_stringify||| | |
2028 | 1950 | multideref_stringify||| |
2029 | 1951 | my_atof2||5.007002| |
1952 | my_atof3||| | |
2030 | 1953 | my_atof||5.006000| |
2031 | 1954 | my_attrs||| |
2032 | my_bcopy||5.004050|n | |
2033 | 1955 | my_bytes_to_utf8|||n |
2034 | my_bzero|||n | |
2035 | 1956 | my_chsize||| |
2036 | 1957 | my_clearenv||| |
2037 | 1958 | my_cxt_index||| |
2045 | 1966 | my_kid||| |
2046 | 1967 | my_lstat_flags||| |
2047 | 1968 | my_lstat||5.024000| |
2048 | my_memcmp|||n | |
2049 | my_memset|||n | |
1969 | my_memrchr|||n | |
1970 | my_mkostemp|||n | |
1971 | my_mkstemp_cloexec|||n | |
1972 | my_mkstemp|||n | |
1973 | my_nl_langinfo|||n | |
2050 | 1974 | my_pclose||5.003070| |
2051 | 1975 | my_popen_list||5.007001| |
2052 | 1976 | my_popen||5.003070| |
2053 | 1977 | my_setenv||| |
2054 | my_setlocale||| | |
2055 | 1978 | my_snprintf|5.009004||pvn |
2056 | 1979 | my_socketpair||5.007003|n |
2057 | 1980 | my_sprintf|5.009003||pvn |
2058 | 1981 | my_stat_flags||| |
2059 | 1982 | my_stat||5.024000| |
2060 | my_strerror||5.021001| | |
1983 | my_strerror||| | |
2061 | 1984 | my_strftime||5.007002| |
2062 | 1985 | my_strlcat|5.009004||pn |
2063 | 1986 | my_strlcpy|5.009004||pn |
1987 | my_strnlen|||pn | |
1988 | my_strtod|||n | |
2064 | 1989 | my_unexec||| |
2065 | 1990 | my_vsnprintf||5.009004|n |
2066 | 1991 | need_utf8|||n |
2083 | 2008 | newFOROP||5.013007| |
2084 | 2009 | newGIVENOP||5.009003| |
2085 | 2010 | newGIVWHENOP||| |
2086 | newGP||| | |
2087 | 2011 | newGVOP||| |
2088 | 2012 | newGVREF||| |
2089 | 2013 | newGVgen_flags||5.015004| |
2102 | 2026 | newMYSUB||5.017004| |
2103 | 2027 | newNULLLIST||| |
2104 | 2028 | newOP||| |
2105 | newPADNAMELIST||5.021007|n | |
2106 | newPADNAMEouter||5.021007|n | |
2107 | newPADNAMEpvn||5.021007|n | |
2108 | 2029 | newPADOP||| |
2109 | 2030 | newPMOP||| |
2110 | 2031 | newPROG||| |
2137 | 2058 | newSVpvs|5.009003||p |
2138 | 2059 | newSVpv||| |
2139 | 2060 | newSVrv||| |
2061 | newSVsv_flags||| | |
2062 | newSVsv_nomg||| | |
2140 | 2063 | newSVsv||| |
2141 | 2064 | newSVuv|5.006000||p |
2142 | 2065 | newSV||| |
2145 | 2068 | newWHENOP||5.009003| |
2146 | 2069 | newWHILEOP||5.013007| |
2147 | 2070 | newXS_deffile||| |
2148 | newXS_flags||5.009004| | |
2149 | 2071 | newXS_len_flags||| |
2150 | 2072 | newXSproto||5.006000| |
2151 | 2073 | newXS||5.006000| |
2152 | new_collate||5.006000| | |
2074 | new_collate||| | |
2153 | 2075 | new_constant||| |
2154 | new_ctype||5.006000| | |
2076 | new_ctype||| | |
2155 | 2077 | new_he||| |
2156 | 2078 | new_logop||| |
2157 | new_numeric||5.006000| | |
2079 | new_msg_hv||| | |
2080 | new_numeric||| | |
2081 | new_regcurly|||n | |
2158 | 2082 | new_stackinfo||5.005000| |
2159 | 2083 | new_version||5.009000| |
2160 | new_warnings_bitfield||| | |
2161 | 2084 | next_symbol||| |
2162 | 2085 | nextargv||| |
2163 | 2086 | nextchar||| |
2169 | 2092 | not_a_number||| |
2170 | 2093 | not_incrementable||| |
2171 | 2094 | nothreadhook||5.008000| |
2095 | notify_parser_that_changed_to_utf8||| | |
2172 | 2096 | nuke_stacks||| |
2173 | 2097 | num_overflow|||n |
2174 | 2098 | oopsAV||| |
2175 | 2099 | oopsHV||| |
2176 | 2100 | op_append_elem||5.013006| |
2177 | 2101 | op_append_list||5.013006| |
2102 | op_class||| | |
2178 | 2103 | op_clear||| |
2179 | 2104 | op_contextualize||5.013006| |
2180 | 2105 | op_convert_list||5.021006| |
2183 | 2108 | op_integerize||| |
2184 | 2109 | op_linklist||5.013006| |
2185 | 2110 | op_lvalue_flags||| |
2186 | op_lvalue||5.013007| | |
2187 | 2111 | op_null||5.007002| |
2188 | 2112 | op_parent|||n |
2189 | 2113 | op_prepend_elem||5.013006| |
2190 | op_refcnt_dec||| | |
2191 | op_refcnt_inc||| | |
2192 | 2114 | op_refcnt_lock||5.009002| |
2193 | 2115 | op_refcnt_unlock||5.009002| |
2194 | 2116 | op_relocate_sv||| |
2195 | op_scope||5.013007| | |
2196 | 2117 | op_sibling_splice||5.021002|n |
2197 | 2118 | op_std_init||| |
2198 | op_unscope||| | |
2199 | 2119 | open_script||| |
2200 | 2120 | openn_cleanup||| |
2201 | 2121 | openn_setup||| |
2203 | 2123 | opslab_force_free||| |
2204 | 2124 | opslab_free_nopad||| |
2205 | 2125 | opslab_free||| |
2206 | output_or_return_posix_warnings||| | |
2126 | optimize_optree||| | |
2127 | optimize_op||| | |
2128 | output_posix_warnings||| | |
2207 | 2129 | pMY_CXT_|5.007003||p |
2208 | 2130 | pMY_CXT|5.007003||p |
2209 | 2131 | pTHX_|5.006000||p |
2221 | 2143 | pad_add_name_sv||5.015001| |
2222 | 2144 | pad_add_weakref||| |
2223 | 2145 | pad_alloc_name||| |
2224 | pad_alloc||| | |
2225 | 2146 | pad_block_start||| |
2226 | 2147 | pad_check_dup||| |
2227 | 2148 | pad_compname_type||5.009003| |
2239 | 2160 | pad_setsv||| |
2240 | 2161 | pad_sv||| |
2241 | 2162 | pad_swipe||| |
2242 | pad_tidy||5.008001| | |
2243 | 2163 | padlist_dup||| |
2244 | 2164 | padlist_store||| |
2245 | 2165 | padname_dup||| |
2246 | 2166 | padname_free||| |
2247 | 2167 | padnamelist_dup||| |
2248 | padnamelist_fetch||5.021007|n | |
2249 | 2168 | padnamelist_free||| |
2250 | padnamelist_store||5.021007| | |
2251 | parse_arithexpr||5.013008| | |
2252 | parse_barestmt||5.013007| | |
2253 | parse_block||5.013007| | |
2254 | 2169 | parse_body||| |
2255 | parse_fullexpr||5.013008| | |
2256 | parse_fullstmt||5.013005| | |
2257 | 2170 | parse_gv_stash_name||| |
2258 | 2171 | parse_ident||| |
2259 | parse_label||5.013007| | |
2260 | parse_listexpr||5.013008| | |
2261 | 2172 | parse_lparen_question_flags||| |
2262 | parse_stmtseq||5.013006| | |
2263 | parse_subsignature||| | |
2264 | parse_termexpr||5.013008| | |
2265 | 2173 | parse_unicode_opts||| |
2174 | parse_uniprop_string||| | |
2266 | 2175 | parser_dup||| |
2267 | 2176 | parser_free_nexttoke_ops||| |
2268 | 2177 | parser_free||| |
2291 | 2200 | pregfree2||5.011000| |
2292 | 2201 | pregfree||| |
2293 | 2202 | prescan_version||5.011004| |
2203 | print_bytes_for_locale||| | |
2204 | print_collxfrm_input_and_return||| | |
2294 | 2205 | printbuf||| |
2295 | 2206 | printf_nocontext|||vn |
2296 | 2207 | process_special_blocks||| |
2297 | 2208 | ptr_hash|||n |
2298 | ptr_table_clear||5.009005| | |
2299 | 2209 | ptr_table_fetch||5.009005| |
2300 | 2210 | ptr_table_find|||n |
2301 | 2211 | ptr_table_free||5.009005| |
2313 | 2223 | pv_pretty|5.009004||p |
2314 | 2224 | pv_uni_display||5.007003| |
2315 | 2225 | qerror||| |
2316 | qsortsvu||| | |
2317 | 2226 | quadmath_format_needed|||n |
2318 | 2227 | quadmath_format_single|||n |
2319 | 2228 | re_compile||5.009005| |
2361 | 2270 | reg_numbered_buff_length||| |
2362 | 2271 | reg_numbered_buff_store||| |
2363 | 2272 | reg_qr_package||| |
2364 | reg_recode||| | |
2365 | 2273 | reg_scan_name||| |
2366 | 2274 | reg_skipcomment|||n |
2367 | 2275 | reg_temp_copy||| |
2368 | 2276 | reganode||| |
2369 | 2277 | regatom||| |
2370 | 2278 | regbranch||| |
2371 | regclass_swash||5.009004| | |
2372 | 2279 | regclass||| |
2280 | regcp_restore||| | |
2373 | 2281 | regcppop||| |
2374 | 2282 | regcppush||| |
2375 | 2283 | regcurly|||n |
2404 | 2312 | require_pv||5.006000| |
2405 | 2313 | require_tie_mod||| |
2406 | 2314 | restore_magic||| |
2315 | restore_switched_locale||| | |
2407 | 2316 | rninstr|||n |
2408 | 2317 | rpeep||| |
2409 | 2318 | rsignal_restore||| |
2475 | 2384 | save_sptr||| |
2476 | 2385 | save_strlen||| |
2477 | 2386 | save_svref||| |
2387 | save_to_buffer|||n | |
2478 | 2388 | save_vptr||5.006000| |
2479 | 2389 | savepvn||| |
2480 | 2390 | savepvs||5.009003| |
2486 | 2396 | savestack_grow_cnt||5.008001| |
2487 | 2397 | savestack_grow||| |
2488 | 2398 | savesvpv||5.009002| |
2489 | savetmps||5.023008| | |
2490 | 2399 | sawparens||| |
2491 | 2400 | scalar_mod_type|||n |
2492 | 2401 | scalarboolean||| |
2505 | 2414 | scan_num||5.007001| |
2506 | 2415 | scan_oct||| |
2507 | 2416 | scan_pat||| |
2508 | scan_str||| | |
2509 | 2417 | scan_subst||| |
2510 | 2418 | scan_trans||| |
2511 | 2419 | scan_version||5.009001| |
2512 | 2420 | scan_vstring||5.009005| |
2513 | scan_word||| | |
2514 | 2421 | search_const||| |
2515 | 2422 | seed||5.008001| |
2516 | 2423 | sequence_num||| |
2517 | 2424 | set_ANYOF_arg||| |
2518 | 2425 | set_caret_X||| |
2519 | 2426 | set_context||5.006000|n |
2520 | set_numeric_local||5.006000| | |
2521 | 2427 | set_numeric_radix||5.006000| |
2522 | 2428 | set_numeric_standard||5.006000| |
2429 | set_numeric_underlying||| | |
2523 | 2430 | set_padlist|||n |
2431 | set_regex_pv||| | |
2524 | 2432 | setdefout||| |
2433 | setfd_cloexec_for_nonsysfd||| | |
2434 | setfd_cloexec_or_inhexec_by_sysfdness||| | |
2435 | setfd_cloexec|||n | |
2436 | setfd_inhexec_for_sysfd||| | |
2437 | setfd_inhexec|||n | |
2438 | setlocale_debug_string|||n | |
2525 | 2439 | share_hek_flags||| |
2526 | 2440 | share_hek||5.004000| |
2527 | 2441 | should_warn_nl|||n |
2529 | 2443 | sighandler|||n |
2530 | 2444 | simplify_sort||| |
2531 | 2445 | skip_to_be_ignored_text||| |
2532 | skipspace_flags||| | |
2533 | 2446 | softref2xv||| |
2534 | 2447 | sortcv_stacked||| |
2535 | 2448 | sortcv_xsub||| |
2551 | 2464 | ssc_or||| |
2552 | 2465 | ssc_union||| |
2553 | 2466 | stack_grow||| |
2554 | start_glob||| | |
2555 | 2467 | start_subparse||5.004000| |
2556 | 2468 | stdize_locale||| |
2557 | 2469 | strEQ||| |
2578 | 2490 | sv_2iv_flags||5.009001| |
2579 | 2491 | sv_2iv||| |
2580 | 2492 | sv_2mortal||| |
2581 | sv_2num||| | |
2582 | 2493 | sv_2nv_flags||5.013001| |
2583 | 2494 | sv_2pv_flags|5.007002||p |
2584 | 2495 | sv_2pv_nolen|5.006000||p |
2652 | 2563 | sv_exp_grow||| |
2653 | 2564 | sv_force_normal_flags||5.007001| |
2654 | 2565 | sv_force_normal||5.006000| |
2655 | sv_free2||| | |
2656 | 2566 | sv_free_arenas||| |
2657 | 2567 | sv_free||| |
2658 | sv_get_backrefs||5.021008|n | |
2659 | 2568 | sv_gets||5.003070| |
2660 | 2569 | sv_grow||| |
2661 | 2570 | sv_i_ncmp||| |
2666 | 2575 | sv_isa||| |
2667 | 2576 | sv_isobject||| |
2668 | 2577 | sv_iv||5.005000| |
2669 | sv_kill_backrefs||| | |
2670 | 2578 | sv_len_utf8_nomg||| |
2671 | 2579 | sv_len_utf8||5.006000| |
2672 | 2580 | sv_len||| |
2712 | 2620 | sv_report_used||| |
2713 | 2621 | sv_resetpvn||| |
2714 | 2622 | sv_reset||| |
2623 | sv_rvunweaken||| | |
2715 | 2624 | sv_rvweaken||5.006000| |
2625 | sv_set_undef||| | |
2716 | 2626 | sv_sethek||| |
2717 | 2627 | sv_setiv_mg|5.004050||p |
2718 | 2628 | sv_setiv||| |
2719 | 2629 | sv_setnv_mg|5.006000||p |
2720 | 2630 | sv_setnv||| |
2631 | sv_setpv_bufsize||| | |
2721 | 2632 | sv_setpv_mg|5.004050||p |
2722 | 2633 | sv_setpvf_mg_nocontext|||pvn |
2723 | 2634 | sv_setpvf_mg|5.006000|5.004000|pv |
2736 | 2647 | sv_setref_pvs||5.024000| |
2737 | 2648 | sv_setref_pv||| |
2738 | 2649 | sv_setref_uv||5.007001| |
2739 | sv_setsv_cow||| | |
2740 | 2650 | sv_setsv_flags||5.007002| |
2741 | 2651 | sv_setsv_mg|5.004050||p |
2742 | 2652 | sv_setsv_nomg|5.007002||p |
2743 | 2653 | sv_setsv||| |
2744 | 2654 | sv_setuv_mg|5.004050||p |
2745 | 2655 | sv_setuv|5.004000||p |
2656 | sv_string_from_errnum||| | |
2746 | 2657 | sv_tainted||5.004000| |
2747 | 2658 | sv_taint||5.004000| |
2748 | 2659 | sv_true||5.005000| |
2757 | 2668 | sv_usepvn_flags||5.009004| |
2758 | 2669 | sv_usepvn_mg|5.004050||p |
2759 | 2670 | sv_usepvn||| |
2760 | sv_utf8_decode||5.006000| | |
2761 | sv_utf8_downgrade||5.006000| | |
2671 | sv_utf8_decode||| | |
2672 | sv_utf8_downgrade||| | |
2762 | 2673 | sv_utf8_encode||5.006000| |
2763 | 2674 | sv_utf8_upgrade_flags_grow||5.011000| |
2764 | 2675 | sv_utf8_upgrade_flags||5.007002| |
2774 | 2685 | sv_vsetpvf|5.006000|5.004000|p |
2775 | 2686 | svtype||| |
2776 | 2687 | swallow_bom||| |
2777 | swash_fetch||5.007002| | |
2778 | swash_init||5.006000| | |
2779 | swash_scan_list_line||| | |
2780 | 2688 | swatch_get||| |
2781 | sync_locale||5.021004| | |
2689 | switch_category_locale_to_template||| | |
2690 | switch_to_global_locale|||n | |
2691 | sync_locale||5.021004|n | |
2782 | 2692 | sys_init3||5.010000|n |
2783 | 2693 | sys_init||5.010000|n |
2784 | 2694 | sys_intern_clear||| |
2789 | 2699 | taint_proper||| |
2790 | 2700 | tied_method|||v |
2791 | 2701 | tmps_grow_p||| |
2702 | toFOLD_utf8_safe||| | |
2792 | 2703 | toFOLD_utf8||5.019001| |
2793 | 2704 | toFOLD_uvchr||5.023009| |
2794 | 2705 | toFOLD||5.019001| |
2795 | 2706 | toLOWER_L1||5.019001| |
2796 | 2707 | toLOWER_LC||5.004000| |
2708 | toLOWER_utf8_safe||| | |
2797 | 2709 | toLOWER_utf8||5.015007| |
2798 | 2710 | toLOWER_uvchr||5.023009| |
2799 | 2711 | toLOWER||| |
2712 | toTITLE_utf8_safe||| | |
2800 | 2713 | toTITLE_utf8||5.015007| |
2801 | 2714 | toTITLE_uvchr||5.023009| |
2802 | 2715 | toTITLE||5.019001| |
2716 | toUPPER_utf8_safe||| | |
2803 | 2717 | toUPPER_utf8||5.015007| |
2804 | 2718 | toUPPER_uvchr||5.023009| |
2805 | 2719 | toUPPER||| |
2806 | 2720 | to_byte_substr||| |
2807 | 2721 | to_lower_latin1|||n |
2808 | to_uni_fold||5.007003| | |
2809 | to_uni_lower_lc||5.006000| | |
2810 | to_uni_lower||5.007003| | |
2811 | to_uni_title_lc||5.006000| | |
2812 | to_uni_title||5.007003| | |
2813 | to_uni_upper_lc||5.006000| | |
2814 | to_uni_upper||5.007003| | |
2815 | to_utf8_case||5.007003| | |
2816 | to_utf8_fold||5.015007| | |
2817 | to_utf8_lower||5.015007| | |
2818 | 2722 | to_utf8_substr||| |
2819 | to_utf8_title||5.015007| | |
2820 | to_utf8_upper||5.015007| | |
2821 | 2723 | tokenize_use||| |
2822 | 2724 | tokeq||| |
2823 | 2725 | tokereport||| |
2824 | 2726 | too_few_arguments_pv||| |
2825 | 2727 | too_many_arguments_pv||| |
2826 | 2728 | translate_substr_offsets|||n |
2729 | traverse_op_tree||| | |
2827 | 2730 | try_amagic_bin||| |
2828 | 2731 | try_amagic_un||| |
2732 | turkic_fc||| | |
2733 | turkic_lc||| | |
2734 | turkic_uc||| | |
2829 | 2735 | uiv_2buf|||n |
2830 | 2736 | unlnk||| |
2831 | 2737 | unpack_rec||| |
2843 | 2749 | utf16_to_utf8_reversed||5.006001| |
2844 | 2750 | utf16_to_utf8||5.006001| |
2845 | 2751 | utf8_distance||5.006000| |
2752 | utf8_hop_back|||n | |
2753 | utf8_hop_forward|||n | |
2754 | utf8_hop_safe|||n | |
2846 | 2755 | utf8_hop||5.006000|n |
2847 | 2756 | utf8_length||5.007001| |
2848 | 2757 | utf8_mg_len_cache_update||| |
2849 | 2758 | utf8_mg_pos_cache_update||| |
2850 | utf8_to_bytes||5.006001| | |
2851 | utf8_to_uvchr_buf||5.015009| | |
2852 | utf8_to_uvchr||5.007001| | |
2853 | utf8_to_uvuni_buf||5.015009| | |
2854 | utf8_to_uvuni||5.007001| | |
2855 | utf8n_to_uvchr||5.007001| | |
2759 | utf8_to_uvchr_buf|5.015009|5.015009|p | |
2760 | utf8_to_uvchr|||p | |
2761 | utf8n_to_uvchr_error|||n | |
2762 | utf8n_to_uvchr||5.007001|n | |
2856 | 2763 | utf8n_to_uvuni||5.007001| |
2857 | 2764 | utilize||| |
2858 | 2765 | uvchr_to_utf8_flags||5.007003| |
2860 | 2767 | uvoffuni_to_utf8_flags||5.019004| |
2861 | 2768 | uvuni_to_utf8_flags||5.007003| |
2862 | 2769 | uvuni_to_utf8||5.007001| |
2863 | valid_utf8_to_uvchr||5.015009| | |
2864 | valid_utf8_to_uvuni||5.015009| | |
2865 | validate_proto||| | |
2770 | valid_utf8_to_uvchr|||n | |
2866 | 2771 | validate_suid||| |
2772 | variant_under_utf8_count|||n | |
2867 | 2773 | varname||| |
2868 | 2774 | vcmp||5.009000| |
2869 | 2775 | vcroak||5.006000| |
2873 | 2779 | vivify_defelem||| |
2874 | 2780 | vivify_ref||| |
2875 | 2781 | vload_module|5.006000||p |
2876 | vmess||5.006000| | |
2782 | vmess|5.006000|5.006000|p | |
2877 | 2783 | vnewSVpvf|5.006000|5.004000|p |
2878 | 2784 | vnormal||5.009002| |
2879 | 2785 | vnumify||5.009000| |
2882 | 2788 | vwarner||5.006000| |
2883 | 2789 | vwarn||5.006000| |
2884 | 2790 | wait4pid||| |
2885 | warn_nocontext|||vn | |
2886 | warn_sv||5.013001| | |
2791 | warn_nocontext|||pvn | |
2792 | warn_on_first_deprecated_use||| | |
2793 | warn_sv|5.013001||p | |
2887 | 2794 | warner_nocontext|||vn |
2888 | 2795 | warner|5.006000|5.004000|pv |
2889 | 2796 | warn|||v |
2894 | 2801 | whichsig_sv||5.015004| |
2895 | 2802 | whichsig||| |
2896 | 2803 | win32_croak_not_implemented|||n |
2804 | win32_setlocale||| | |
2897 | 2805 | with_queued_errors||| |
2898 | 2806 | wrap_op_checker||5.015008| |
2899 | 2807 | write_to_stderr||| |
2905 | 2813 | yyerror||| |
2906 | 2814 | yylex||| |
2907 | 2815 | yyparse||| |
2816 | yyquit||| | |
2908 | 2817 | yyunlex||| |
2909 | 2818 | yywarn||| |
2910 | 2819 | ); |
3672 | 3581 | # endif |
3673 | 3582 | #endif |
3674 | 3583 | |
3675 | #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) | |
3676 | #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) | |
3584 | #define D_PPP_DEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) | |
3585 | #define PERL_BCDVERSION ((D_PPP_DEC2BCD(PERL_REVISION)<<24)|(D_PPP_DEC2BCD(PERL_VERSION)<<12)|D_PPP_DEC2BCD(PERL_SUBVERSION)) | |
3677 | 3586 | |
3678 | 3587 | /* It is very unlikely that anyone will try to use this with Perl 6 |
3679 | 3588 | (or greater), but who knows. |
4070 | 3979 | #ifndef UVSIZE |
4071 | 3980 | # define UVSIZE IVSIZE |
4072 | 3981 | #endif |
4073 | #ifndef sv_setuv | |
4074 | # define sv_setuv(sv, uv) \ | |
4075 | STMT_START { \ | |
4076 | UV TeMpUv = uv; \ | |
4077 | if (TeMpUv <= IV_MAX) \ | |
4078 | sv_setiv(sv, TeMpUv); \ | |
4079 | else \ | |
4080 | sv_setnv(sv, (double)TeMpUv); \ | |
4081 | } STMT_END | |
4082 | #endif | |
4083 | #ifndef newSVuv | |
4084 | # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) | |
4085 | #endif | |
4086 | #ifndef sv_2uv | |
4087 | # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) | |
4088 | #endif | |
4089 | ||
4090 | #ifndef SvUVX | |
4091 | # define SvUVX(sv) ((UV)SvIVX(sv)) | |
4092 | #endif | |
4093 | ||
4094 | #ifndef SvUVXx | |
4095 | # define SvUVXx(sv) SvUVX(sv) | |
4096 | #endif | |
4097 | ||
4098 | #ifndef SvUV | |
4099 | # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) | |
4100 | #endif | |
4101 | ||
4102 | #ifndef SvUVx | |
4103 | # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) | |
4104 | #endif | |
4105 | ||
4106 | /* Hint: sv_uv | |
4107 | * Always use the SvUVx() macro instead of sv_uv(). | |
4108 | */ | |
4109 | #ifndef sv_uv | |
4110 | # define sv_uv(sv) SvUVx(sv) | |
4111 | #endif | |
4112 | ||
4113 | #if !defined(SvUOK) && defined(SvIOK_UV) | |
4114 | # define SvUOK(sv) SvIOK_UV(sv) | |
4115 | #endif | |
4116 | #ifndef XST_mUV | |
4117 | # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) | |
4118 | #endif | |
4119 | ||
4120 | #ifndef XSRETURN_UV | |
4121 | # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END | |
4122 | #endif | |
4123 | #ifndef PUSHu | |
4124 | # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END | |
4125 | #endif | |
4126 | ||
4127 | #ifndef XPUSHu | |
4128 | # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END | |
4129 | #endif | |
4130 | ||
4131 | #ifdef HAS_MEMCMP | |
4132 | #ifndef memNE | |
4133 | # define memNE(s1,s2,l) (memcmp(s1,s2,l)) | |
4134 | #endif | |
4135 | ||
4136 | #ifndef memEQ | |
4137 | # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) | |
4138 | #endif | |
4139 | ||
4140 | #else | |
4141 | #ifndef memNE | |
4142 | # define memNE(s1,s2,l) (bcmp(s1,s2,l)) | |
4143 | #endif | |
4144 | ||
4145 | #ifndef memEQ | |
4146 | # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) | |
4147 | #endif | |
4148 | ||
4149 | #endif | |
4150 | #ifndef memEQs | |
4151 | # define memEQs(s1, l, s2) \ | |
4152 | (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) | |
4153 | #endif | |
4154 | ||
4155 | #ifndef memNEs | |
4156 | # define memNEs(s1, l, s2) !memEQs(s1, l, s2) | |
4157 | #endif | |
4158 | #ifndef MoveD | |
4159 | # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) | |
4160 | #endif | |
4161 | ||
4162 | #ifndef CopyD | |
4163 | # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) | |
4164 | #endif | |
4165 | ||
4166 | #ifdef HAS_MEMSET | |
4167 | #ifndef ZeroD | |
4168 | # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) | |
4169 | #endif | |
4170 | ||
4171 | #else | |
4172 | #ifndef ZeroD | |
4173 | # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) | |
4174 | #endif | |
4175 | ||
4176 | #endif | |
4177 | #ifndef PoisonWith | |
4178 | # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) | |
4179 | #endif | |
4180 | ||
4181 | #ifndef PoisonNew | |
4182 | # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) | |
4183 | #endif | |
4184 | ||
4185 | #ifndef PoisonFree | |
4186 | # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) | |
4187 | #endif | |
4188 | ||
4189 | #ifndef Poison | |
4190 | # define Poison(d,n,t) PoisonFree(d,n,t) | |
4191 | #endif | |
4192 | #ifndef Newx | |
4193 | # define Newx(v,n,t) New(0,v,n,t) | |
4194 | #endif | |
4195 | ||
4196 | #ifndef Newxc | |
4197 | # define Newxc(v,n,t,c) Newc(0,v,n,t,c) | |
4198 | #endif | |
4199 | ||
4200 | #ifndef Newxz | |
4201 | # define Newxz(v,n,t) Newz(0,v,n,t) | |
4202 | #endif | |
4203 | #ifndef PERL_MAGIC_qr | |
4204 | # define PERL_MAGIC_qr 'r' | |
4205 | #endif | |
4206 | 3982 | #ifndef cBOOL |
4207 | 3983 | # define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0) |
4208 | 3984 | #endif |
4225 | 4001 | |
4226 | 4002 | #ifndef OpMAYBESIB_set |
4227 | 4003 | # define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib)) |
4004 | #endif | |
4005 | ||
4006 | #ifndef HEf_SVKEY | |
4007 | # define HEf_SVKEY -2 | |
4008 | #endif | |
4009 | ||
4010 | #if defined(DEBUGGING) && !defined(__COVERITY__) | |
4011 | #ifndef __ASSERT_ | |
4012 | # define __ASSERT_(statement) assert(statement), | |
4013 | #endif | |
4014 | ||
4015 | #else | |
4016 | #ifndef __ASSERT_ | |
4017 | # define __ASSERT_(statement) | |
4018 | #endif | |
4019 | ||
4228 | 4020 | #endif |
4229 | 4021 | |
4230 | 4022 | #ifndef SvRX |
4235 | 4027 | extern void * DPPP_(my_SvRX)(pTHX_ SV *rv); |
4236 | 4028 | #endif |
4237 | 4029 | |
4030 | #if defined(NEED_SvRX) || defined(NEED_SvRX_GLOBAL) | |
4031 | ||
4238 | 4032 | #ifdef SvRX |
4239 | 4033 | # undef SvRX |
4240 | 4034 | #endif |
4241 | 4035 | #define SvRX(a) DPPP_(my_SvRX)(aTHX_ a) |
4242 | 4036 | |
4243 | #if defined(NEED_SvRX) || defined(NEED_SvRX_GLOBAL) | |
4244 | 4037 | |
4245 | 4038 | void * |
4246 | 4039 | DPPP_(my_SvRX)(pTHX_ SV *rv) |
4420 | 4213 | #ifndef AvFILLp |
4421 | 4214 | # define AvFILLp AvFILL |
4422 | 4215 | #endif |
4216 | #ifndef av_tindex | |
4217 | # define av_tindex AvFILL | |
4218 | #endif | |
4219 | ||
4220 | #ifndef av_top_index | |
4221 | # define av_top_index AvFILL | |
4222 | #endif | |
4423 | 4223 | #ifndef ERRSV |
4424 | 4224 | # define ERRSV get_sv("@",FALSE) |
4425 | 4225 | #endif |
4541 | 4341 | typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); |
4542 | 4342 | |
4543 | 4343 | #endif |
4544 | #ifndef isPSXSPC | |
4545 | # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') | |
4546 | #endif | |
4547 | ||
4548 | #ifndef isBLANK | |
4549 | # define isBLANK(c) ((c) == ' ' || (c) == '\t') | |
4344 | ||
4345 | #ifndef WIDEST_UTYPE | |
4346 | # ifdef QUADKIND | |
4347 | # ifdef U64TYPE | |
4348 | # define WIDEST_UTYPE U64TYPE | |
4349 | # else | |
4350 | # define WIDEST_UTYPE Quad_t | |
4351 | # endif | |
4352 | # else | |
4353 | # define WIDEST_UTYPE U32 | |
4354 | # endif | |
4550 | 4355 | #endif |
4551 | 4356 | |
4552 | 4357 | #ifdef EBCDIC |
4553 | #ifndef isALNUMC | |
4554 | # define isALNUMC(c) isalnum(c) | |
4555 | #endif | |
4556 | ||
4358 | ||
4359 | /* This is the first version where these macros are fully correct. Relying on | |
4360 | * the C library functions, as earlier releases did, causes problems with | |
4361 | * locales */ | |
4362 | # if (PERL_BCDVERSION < 0x5022000) | |
4363 | # undef isALNUM | |
4364 | # undef isALNUM_A | |
4365 | # undef isALNUMC | |
4366 | # undef isALNUMC_A | |
4367 | # undef isALPHA | |
4368 | # undef isALPHA_A | |
4369 | # undef isALPHANUMERIC | |
4370 | # undef isALPHANUMERIC_A | |
4371 | # undef isASCII | |
4372 | # undef isASCII_A | |
4373 | # undef isBLANK | |
4374 | # undef isBLANK_A | |
4375 | # undef isCNTRL | |
4376 | # undef isCNTRL_A | |
4377 | # undef isDIGIT | |
4378 | # undef isDIGIT_A | |
4379 | # undef isGRAPH | |
4380 | # undef isGRAPH_A | |
4381 | # undef isIDCONT | |
4382 | # undef isIDCONT_A | |
4383 | # undef isIDFIRST | |
4384 | # undef isIDFIRST_A | |
4385 | # undef isLOWER | |
4386 | # undef isLOWER_A | |
4387 | # undef isOCTAL | |
4388 | # undef isOCTAL_A | |
4389 | # undef isPRINT | |
4390 | # undef isPRINT_A | |
4391 | # undef isPSXSPC | |
4392 | # undef isPSXSPC_A | |
4393 | # undef isPUNCT | |
4394 | # undef isPUNCT_A | |
4395 | # undef isSPACE | |
4396 | # undef isSPACE_A | |
4397 | # undef isUPPER | |
4398 | # undef isUPPER_A | |
4399 | # undef isWORDCHAR | |
4400 | # undef isWORDCHAR_A | |
4401 | # undef isXDIGIT | |
4402 | # undef isXDIGIT_A | |
4403 | # endif | |
4557 | 4404 | #ifndef isASCII |
4558 | # define isASCII(c) isascii(c) | |
4559 | #endif | |
4560 | ||
4405 | # define isASCII(c) (isCNTRL(c) || isPRINT(c)) | |
4406 | #endif | |
4407 | ||
4408 | /* The below is accurate for all EBCDIC code pages supported by | |
4409 | * all the versions of Perl overridden by this */ | |
4561 | 4410 | #ifndef isCNTRL |
4562 | # define isCNTRL(c) iscntrl(c) | |
4563 | #endif | |
4564 | ||
4565 | #ifndef isGRAPH | |
4566 | # define isGRAPH(c) isgraph(c) | |
4567 | #endif | |
4568 | ||
4569 | #ifndef isPRINT | |
4570 | # define isPRINT(c) isprint(c) | |
4571 | #endif | |
4572 | ||
4573 | #ifndef isPUNCT | |
4574 | # define isPUNCT(c) ispunct(c) | |
4575 | #endif | |
4576 | ||
4577 | #ifndef isXDIGIT | |
4578 | # define isXDIGIT(c) isxdigit(c) | |
4579 | #endif | |
4580 | ||
4581 | #else | |
4411 | # define isCNTRL(c) ( (c) == '\0' || (c) == '\a' || (c) == '\b' \ | |
4412 | || (c) == '\f' || (c) == '\n' || (c) == '\r' \ | |
4413 | || (c) == '\t' || (c) == '\v' \ | |
4414 | || ((c) <= 3 && (c) >= 1) /* SOH, STX, ETX */ \ | |
4415 | || (c) == 7 /* U+7F DEL */ \ | |
4416 | || ((c) <= 0x13 && (c) >= 0x0E) /* SO, SI */ \ | |
4417 | /* DLE, DC[1-3] */ \ | |
4418 | || (c) == 0x18 /* U+18 CAN */ \ | |
4419 | || (c) == 0x19 /* U+19 EOM */ \ | |
4420 | || ((c) <= 0x1F && (c) >= 0x1C) /* [FGRU]S */ \ | |
4421 | || (c) == 0x26 /* U+17 ETB */ \ | |
4422 | || (c) == 0x27 /* U+1B ESC */ \ | |
4423 | || (c) == 0x2D /* U+05 ENQ */ \ | |
4424 | || (c) == 0x2E /* U+06 ACK */ \ | |
4425 | || (c) == 0x32 /* U+16 SYN */ \ | |
4426 | || (c) == 0x37 /* U+04 EOT */ \ | |
4427 | || (c) == 0x3C /* U+14 DC4 */ \ | |
4428 | || (c) == 0x3D /* U+15 NAK */ \ | |
4429 | || (c) == 0x3F /* U+1A SUB */ \ | |
4430 | ) | |
4431 | #endif | |
4432 | ||
4433 | /* The ordering of the tests in this and isUPPER are to exclude most characters | |
4434 | * early */ | |
4435 | #ifndef isLOWER | |
4436 | # define isLOWER(c) ( (c) >= 'a' && (c) <= 'z' \ | |
4437 | && ( (c) <= 'i' \ | |
4438 | || ((c) >= 'j' && (c) <= 'r') \ | |
4439 | || (c) >= 's')) | |
4440 | #endif | |
4441 | ||
4442 | #ifndef isUPPER | |
4443 | # define isUPPER(c) ( (c) >= 'A' && (c) <= 'Z' \ | |
4444 | && ( (c) <= 'I' \ | |
4445 | || ((c) >= 'J' && (c) <= 'R') \ | |
4446 | || (c) >= 'S')) | |
4447 | #endif | |
4448 | ||
4449 | #else /* Above is EBCDIC; below is ASCII */ | |
4450 | ||
4451 | # if (PERL_BCDVERSION < 0x5004000) | |
4452 | /* The implementation of these in older perl versions can give wrong results if | |
4453 | * the C program locale is set to other than the C locale */ | |
4454 | # undef isALNUM | |
4455 | # undef isALNUM_A | |
4456 | # undef isALPHA | |
4457 | # undef isALPHA_A | |
4458 | # undef isDIGIT | |
4459 | # undef isDIGIT_A | |
4460 | # undef isIDFIRST | |
4461 | # undef isIDFIRST_A | |
4462 | # undef isLOWER | |
4463 | # undef isLOWER_A | |
4464 | # undef isUPPER | |
4465 | # undef isUPPER_A | |
4466 | # endif | |
4467 | ||
4468 | # if (PERL_BCDVERSION < 0x5008000) | |
4469 | /* Hint: isCNTRL | |
4470 | * Earlier perls omitted DEL */ | |
4471 | # undef isCNTRL | |
4472 | # endif | |
4473 | ||
4582 | 4474 | # if (PERL_BCDVERSION < 0x5010000) |
4583 | 4475 | /* Hint: isPRINT |
4584 | 4476 | * The implementation in older perl versions includes all of the |
4586 | 4478 | * Devel::PPPort always overrides a present buggy version. |
4587 | 4479 | */ |
4588 | 4480 | # undef isPRINT |
4481 | # undef isPRINT_A | |
4589 | 4482 | # endif |
4590 | 4483 | |
4591 | #ifdef HAS_QUAD | |
4592 | # ifdef U64TYPE | |
4593 | # define WIDEST_UTYPE U64TYPE | |
4594 | # else | |
4595 | # define WIDEST_UTYPE Quad_t | |
4484 | # if (PERL_BCDVERSION < 0x5014000) | |
4485 | /* Hint: isASCII | |
4486 | * The implementation in older perl versions always returned true if the | |
4487 | * parameter was a signed char | |
4488 | */ | |
4489 | # undef isASCII | |
4490 | # undef isASCII_A | |
4596 | 4491 | # endif |
4597 | #else | |
4598 | # define WIDEST_UTYPE U32 | |
4599 | #endif | |
4600 | #ifndef isALNUMC | |
4601 | # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) | |
4602 | #endif | |
4603 | ||
4492 | ||
4493 | # if (PERL_BCDVERSION < 0x5020000) | |
4494 | /* Hint: isSPACE | |
4495 | * The implementation in older perl versions didn't include \v */ | |
4496 | # undef isSPACE | |
4497 | # undef isSPACE_A | |
4498 | # endif | |
4604 | 4499 | #ifndef isASCII |
4605 | 4500 | # define isASCII(c) ((WIDEST_UTYPE) (c) <= 127) |
4606 | 4501 | #endif |
4609 | 4504 | # define isCNTRL(c) ((WIDEST_UTYPE) (c) < ' ' || (c) == 127) |
4610 | 4505 | #endif |
4611 | 4506 | |
4507 | #ifndef isLOWER | |
4508 | # define isLOWER(c) ((c) >= 'a' && (c) <= 'z') | |
4509 | #endif | |
4510 | ||
4511 | #ifndef isUPPER | |
4512 | # define isUPPER(c) ((c) <= 'Z' && (c) >= 'A') | |
4513 | #endif | |
4514 | ||
4515 | #endif /* Below are definitions common to EBCDIC and ASCII */ | |
4516 | #ifndef isALNUM | |
4517 | # define isALNUM(c) isWORDCHAR(c) | |
4518 | #endif | |
4519 | ||
4520 | #ifndef isALNUMC | |
4521 | # define isALNUMC(c) isALPHANUMERIC(c) | |
4522 | #endif | |
4523 | ||
4524 | #ifndef isALPHA | |
4525 | # define isALPHA(c) (isUPPER(c) || isLOWER(c)) | |
4526 | #endif | |
4527 | ||
4528 | #ifndef isALPHANUMERIC | |
4529 | # define isALPHANUMERIC(c) (isALPHA(c) || isDIGIT(c)) | |
4530 | #endif | |
4531 | ||
4532 | #ifndef isBLANK | |
4533 | # define isBLANK(c) ((c) == ' ' || (c) == '\t') | |
4534 | #endif | |
4535 | ||
4536 | #ifndef isDIGIT | |
4537 | # define isDIGIT(c) ((c) <= '9' && (c) >= '0') | |
4538 | #endif | |
4539 | ||
4612 | 4540 | #ifndef isGRAPH |
4613 | # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) | |
4541 | # define isGRAPH(c) (isWORDCHAR(c) || isPUNCT(c)) | |
4542 | #endif | |
4543 | ||
4544 | #ifndef isIDCONT | |
4545 | # define isIDCONT(c) isWORDCHAR(c) | |
4546 | #endif | |
4547 | ||
4548 | #ifndef isIDFIRST | |
4549 | # define isIDFIRST(c) (isALPHA(c) || (c) == '_') | |
4550 | #endif | |
4551 | ||
4552 | #ifndef isOCTAL | |
4553 | # define isOCTAL(c) (((WIDEST_UTYPE)((c)) & ~7) == '0') | |
4614 | 4554 | #endif |
4615 | 4555 | |
4616 | 4556 | #ifndef isPRINT |
4617 | # define isPRINT(c) (((c) >= 32 && (c) < 127)) | |
4557 | # define isPRINT(c) (isGRAPH(c) || (c) == ' ') | |
4558 | #endif | |
4559 | ||
4560 | #ifndef isPSXSPC | |
4561 | # define isPSXSPC(c) isSPACE(c) | |
4618 | 4562 | #endif |
4619 | 4563 | |
4620 | 4564 | #ifndef isPUNCT |
4621 | # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) | |
4565 | # define isPUNCT(c) ( (c) == '-' || (c) == '!' || (c) == '"' \ | |
4566 | || (c) == '#' || (c) == '$' || (c) == '%' \ | |
4567 | || (c) == '&' || (c) == '\'' || (c) == '(' \ | |
4568 | || (c) == ')' || (c) == '*' || (c) == '+' \ | |
4569 | || (c) == ',' || (c) == '.' || (c) == '/' \ | |
4570 | || (c) == ':' || (c) == ';' || (c) == '<' \ | |
4571 | || (c) == '=' || (c) == '>' || (c) == '?' \ | |
4572 | || (c) == '@' || (c) == '[' || (c) == '\\' \ | |
4573 | || (c) == ']' || (c) == '^' || (c) == '_' \ | |
4574 | || (c) == '`' || (c) == '{' || (c) == '|' \ | |
4575 | || (c) == '}' || (c) == '~') | |
4576 | #endif | |
4577 | ||
4578 | #ifndef isSPACE | |
4579 | # define isSPACE(c) ( isBLANK(c) || (c) == '\n' || (c) == '\r' \ | |
4580 | || (c) == '\v' || (c) == '\f') | |
4581 | #endif | |
4582 | ||
4583 | #ifndef isWORDCHAR | |
4584 | # define isWORDCHAR(c) (isALPHANUMERIC(c) || (c) == '_') | |
4622 | 4585 | #endif |
4623 | 4586 | |
4624 | 4587 | #ifndef isXDIGIT |
4625 | # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) | |
4626 | #endif | |
4627 | ||
4588 | # define isXDIGIT(c) ( isDIGIT(c) \ | |
4589 | || ((c) >= 'a' && (c) <= 'f') \ | |
4590 | || ((c) >= 'A' && (c) <= 'F')) | |
4591 | #endif | |
4592 | #ifndef isALNUM_A | |
4593 | # define isALNUM_A isALNUM | |
4594 | #endif | |
4595 | ||
4596 | #ifndef isALNUMC_A | |
4597 | # define isALNUMC_A isALNUMC | |
4598 | #endif | |
4599 | ||
4600 | #ifndef isALPHA_A | |
4601 | # define isALPHA_A isALPHA | |
4602 | #endif | |
4603 | ||
4604 | #ifndef isALPHANUMERIC_A | |
4605 | # define isALPHANUMERIC_A isALPHANUMERIC | |
4606 | #endif | |
4607 | ||
4608 | #ifndef isASCII_A | |
4609 | # define isASCII_A isASCII | |
4610 | #endif | |
4611 | ||
4612 | #ifndef isBLANK_A | |
4613 | # define isBLANK_A isBLANK | |
4614 | #endif | |
4615 | ||
4616 | #ifndef isCNTRL_A | |
4617 | # define isCNTRL_A isCNTRL | |
4618 | #endif | |
4619 | ||
4620 | #ifndef isDIGIT_A | |
4621 | # define isDIGIT_A isDIGIT | |
4622 | #endif | |
4623 | ||
4624 | #ifndef isGRAPH_A | |
4625 | # define isGRAPH_A isGRAPH | |
4626 | #endif | |
4627 | ||
4628 | #ifndef isIDCONT_A | |
4629 | # define isIDCONT_A isIDCONT | |
4630 | #endif | |
4631 | ||
4632 | #ifndef isIDFIRST_A | |
4633 | # define isIDFIRST_A isIDFIRST | |
4634 | #endif | |
4635 | ||
4636 | #ifndef isLOWER_A | |
4637 | # define isLOWER_A isLOWER | |
4638 | #endif | |
4639 | ||
4640 | #ifndef isOCTAL_A | |
4641 | # define isOCTAL_A isOCTAL | |
4642 | #endif | |
4643 | ||
4644 | #ifndef isPRINT_A | |
4645 | # define isPRINT_A isPRINT | |
4646 | #endif | |
4647 | ||
4648 | #ifndef isPSXSPC_A | |
4649 | # define isPSXSPC_A isPSXSPC | |
4650 | #endif | |
4651 | ||
4652 | #ifndef isPUNCT_A | |
4653 | # define isPUNCT_A isPUNCT | |
4654 | #endif | |
4655 | ||
4656 | #ifndef isSPACE_A | |
4657 | # define isSPACE_A isSPACE | |
4658 | #endif | |
4659 | ||
4660 | #ifndef isUPPER_A | |
4661 | # define isUPPER_A isUPPER | |
4662 | #endif | |
4663 | ||
4664 | #ifndef isWORDCHAR_A | |
4665 | # define isWORDCHAR_A isWORDCHAR | |
4666 | #endif | |
4667 | ||
4668 | #ifndef isXDIGIT_A | |
4669 | # define isXDIGIT_A isXDIGIT | |
4628 | 4670 | #endif |
4629 | 4671 | |
4630 | 4672 | /* Until we figure out how to support this in older perls... */ |
4642 | 4684 | |
4643 | 4685 | #ifndef C_ARRAY_END |
4644 | 4686 | # define C_ARRAY_END(a) ((a) + C_ARRAY_LENGTH(a)) |
4687 | #endif | |
4688 | #ifndef LIKELY | |
4689 | # define LIKELY(x) (x) | |
4690 | #endif | |
4691 | ||
4692 | #ifndef UNLIKELY | |
4693 | # define UNLIKELY(x) (x) | |
4694 | #endif | |
4695 | #ifndef UNICODE_REPLACEMENT | |
4696 | # define UNICODE_REPLACEMENT 0xFFFD | |
4697 | #endif | |
4698 | ||
4699 | #ifndef MUTABLE_PTR | |
4700 | #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) | |
4701 | # define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) | |
4702 | #else | |
4703 | # define MUTABLE_PTR(p) ((void *) (p)) | |
4704 | #endif | |
4705 | #endif | |
4706 | #ifndef MUTABLE_SV | |
4707 | # define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) | |
4708 | #endif | |
4709 | #ifndef WARN_ALL | |
4710 | # define WARN_ALL 0 | |
4711 | #endif | |
4712 | ||
4713 | #ifndef WARN_CLOSURE | |
4714 | # define WARN_CLOSURE 1 | |
4715 | #endif | |
4716 | ||
4717 | #ifndef WARN_DEPRECATED | |
4718 | # define WARN_DEPRECATED 2 | |
4719 | #endif | |
4720 | ||
4721 | #ifndef WARN_EXITING | |
4722 | # define WARN_EXITING 3 | |
4723 | #endif | |
4724 | ||
4725 | #ifndef WARN_GLOB | |
4726 | # define WARN_GLOB 4 | |
4727 | #endif | |
4728 | ||
4729 | #ifndef WARN_IO | |
4730 | # define WARN_IO 5 | |
4731 | #endif | |
4732 | ||
4733 | #ifndef WARN_CLOSED | |
4734 | # define WARN_CLOSED 6 | |
4735 | #endif | |
4736 | ||
4737 | #ifndef WARN_EXEC | |
4738 | # define WARN_EXEC 7 | |
4739 | #endif | |
4740 | ||
4741 | #ifndef WARN_LAYER | |
4742 | # define WARN_LAYER 8 | |
4743 | #endif | |
4744 | ||
4745 | #ifndef WARN_NEWLINE | |
4746 | # define WARN_NEWLINE 9 | |
4747 | #endif | |
4748 | ||
4749 | #ifndef WARN_PIPE | |
4750 | # define WARN_PIPE 10 | |
4751 | #endif | |
4752 | ||
4753 | #ifndef WARN_UNOPENED | |
4754 | # define WARN_UNOPENED 11 | |
4755 | #endif | |
4756 | ||
4757 | #ifndef WARN_MISC | |
4758 | # define WARN_MISC 12 | |
4759 | #endif | |
4760 | ||
4761 | #ifndef WARN_NUMERIC | |
4762 | # define WARN_NUMERIC 13 | |
4763 | #endif | |
4764 | ||
4765 | #ifndef WARN_ONCE | |
4766 | # define WARN_ONCE 14 | |
4767 | #endif | |
4768 | ||
4769 | #ifndef WARN_OVERFLOW | |
4770 | # define WARN_OVERFLOW 15 | |
4771 | #endif | |
4772 | ||
4773 | #ifndef WARN_PACK | |
4774 | # define WARN_PACK 16 | |
4775 | #endif | |
4776 | ||
4777 | #ifndef WARN_PORTABLE | |
4778 | # define WARN_PORTABLE 17 | |
4779 | #endif | |
4780 | ||
4781 | #ifndef WARN_RECURSION | |
4782 | # define WARN_RECURSION 18 | |
4783 | #endif | |
4784 | ||
4785 | #ifndef WARN_REDEFINE | |
4786 | # define WARN_REDEFINE 19 | |
4787 | #endif | |
4788 | ||
4789 | #ifndef WARN_REGEXP | |
4790 | # define WARN_REGEXP 20 | |
4791 | #endif | |
4792 | ||
4793 | #ifndef WARN_SEVERE | |
4794 | # define WARN_SEVERE 21 | |
4795 | #endif | |
4796 | ||
4797 | #ifndef WARN_DEBUGGING | |
4798 | # define WARN_DEBUGGING 22 | |
4799 | #endif | |
4800 | ||
4801 | #ifndef WARN_INPLACE | |
4802 | # define WARN_INPLACE 23 | |
4803 | #endif | |
4804 | ||
4805 | #ifndef WARN_INTERNAL | |
4806 | # define WARN_INTERNAL 24 | |
4807 | #endif | |
4808 | ||
4809 | #ifndef WARN_MALLOC | |
4810 | # define WARN_MALLOC 25 | |
4811 | #endif | |
4812 | ||
4813 | #ifndef WARN_SIGNAL | |
4814 | # define WARN_SIGNAL 26 | |
4815 | #endif | |
4816 | ||
4817 | #ifndef WARN_SUBSTR | |
4818 | # define WARN_SUBSTR 27 | |
4819 | #endif | |
4820 | ||
4821 | #ifndef WARN_SYNTAX | |
4822 | # define WARN_SYNTAX 28 | |
4823 | #endif | |
4824 | ||
4825 | #ifndef WARN_AMBIGUOUS | |
4826 | # define WARN_AMBIGUOUS 29 | |
4827 | #endif | |
4828 | ||
4829 | #ifndef WARN_BAREWORD | |
4830 | # define WARN_BAREWORD 30 | |
4831 | #endif | |
4832 | ||
4833 | #ifndef WARN_DIGIT | |
4834 | # define WARN_DIGIT 31 | |
4835 | #endif | |
4836 | ||
4837 | #ifndef WARN_PARENTHESIS | |
4838 | # define WARN_PARENTHESIS 32 | |
4839 | #endif | |
4840 | ||
4841 | #ifndef WARN_PRECEDENCE | |
4842 | # define WARN_PRECEDENCE 33 | |
4843 | #endif | |
4844 | ||
4845 | #ifndef WARN_PRINTF | |
4846 | # define WARN_PRINTF 34 | |
4847 | #endif | |
4848 | ||
4849 | #ifndef WARN_PROTOTYPE | |
4850 | # define WARN_PROTOTYPE 35 | |
4851 | #endif | |
4852 | ||
4853 | #ifndef WARN_QW | |
4854 | # define WARN_QW 36 | |
4855 | #endif | |
4856 | ||
4857 | #ifndef WARN_RESERVED | |
4858 | # define WARN_RESERVED 37 | |
4859 | #endif | |
4860 | ||
4861 | #ifndef WARN_SEMICOLON | |
4862 | # define WARN_SEMICOLON 38 | |
4863 | #endif | |
4864 | ||
4865 | #ifndef WARN_TAINT | |
4866 | # define WARN_TAINT 39 | |
4867 | #endif | |
4868 | ||
4869 | #ifndef WARN_THREADS | |
4870 | # define WARN_THREADS 40 | |
4871 | #endif | |
4872 | ||
4873 | #ifndef WARN_UNINITIALIZED | |
4874 | # define WARN_UNINITIALIZED 41 | |
4875 | #endif | |
4876 | ||
4877 | #ifndef WARN_UNPACK | |
4878 | # define WARN_UNPACK 42 | |
4879 | #endif | |
4880 | ||
4881 | #ifndef WARN_UNTIE | |
4882 | # define WARN_UNTIE 43 | |
4883 | #endif | |
4884 | ||
4885 | #ifndef WARN_UTF8 | |
4886 | # define WARN_UTF8 44 | |
4887 | #endif | |
4888 | ||
4889 | #ifndef WARN_VOID | |
4890 | # define WARN_VOID 45 | |
4891 | #endif | |
4892 | ||
4893 | #ifndef WARN_ASSERTIONS | |
4894 | # define WARN_ASSERTIONS 46 | |
4895 | #endif | |
4896 | #ifndef packWARN | |
4897 | # define packWARN(a) (a) | |
4898 | #endif | |
4899 | ||
4900 | #ifndef ckWARN | |
4901 | # ifdef G_WARN_ON | |
4902 | # define ckWARN(a) (PL_dowarn & G_WARN_ON) | |
4903 | # else | |
4904 | # define ckWARN(a) PL_dowarn | |
4905 | # endif | |
4906 | #endif | |
4907 | ||
4908 | #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) | |
4909 | #if defined(NEED_warner) | |
4910 | static void DPPP_(my_warner)(U32 err, const char *pat, ...); | |
4911 | static | |
4912 | #else | |
4913 | extern void DPPP_(my_warner)(U32 err, const char *pat, ...); | |
4914 | #endif | |
4915 | ||
4916 | #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) | |
4917 | ||
4918 | #define Perl_warner DPPP_(my_warner) | |
4919 | ||
4920 | ||
4921 | void | |
4922 | DPPP_(my_warner)(U32 err, const char *pat, ...) | |
4923 | { | |
4924 | SV *sv; | |
4925 | va_list args; | |
4926 | ||
4927 | PERL_UNUSED_ARG(err); | |
4928 | ||
4929 | va_start(args, pat); | |
4930 | sv = vnewSVpvf(pat, &args); | |
4931 | va_end(args); | |
4932 | sv_2mortal(sv); | |
4933 | warn("%s", SvPV_nolen(sv)); | |
4934 | } | |
4935 | ||
4936 | #define warner Perl_warner | |
4937 | ||
4938 | #define Perl_warner_nocontext Perl_warner | |
4939 | ||
4940 | #endif | |
4941 | #endif | |
4942 | ||
4943 | #define _ppport_MIN(a,b) (((a) <= (b)) ? (a) : (b)) | |
4944 | #ifndef sv_setuv | |
4945 | # define sv_setuv(sv, uv) \ | |
4946 | STMT_START { \ | |
4947 | UV TeMpUv = uv; \ | |
4948 | if (TeMpUv <= IV_MAX) \ | |
4949 | sv_setiv(sv, TeMpUv); \ | |
4950 | else \ | |
4951 | sv_setnv(sv, (double)TeMpUv); \ | |
4952 | } STMT_END | |
4953 | #endif | |
4954 | #ifndef newSVuv | |
4955 | # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) | |
4956 | #endif | |
4957 | #ifndef sv_2uv | |
4958 | # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) | |
4959 | #endif | |
4960 | ||
4961 | #ifndef SvUVX | |
4962 | # define SvUVX(sv) ((UV)SvIVX(sv)) | |
4963 | #endif | |
4964 | ||
4965 | #ifndef SvUVXx | |
4966 | # define SvUVXx(sv) SvUVX(sv) | |
4967 | #endif | |
4968 | ||
4969 | #ifndef SvUV | |
4970 | # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) | |
4971 | #endif | |
4972 | ||
4973 | #ifndef SvUVx | |
4974 | # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) | |
4975 | #endif | |
4976 | ||
4977 | /* Hint: sv_uv | |
4978 | * Always use the SvUVx() macro instead of sv_uv(). | |
4979 | */ | |
4980 | #ifndef sv_uv | |
4981 | # define sv_uv(sv) SvUVx(sv) | |
4982 | #endif | |
4983 | ||
4984 | #if !defined(SvUOK) && defined(SvIOK_UV) | |
4985 | # define SvUOK(sv) SvIOK_UV(sv) | |
4986 | #endif | |
4987 | #ifndef XST_mUV | |
4988 | # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) | |
4989 | #endif | |
4990 | ||
4991 | #ifndef XSRETURN_UV | |
4992 | # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END | |
4993 | #endif | |
4994 | #ifndef PUSHu | |
4995 | # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END | |
4996 | #endif | |
4997 | ||
4998 | #ifndef XPUSHu | |
4999 | # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END | |
5000 | #endif | |
5001 | ||
5002 | #if defined UTF8SKIP | |
5003 | ||
5004 | /* Don't use official version because it uses MIN, which may not be available */ | |
5005 | #undef UTF8_SAFE_SKIP | |
5006 | #ifndef UTF8_SAFE_SKIP | |
5007 | # define UTF8_SAFE_SKIP(s, e) ( \ | |
5008 | ((((e) - (s)) <= 0) \ | |
5009 | ? 0 \ | |
5010 | : _ppport_MIN(((e) - (s)), UTF8SKIP(s)))) | |
5011 | #endif | |
5012 | ||
5013 | #endif | |
5014 | ||
5015 | #if !defined(my_strnlen) | |
5016 | #if defined(NEED_my_strnlen) | |
5017 | static STRLEN DPPP_(my_my_strnlen)(const char *str, Size_t maxlen); | |
5018 | static | |
5019 | #else | |
5020 | extern STRLEN DPPP_(my_my_strnlen)(const char *str, Size_t maxlen); | |
5021 | #endif | |
5022 | ||
5023 | #if defined(NEED_my_strnlen) || defined(NEED_my_strnlen_GLOBAL) | |
5024 | ||
5025 | #define my_strnlen DPPP_(my_my_strnlen) | |
5026 | #define Perl_my_strnlen DPPP_(my_my_strnlen) | |
5027 | ||
5028 | ||
5029 | STRLEN | |
5030 | DPPP_(my_my_strnlen)(const char *str, Size_t maxlen) | |
5031 | { | |
5032 | const char *p = str; | |
5033 | ||
5034 | while(maxlen-- && *p) | |
5035 | p++; | |
5036 | ||
5037 | return p - str; | |
5038 | } | |
5039 | ||
5040 | #endif | |
5041 | #endif | |
5042 | ||
5043 | #if (PERL_BCDVERSION < 0x5031002) | |
5044 | /* Versions prior to this accepted things that are now considered | |
5045 | * malformations, and didn't return -1 on error with warnings enabled | |
5046 | * */ | |
5047 | # undef utf8_to_uvchr_buf | |
5048 | #endif | |
5049 | ||
5050 | /* This implementation brings modern, generally more restricted standards to | |
5051 | * utf8_to_uvchr_buf. Some of these are security related, and clearly must | |
5052 | * be done. But its arguable that the others need not, and hence should not. | |
5053 | * The reason they're here is that a module that intends to play with the | |
5054 | * latest perls shoud be able to work the same in all releases. An example is | |
5055 | * that perl no longer accepts any UV for a code point, but limits them to | |
5056 | * IV_MAX or below. This is for future internal use of the larger code points. | |
5057 | * If it turns out that some of these changes are breaking code that isn't | |
5058 | * intended to work with modern perls, the tighter restrictions could be | |
5059 | * relaxed. khw thinks this is unlikely, but has been wrong in the past. */ | |
5060 | ||
5061 | #ifndef utf8_to_uvchr_buf | |
5062 | /* Choose which underlying implementation to use. At least one must be | |
5063 | * present or the perl is too early to handle this function */ | |
5064 | # if defined(utf8n_to_uvchr) || defined(utf8_to_uv) | |
5065 | # if defined(utf8n_to_uvchr) /* This is the preferred implementation */ | |
5066 | # define _ppport_utf8_to_uvchr_buf_callee utf8n_to_uvchr | |
5067 | # else | |
5068 | # define _ppport_utf8_to_uvchr_buf_callee utf8_to_uv | |
5069 | # endif | |
5070 | ||
5071 | # endif | |
5072 | ||
5073 | #ifdef _ppport_utf8_to_uvchr_buf_callee | |
5074 | # if defined(NEED_utf8_to_uvchr_buf) | |
5075 | static UV DPPP_(my_utf8_to_uvchr_buf)(pTHX_ const U8 * s, const U8 * send, STRLEN * retlen); | |
5076 | static | |
5077 | #else | |
5078 | extern UV DPPP_(my_utf8_to_uvchr_buf)(pTHX_ const U8 * s, const U8 * send, STRLEN * retlen); | |
5079 | #endif | |
5080 | ||
5081 | #if defined(NEED_utf8_to_uvchr_buf) || defined(NEED_utf8_to_uvchr_buf_GLOBAL) | |
5082 | ||
5083 | #ifdef utf8_to_uvchr_buf | |
5084 | # undef utf8_to_uvchr_buf | |
5085 | #endif | |
5086 | #define utf8_to_uvchr_buf(a,b,c) DPPP_(my_utf8_to_uvchr_buf)(aTHX_ a,b,c) | |
5087 | #define Perl_utf8_to_uvchr_buf DPPP_(my_utf8_to_uvchr_buf) | |
5088 | ||
5089 | ||
5090 | UV | |
5091 | DPPP_(my_utf8_to_uvchr_buf)(pTHX_ const U8 *s, const U8 *send, STRLEN *retlen) | |
5092 | { | |
5093 | UV ret; | |
5094 | STRLEN curlen; | |
5095 | bool overflows = 0; | |
5096 | const U8 *cur_s = s; | |
5097 | const bool do_warnings = ckWARN_d(WARN_UTF8); | |
5098 | ||
5099 | if (send > s) { | |
5100 | curlen = send - s; | |
5101 | } | |
5102 | else { | |
5103 | assert(0); /* Modern perls die under this circumstance */ | |
5104 | curlen = 0; | |
5105 | if (! do_warnings) { /* Handle empty here if no warnings needed */ | |
5106 | if (retlen) *retlen = 0; | |
5107 | return UNICODE_REPLACEMENT; | |
5108 | } | |
5109 | } | |
5110 | ||
5111 | /* The modern version allows anything that evaluates to a legal UV, but not | |
5112 | * overlongs nor an empty input */ | |
5113 | ret = _ppport_utf8_to_uvchr_buf_callee( | |
5114 | s, curlen, retlen, (UTF8_ALLOW_ANYUV | |
5115 | & ~(UTF8_ALLOW_LONG|UTF8_ALLOW_EMPTY))); | |
5116 | ||
5117 | /* But actually, modern versions restrict the UV to being no more than what | |
5118 | * an IV can hold */ | |
5119 | if (ret > PERL_INT_MAX) { | |
5120 | overflows = 1; | |
5121 | } | |
5122 | ||
5123 | # if (PERL_BCDVERSION < 0x5026000) | |
5124 | # ifndef EBCDIC | |
5125 | ||
5126 | /* There are bugs in versions earlier than this on non-EBCDIC platforms | |
5127 | * in which it did not detect all instances of overflow, which could be | |
5128 | * a security hole. Also, earlier versions did not allow the overflow | |
5129 | * malformation under any circumstances, and modern ones do. So we | |
5130 | * need to check here. */ | |
5131 | ||
5132 | else if (curlen > 0 && *s >= 0xFE) { | |
5133 | ||
5134 | /* If the main routine detected overflow, great; it returned 0. But if the | |
5135 | * input's first byte indicates it could overflow, we need to verify. | |
5136 | * First, on a 32-bit machine the first byte being at least \xFE | |
5137 | * automatically is overflow */ | |
5138 | if (sizeof(ret) < 8) { | |
5139 | overflows = 1; | |
5140 | } | |
5141 | else { | |
5142 | const U8 highest[] = /* 2*63-1 */ | |
5143 | "\xFF\x80\x87\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF"; | |
5144 | const U8 *cur_h = highest; | |
5145 | ||
5146 | for (cur_s = s; cur_s < send; cur_s++, cur_h++) { | |
5147 | if (UNLIKELY(*cur_s == *cur_h)) { | |
5148 | continue; | |
5149 | } | |
5150 | ||
5151 | /* If this byte is larger than the corresponding highest UTF-8 | |
5152 | * byte, the sequence overflows; otherwise the byte is less than | |
5153 | * (as we handled the equality case above), and so the sequence | |
5154 | * doesn't overflow */ | |
5155 | overflows = *cur_s > *cur_h; | |
5156 | break; | |
5157 | ||
5158 | } | |
5159 | ||
5160 | /* Here, either we set the bool and broke out of the loop, or got | |
5161 | * to the end and all bytes are the same which indicates it doesn't | |
5162 | * overflow. */ | |
5163 | } | |
5164 | } | |
5165 | ||
5166 | # endif | |
5167 | # endif /* < 5.26 */ | |
5168 | ||
5169 | if (UNLIKELY(overflows)) { | |
5170 | if (! do_warnings) { | |
5171 | if (retlen) { | |
5172 | *retlen = _ppport_MIN(*retlen, UTF8SKIP(s)); | |
5173 | *retlen = _ppport_MIN(*retlen, curlen); | |
5174 | } | |
5175 | return UNICODE_REPLACEMENT; | |
5176 | } | |
5177 | else { | |
5178 | ||
5179 | /* On versions that correctly detect overflow, but forbid it | |
5180 | * always, 0 will be returned, but also a warning will have been | |
5181 | * raised. Don't repeat it */ | |
5182 | if (ret != 0) { | |
5183 | /* We use the error message in use from 5.8-5.14 */ | |
5184 | Perl_warner(aTHX_ packWARN(WARN_UTF8), | |
5185 | "Malformed UTF-8 character (overflow at 0x%" UVxf | |
5186 | ", byte 0x%02x, after start byte 0x%02x)", | |
5187 | ret, *cur_s, *s); | |
5188 | } | |
5189 | if (retlen) { | |
5190 | *retlen = (STRLEN) -1; | |
5191 | } | |
5192 | return 0; | |
5193 | } | |
5194 | } | |
5195 | ||
5196 | /* If failed and warnings are off, to emulate the behavior of the real | |
5197 | * utf8_to_uvchr(), try again, allowing anything. (Note a return of 0 is | |
5198 | * ok if the input was '\0') */ | |
5199 | if (UNLIKELY(ret == 0 && (curlen == 0 || *s != '\0'))) { | |
5200 | ||
5201 | /* If curlen is 0, we already handled the case where warnings are | |
5202 | * disabled, so this 'if' will be true, and we won't look at the | |
5203 | * contents of 's' */ | |
5204 | if (do_warnings) { | |
5205 | *retlen = (STRLEN) -1; | |
5206 | } | |
5207 | else { | |
5208 | ret = _ppport_utf8_to_uvchr_buf_callee( | |
5209 | s, curlen, retlen, UTF8_ALLOW_ANY); | |
5210 | /* Override with the REPLACEMENT character, as that is what the | |
5211 | * modern version of this function returns */ | |
5212 | ret = UNICODE_REPLACEMENT; | |
5213 | ||
5214 | # if (PERL_BCDVERSION < 0x5016000) | |
5215 | ||
5216 | /* Versions earlier than this don't necessarily return the proper | |
5217 | * length. It should not extend past the end of string, nor past | |
5218 | * what the first byte indicates the length is, nor past the | |
5219 | * continuation characters */ | |
5220 | if (retlen && *retlen >= 0) { | |
5221 | *retlen = _ppport_MIN(*retlen, curlen); | |
5222 | *retlen = _ppport_MIN(*retlen, UTF8SKIP(s)); | |
5223 | unsigned int i = 1; | |
5224 | do { | |
5225 | if (s[i] < 0x80 || s[i] > 0xBF) { | |
5226 | *retlen = i; | |
5227 | break; | |
5228 | } | |
5229 | } while (++i < *retlen); | |
5230 | } | |
5231 | ||
5232 | # endif | |
5233 | ||
5234 | } | |
5235 | } | |
5236 | ||
5237 | return ret; | |
5238 | } | |
5239 | ||
5240 | # endif | |
5241 | #endif | |
5242 | #endif | |
5243 | ||
5244 | #if defined(UTF8SKIP) && defined(utf8_to_uvchr_buf) | |
5245 | #undef utf8_to_uvchr /* Always redefine this unsafe function so that it refuses | |
5246 | to read past a NUL, making it much less likely to read | |
5247 | off the end of the buffer. A NUL indicates the start | |
5248 | of the next character anyway. If the input isn't | |
5249 | NUL-terminated, the function remains unsafe, as it | |
5250 | always has been. */ | |
5251 | #ifndef utf8_to_uvchr | |
5252 | # define utf8_to_uvchr(s, lp) \ | |
5253 | ((*(s) == '\0') \ | |
5254 | ? utf8_to_uvchr_buf(s,((s)+1), lp) /* Handle single NUL specially */ \ | |
5255 | : utf8_to_uvchr_buf(s, (s) + my_strnlen((char *) (s), UTF8SKIP(s)), (lp))) | |
5256 | #endif | |
5257 | ||
5258 | #endif | |
5259 | ||
5260 | #ifdef HAS_MEMCMP | |
5261 | #ifndef memNE | |
5262 | # define memNE(s1,s2,l) (memcmp(s1,s2,l)) | |
5263 | #endif | |
5264 | ||
5265 | #ifndef memEQ | |
5266 | # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) | |
5267 | #endif | |
5268 | ||
5269 | #else | |
5270 | #ifndef memNE | |
5271 | # define memNE(s1,s2,l) (bcmp(s1,s2,l)) | |
5272 | #endif | |
5273 | ||
5274 | #ifndef memEQ | |
5275 | # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) | |
5276 | #endif | |
5277 | ||
5278 | #endif | |
5279 | #ifndef memEQs | |
5280 | # define memEQs(s1, l, s2) \ | |
5281 | (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) | |
5282 | #endif | |
5283 | ||
5284 | #ifndef memNEs | |
5285 | # define memNEs(s1, l, s2) !memEQs(s1, l, s2) | |
5286 | #endif | |
5287 | #ifndef MoveD | |
5288 | # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) | |
5289 | #endif | |
5290 | ||
5291 | #ifndef CopyD | |
5292 | # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) | |
5293 | #endif | |
5294 | ||
5295 | #ifdef HAS_MEMSET | |
5296 | #ifndef ZeroD | |
5297 | # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) | |
5298 | #endif | |
5299 | ||
5300 | #else | |
5301 | #ifndef ZeroD | |
5302 | # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) | |
5303 | #endif | |
5304 | ||
5305 | #endif | |
5306 | #ifndef PoisonWith | |
5307 | # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) | |
5308 | #endif | |
5309 | ||
5310 | #ifndef PoisonNew | |
5311 | # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) | |
5312 | #endif | |
5313 | ||
5314 | #ifndef PoisonFree | |
5315 | # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) | |
5316 | #endif | |
5317 | ||
5318 | #ifndef Poison | |
5319 | # define Poison(d,n,t) PoisonFree(d,n,t) | |
5320 | #endif | |
5321 | #ifndef Newx | |
5322 | # define Newx(v,n,t) New(0,v,n,t) | |
5323 | #endif | |
5324 | ||
5325 | #ifndef Newxc | |
5326 | # define Newxc(v,n,t,c) Newc(0,v,n,t,c) | |
5327 | #endif | |
5328 | ||
5329 | #ifndef Newxz | |
5330 | # define Newxz(v,n,t) Newz(0,v,n,t) | |
5331 | #endif | |
5332 | #ifndef PERL_MAGIC_sv | |
5333 | # define PERL_MAGIC_sv '\0' | |
5334 | #endif | |
5335 | ||
5336 | #ifndef PERL_MAGIC_overload | |
5337 | # define PERL_MAGIC_overload 'A' | |
5338 | #endif | |
5339 | ||
5340 | #ifndef PERL_MAGIC_overload_elem | |
5341 | # define PERL_MAGIC_overload_elem 'a' | |
5342 | #endif | |
5343 | ||
5344 | #ifndef PERL_MAGIC_overload_table | |
5345 | # define PERL_MAGIC_overload_table 'c' | |
5346 | #endif | |
5347 | ||
5348 | #ifndef PERL_MAGIC_bm | |
5349 | # define PERL_MAGIC_bm 'B' | |
5350 | #endif | |
5351 | ||
5352 | #ifndef PERL_MAGIC_regdata | |
5353 | # define PERL_MAGIC_regdata 'D' | |
5354 | #endif | |
5355 | ||
5356 | #ifndef PERL_MAGIC_regdatum | |
5357 | # define PERL_MAGIC_regdatum 'd' | |
5358 | #endif | |
5359 | ||
5360 | #ifndef PERL_MAGIC_env | |
5361 | # define PERL_MAGIC_env 'E' | |
5362 | #endif | |
5363 | ||
5364 | #ifndef PERL_MAGIC_envelem | |
5365 | # define PERL_MAGIC_envelem 'e' | |
5366 | #endif | |
5367 | ||
5368 | #ifndef PERL_MAGIC_fm | |
5369 | # define PERL_MAGIC_fm 'f' | |
5370 | #endif | |
5371 | ||
5372 | #ifndef PERL_MAGIC_regex_global | |
5373 | # define PERL_MAGIC_regex_global 'g' | |
5374 | #endif | |
5375 | ||
5376 | #ifndef PERL_MAGIC_isa | |
5377 | # define PERL_MAGIC_isa 'I' | |
5378 | #endif | |
5379 | ||
5380 | #ifndef PERL_MAGIC_isaelem | |
5381 | # define PERL_MAGIC_isaelem 'i' | |
5382 | #endif | |
5383 | ||
5384 | #ifndef PERL_MAGIC_nkeys | |
5385 | # define PERL_MAGIC_nkeys 'k' | |
5386 | #endif | |
5387 | ||
5388 | #ifndef PERL_MAGIC_dbfile | |
5389 | # define PERL_MAGIC_dbfile 'L' | |
5390 | #endif | |
5391 | ||
5392 | #ifndef PERL_MAGIC_dbline | |
5393 | # define PERL_MAGIC_dbline 'l' | |
5394 | #endif | |
5395 | ||
5396 | #ifndef PERL_MAGIC_mutex | |
5397 | # define PERL_MAGIC_mutex 'm' | |
5398 | #endif | |
5399 | ||
5400 | #ifndef PERL_MAGIC_shared | |
5401 | # define PERL_MAGIC_shared 'N' | |
5402 | #endif | |
5403 | ||
5404 | #ifndef PERL_MAGIC_shared_scalar | |
5405 | # define PERL_MAGIC_shared_scalar 'n' | |
5406 | #endif | |
5407 | ||
5408 | #ifndef PERL_MAGIC_collxfrm | |
5409 | # define PERL_MAGIC_collxfrm 'o' | |
5410 | #endif | |
5411 | ||
5412 | #ifndef PERL_MAGIC_tied | |
5413 | # define PERL_MAGIC_tied 'P' | |
5414 | #endif | |
5415 | ||
5416 | #ifndef PERL_MAGIC_tiedelem | |
5417 | # define PERL_MAGIC_tiedelem 'p' | |
5418 | #endif | |
5419 | ||
5420 | #ifndef PERL_MAGIC_tiedscalar | |
5421 | # define PERL_MAGIC_tiedscalar 'q' | |
5422 | #endif | |
5423 | ||
5424 | #ifndef PERL_MAGIC_qr | |
5425 | # define PERL_MAGIC_qr 'r' | |
5426 | #endif | |
5427 | ||
5428 | #ifndef PERL_MAGIC_sig | |
5429 | # define PERL_MAGIC_sig 'S' | |
5430 | #endif | |
5431 | ||
5432 | #ifndef PERL_MAGIC_sigelem | |
5433 | # define PERL_MAGIC_sigelem 's' | |
5434 | #endif | |
5435 | ||
5436 | #ifndef PERL_MAGIC_taint | |
5437 | # define PERL_MAGIC_taint 't' | |
5438 | #endif | |
5439 | ||
5440 | #ifndef PERL_MAGIC_uvar | |
5441 | # define PERL_MAGIC_uvar 'U' | |
5442 | #endif | |
5443 | ||
5444 | #ifndef PERL_MAGIC_uvar_elem | |
5445 | # define PERL_MAGIC_uvar_elem 'u' | |
5446 | #endif | |
5447 | ||
5448 | #ifndef PERL_MAGIC_vstring | |
5449 | # define PERL_MAGIC_vstring 'V' | |
5450 | #endif | |
5451 | ||
5452 | #ifndef PERL_MAGIC_vec | |
5453 | # define PERL_MAGIC_vec 'v' | |
5454 | #endif | |
5455 | ||
5456 | #ifndef PERL_MAGIC_utf8 | |
5457 | # define PERL_MAGIC_utf8 'w' | |
5458 | #endif | |
5459 | ||
5460 | #ifndef PERL_MAGIC_substr | |
5461 | # define PERL_MAGIC_substr 'x' | |
5462 | #endif | |
5463 | ||
5464 | #ifndef PERL_MAGIC_defelem | |
5465 | # define PERL_MAGIC_defelem 'y' | |
5466 | #endif | |
5467 | ||
5468 | #ifndef PERL_MAGIC_glob | |
5469 | # define PERL_MAGIC_glob '*' | |
5470 | #endif | |
5471 | ||
5472 | #ifndef PERL_MAGIC_arylen | |
5473 | # define PERL_MAGIC_arylen '#' | |
5474 | #endif | |
5475 | ||
5476 | #ifndef PERL_MAGIC_pos | |
5477 | # define PERL_MAGIC_pos '.' | |
5478 | #endif | |
5479 | ||
5480 | #ifndef PERL_MAGIC_backref | |
5481 | # define PERL_MAGIC_backref '<' | |
5482 | #endif | |
5483 | ||
5484 | #ifndef PERL_MAGIC_ext | |
5485 | # define PERL_MAGIC_ext '~' | |
5486 | #endif | |
5487 | ||
5488 | #ifdef NEED_mess_sv | |
5489 | #define NEED_mess | |
5490 | #endif | |
5491 | ||
5492 | #ifdef NEED_mess | |
5493 | #define NEED_mess_nocontext | |
5494 | #define NEED_vmess | |
5495 | #endif | |
5496 | ||
5497 | #ifndef croak_sv | |
5498 | #if (PERL_BCDVERSION >= 0x5007003) || ( (PERL_BCDVERSION >= 0x5006001) && (PERL_BCDVERSION < 0x5007000) ) | |
5499 | # if ( (PERL_BCDVERSION >= 0x5008000) && (PERL_BCDVERSION < 0x5008009) ) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5010001) ) | |
5500 | # define D_PPP_FIX_UTF8_ERRSV(errsv, sv) \ | |
5501 | STMT_START { \ | |
5502 | if (sv != errsv) \ | |
5503 | SvFLAGS(errsv) = (SvFLAGS(errsv) & ~SVf_UTF8) | \ | |
5504 | (SvFLAGS(sv) & SVf_UTF8); \ | |
5505 | } STMT_END | |
5506 | # else | |
5507 | # define D_PPP_FIX_UTF8_ERRSV(errsv, sv) STMT_START {} STMT_END | |
5508 | # endif | |
5509 | # define croak_sv(sv) \ | |
5510 | STMT_START { \ | |
5511 | if (SvROK(sv)) { \ | |
5512 | sv_setsv(ERRSV, sv); \ | |
5513 | croak(NULL); \ | |
5514 | } else { \ | |
5515 | D_PPP_FIX_UTF8_ERRSV(ERRSV, sv); \ | |
5516 | croak("%" SVf, SVfARG(sv)); \ | |
5517 | } \ | |
5518 | } STMT_END | |
5519 | #elif (PERL_BCDVERSION >= 0x5004000) | |
5520 | # define croak_sv(sv) croak("%" SVf, SVfARG(sv)) | |
5521 | #else | |
5522 | # define croak_sv(sv) croak("%s", SvPV_nolen(sv)) | |
5523 | #endif | |
5524 | #endif | |
5525 | ||
5526 | #ifndef die_sv | |
5527 | #if defined(NEED_die_sv) | |
5528 | static OP * DPPP_(my_die_sv)(pTHX_ SV *sv); | |
5529 | static | |
5530 | #else | |
5531 | extern OP * DPPP_(my_die_sv)(pTHX_ SV *sv); | |
5532 | #endif | |
5533 | ||
5534 | #if defined(NEED_die_sv) || defined(NEED_die_sv_GLOBAL) | |
5535 | ||
5536 | #ifdef die_sv | |
5537 | # undef die_sv | |
5538 | #endif | |
5539 | #define die_sv(a) DPPP_(my_die_sv)(aTHX_ a) | |
5540 | #define Perl_die_sv DPPP_(my_die_sv) | |
5541 | ||
5542 | OP * | |
5543 | DPPP_(my_die_sv)(pTHX_ SV *sv) | |
5544 | { | |
5545 | croak_sv(sv); | |
5546 | return (OP *)NULL; | |
5547 | } | |
5548 | #endif | |
5549 | #endif | |
5550 | ||
5551 | #ifndef warn_sv | |
5552 | #if (PERL_BCDVERSION >= 0x5004000) | |
5553 | # define warn_sv(sv) warn("%" SVf, SVfARG(sv)) | |
5554 | #else | |
5555 | # define warn_sv(sv) warn("%s", SvPV_nolen(sv)) | |
5556 | #endif | |
5557 | #endif | |
5558 | ||
5559 | #ifndef vmess | |
5560 | #if defined(NEED_vmess) | |
5561 | static SV * DPPP_(my_vmess)(pTHX_ const char * pat, va_list * args); | |
5562 | static | |
5563 | #else | |
5564 | extern SV * DPPP_(my_vmess)(pTHX_ const char * pat, va_list * args); | |
5565 | #endif | |
5566 | ||
5567 | #if defined(NEED_vmess) || defined(NEED_vmess_GLOBAL) | |
5568 | ||
5569 | #ifdef vmess | |
5570 | # undef vmess | |
5571 | #endif | |
5572 | #define vmess(a,b) DPPP_(my_vmess)(aTHX_ a,b) | |
5573 | #define Perl_vmess DPPP_(my_vmess) | |
5574 | ||
5575 | SV* | |
5576 | DPPP_(my_vmess)(pTHX_ const char* pat, va_list* args) | |
5577 | { | |
5578 | mess(pat, args); | |
5579 | return PL_mess_sv; | |
5580 | } | |
5581 | #endif | |
5582 | #endif | |
5583 | ||
5584 | #if (PERL_BCDVERSION < 0x5006000) | |
5585 | #undef mess | |
5586 | #endif | |
5587 | ||
5588 | #if !defined(mess_nocontext) && !defined(Perl_mess_nocontext) | |
5589 | #if defined(NEED_mess_nocontext) | |
5590 | static SV * DPPP_(my_mess_nocontext)(const char * pat, ...); | |
5591 | static | |
5592 | #else | |
5593 | extern SV * DPPP_(my_mess_nocontext)(const char * pat, ...); | |
5594 | #endif | |
5595 | ||
5596 | #if defined(NEED_mess_nocontext) || defined(NEED_mess_nocontext_GLOBAL) | |
5597 | ||
5598 | #define mess_nocontext DPPP_(my_mess_nocontext) | |
5599 | #define Perl_mess_nocontext DPPP_(my_mess_nocontext) | |
5600 | ||
5601 | SV* | |
5602 | DPPP_(my_mess_nocontext)(const char* pat, ...) | |
5603 | { | |
5604 | dTHX; | |
5605 | SV *sv; | |
5606 | va_list args; | |
5607 | va_start(args, pat); | |
5608 | sv = vmess(pat, &args); | |
5609 | va_end(args); | |
5610 | return sv; | |
5611 | } | |
5612 | #endif | |
5613 | #endif | |
5614 | ||
5615 | #ifndef mess | |
5616 | #if defined(NEED_mess) | |
5617 | static SV * DPPP_(my_mess)(pTHX_ const char * pat, ...); | |
5618 | static | |
5619 | #else | |
5620 | extern SV * DPPP_(my_mess)(pTHX_ const char * pat, ...); | |
5621 | #endif | |
5622 | ||
5623 | #if defined(NEED_mess) || defined(NEED_mess_GLOBAL) | |
5624 | ||
5625 | #define Perl_mess DPPP_(my_mess) | |
5626 | ||
5627 | SV* | |
5628 | DPPP_(my_mess)(pTHX_ const char* pat, ...) | |
5629 | { | |
5630 | SV *sv; | |
5631 | va_list args; | |
5632 | va_start(args, pat); | |
5633 | sv = vmess(pat, &args); | |
5634 | va_end(args); | |
5635 | return sv; | |
5636 | } | |
5637 | #ifdef mess_nocontext | |
5638 | #define mess mess_nocontext | |
5639 | #else | |
5640 | #define mess Perl_mess_nocontext | |
5641 | #endif | |
5642 | #endif | |
5643 | #endif | |
5644 | ||
5645 | #ifndef mess_sv | |
5646 | #if defined(NEED_mess_sv) | |
5647 | static SV * DPPP_(my_mess_sv)(pTHX_ SV * basemsg, bool consume); | |
5648 | static | |
5649 | #else | |
5650 | extern SV * DPPP_(my_mess_sv)(pTHX_ SV * basemsg, bool consume); | |
5651 | #endif | |
5652 | ||
5653 | #if defined(NEED_mess_sv) || defined(NEED_mess_sv_GLOBAL) | |
5654 | ||
5655 | #ifdef mess_sv | |
5656 | # undef mess_sv | |
5657 | #endif | |
5658 | #define mess_sv(a,b) DPPP_(my_mess_sv)(aTHX_ a,b) | |
5659 | #define Perl_mess_sv DPPP_(my_mess_sv) | |
5660 | ||
5661 | SV * | |
5662 | DPPP_(my_mess_sv)(pTHX_ SV *basemsg, bool consume) | |
5663 | { | |
5664 | SV *tmp; | |
5665 | SV *ret; | |
5666 | ||
5667 | if (SvPOK(basemsg) && SvCUR(basemsg) && *(SvEND(basemsg)-1) == '\n') { | |
5668 | if (consume) | |
5669 | return basemsg; | |
5670 | ret = mess(""); | |
5671 | SvSetSV_nosteal(ret, basemsg); | |
5672 | return ret; | |
5673 | } | |
5674 | ||
5675 | if (consume) { | |
5676 | sv_catsv(basemsg, mess("")); | |
5677 | return basemsg; | |
5678 | } | |
5679 | ||
5680 | ret = mess(""); | |
5681 | tmp = newSVsv(ret); | |
5682 | SvSetSV_nosteal(ret, basemsg); | |
5683 | sv_catsv(ret, tmp); | |
5684 | sv_dec(tmp); | |
5685 | return ret; | |
5686 | } | |
5687 | #endif | |
5688 | #endif | |
5689 | ||
5690 | #ifndef warn_nocontext | |
5691 | #define warn_nocontext warn | |
5692 | #endif | |
5693 | ||
5694 | #ifndef croak_nocontext | |
5695 | #define croak_nocontext croak | |
5696 | #endif | |
5697 | ||
5698 | #ifndef croak_no_modify | |
5699 | #define croak_no_modify() croak_nocontext("%s", PL_no_modify) | |
5700 | #define Perl_croak_no_modify() croak_no_modify() | |
5701 | #endif | |
5702 | ||
5703 | #ifndef croak_memory_wrap | |
5704 | #if (PERL_BCDVERSION >= 0x5009002) || ( (PERL_BCDVERSION >= 0x5008006) && (PERL_BCDVERSION < 0x5009000) ) | |
5705 | # define croak_memory_wrap() croak_nocontext("%s", PL_memory_wrap) | |
5706 | #else | |
5707 | # define croak_memory_wrap() croak_nocontext("panic: memory wrap") | |
5708 | #endif | |
5709 | #endif | |
5710 | ||
5711 | #ifndef croak_xs_usage | |
5712 | #if defined(NEED_croak_xs_usage) | |
5713 | static void DPPP_(my_croak_xs_usage)(const CV * const cv, const char * const params); | |
5714 | static | |
5715 | #else | |
5716 | extern void DPPP_(my_croak_xs_usage)(const CV * const cv, const char * const params); | |
5717 | #endif | |
5718 | ||
5719 | #if defined(NEED_croak_xs_usage) || defined(NEED_croak_xs_usage_GLOBAL) | |
5720 | ||
5721 | #define croak_xs_usage DPPP_(my_croak_xs_usage) | |
5722 | #define Perl_croak_xs_usage DPPP_(my_croak_xs_usage) | |
5723 | ||
5724 | ||
5725 | #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE | |
5726 | #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) | |
5727 | #endif | |
5728 | ||
5729 | void | |
5730 | DPPP_(my_croak_xs_usage)(const CV *const cv, const char *const params) | |
5731 | { | |
5732 | dTHX; | |
5733 | const GV *const gv = CvGV(cv); | |
5734 | ||
5735 | PERL_ARGS_ASSERT_CROAK_XS_USAGE; | |
5736 | ||
5737 | if (gv) { | |
5738 | const char *const gvname = GvNAME(gv); | |
5739 | const HV *const stash = GvSTASH(gv); | |
5740 | const char *const hvname = stash ? HvNAME(stash) : NULL; | |
5741 | ||
5742 | if (hvname) | |
5743 | croak("Usage: %s::%s(%s)", hvname, gvname, params); | |
5744 | else | |
5745 | croak("Usage: %s(%s)", gvname, params); | |
5746 | } else { | |
5747 | /* Pants. I don't think that it should be possible to get here. */ | |
5748 | croak("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); | |
5749 | } | |
5750 | } | |
5751 | #endif | |
4645 | 5752 | #endif |
4646 | 5753 | |
4647 | 5754 | #ifndef PERL_SIGNALS_UNSAFE_FLAG |
4900 | 6007 | extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); |
4901 | 6008 | #endif |
4902 | 6009 | |
6010 | #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) | |
6011 | ||
4903 | 6012 | #ifdef eval_pv |
4904 | 6013 | # undef eval_pv |
4905 | 6014 | #endif |
4906 | 6015 | #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) |
4907 | 6016 | #define Perl_eval_pv DPPP_(my_eval_pv) |
4908 | 6017 | |
4909 | #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) | |
4910 | 6018 | |
4911 | 6019 | SV* |
4912 | 6020 | DPPP_(my_eval_pv)(char *p, I32 croak_on_error) |
4922 | 6030 | sv = POPs; |
4923 | 6031 | PUTBACK; |
4924 | 6032 | |
4925 | if (croak_on_error && SvTRUE(GvSV(errgv))) | |
4926 | croak(SvPVx(GvSV(errgv), na)); | |
6033 | if (croak_on_error && SvTRUEx(ERRSV)) | |
6034 | croak_sv(ERRSV); | |
4927 | 6035 | |
4928 | 6036 | return sv; |
4929 | 6037 | } |
4939 | 6047 | extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); |
4940 | 6048 | #endif |
4941 | 6049 | |
6050 | #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) | |
6051 | ||
4942 | 6052 | #ifdef vload_module |
4943 | 6053 | # undef vload_module |
4944 | 6054 | #endif |
4945 | 6055 | #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) |
4946 | 6056 | #define Perl_vload_module DPPP_(my_vload_module) |
4947 | 6057 | |
4948 | #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) | |
4949 | 6058 | |
4950 | 6059 | void |
4951 | 6060 | DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) |
5014 | 6123 | extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); |
5015 | 6124 | #endif |
5016 | 6125 | |
6126 | #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) | |
6127 | ||
5017 | 6128 | #ifdef load_module |
5018 | 6129 | # undef load_module |
5019 | 6130 | #endif |
5020 | 6131 | #define load_module DPPP_(my_load_module) |
5021 | 6132 | #define Perl_load_module DPPP_(my_load_module) |
5022 | 6133 | |
5023 | #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) | |
5024 | 6134 | |
5025 | 6135 | void |
5026 | 6136 | DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) |
5045 | 6155 | extern SV * DPPP_(my_newRV_noinc)(SV *sv); |
5046 | 6156 | #endif |
5047 | 6157 | |
6158 | #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) | |
6159 | ||
5048 | 6160 | #ifdef newRV_noinc |
5049 | 6161 | # undef newRV_noinc |
5050 | 6162 | #endif |
5051 | 6163 | #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) |
5052 | 6164 | #define Perl_newRV_noinc DPPP_(my_newRV_noinc) |
5053 | 6165 | |
5054 | #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) | |
5055 | 6166 | SV * |
5056 | 6167 | DPPP_(my_newRV_noinc)(SV *sv) |
5057 | 6168 | { |
5076 | 6187 | extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); |
5077 | 6188 | #endif |
5078 | 6189 | |
6190 | #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) | |
6191 | ||
5079 | 6192 | #ifdef newCONSTSUB |
5080 | 6193 | # undef newCONSTSUB |
5081 | 6194 | #endif |
5082 | 6195 | #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) |
5083 | 6196 | #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) |
5084 | 6197 | |
5085 | #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) | |
5086 | 6198 | |
5087 | 6199 | /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ |
5088 | 6200 | /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ |
5341 | 6453 | extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); |
5342 | 6454 | #endif |
5343 | 6455 | |
6456 | #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) | |
6457 | ||
5344 | 6458 | #ifdef newSV_type |
5345 | 6459 | # undef newSV_type |
5346 | 6460 | #endif |
5347 | 6461 | #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) |
5348 | 6462 | #define Perl_newSV_type DPPP_(my_newSV_type) |
5349 | 6463 | |
5350 | #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) | |
5351 | 6464 | |
5352 | 6465 | SV* |
5353 | 6466 | DPPP_(my_newSV_type)(pTHX_ svtype const t) |
5387 | 6500 | extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); |
5388 | 6501 | #endif |
5389 | 6502 | |
6503 | #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) | |
6504 | ||
5390 | 6505 | #ifdef newSVpvn_flags |
5391 | 6506 | # undef newSVpvn_flags |
5392 | 6507 | #endif |
5393 | 6508 | #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) |
5394 | 6509 | #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) |
5395 | 6510 | |
5396 | #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) | |
5397 | 6511 | |
5398 | 6512 | SV * |
5399 | 6513 | DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) |
5438 | 6552 | extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); |
5439 | 6553 | #endif |
5440 | 6554 | |
6555 | #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) | |
6556 | ||
5441 | 6557 | #ifdef sv_2pvbyte |
5442 | 6558 | # undef sv_2pvbyte |
5443 | 6559 | #endif |
5444 | 6560 | #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) |
5445 | 6561 | #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) |
5446 | 6562 | |
5447 | #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) | |
5448 | 6563 | |
5449 | 6564 | char * |
5450 | 6565 | DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) |
5535 | 6650 | extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); |
5536 | 6651 | #endif |
5537 | 6652 | |
6653 | #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) | |
6654 | ||
5538 | 6655 | #ifdef sv_2pv_flags |
5539 | 6656 | # undef sv_2pv_flags |
5540 | 6657 | #endif |
5541 | 6658 | #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) |
5542 | 6659 | #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) |
5543 | 6660 | |
5544 | #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) | |
5545 | 6661 | |
5546 | 6662 | char * |
5547 | 6663 | DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) |
5559 | 6675 | extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); |
5560 | 6676 | #endif |
5561 | 6677 | |
6678 | #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) | |
6679 | ||
5562 | 6680 | #ifdef sv_pvn_force_flags |
5563 | 6681 | # undef sv_pvn_force_flags |
5564 | 6682 | #endif |
5565 | 6683 | #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) |
5566 | 6684 | #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) |
5567 | 6685 | |
5568 | #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) | |
5569 | 6686 | |
5570 | 6687 | char * |
5571 | 6688 | DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) |
5579 | 6696 | #endif |
5580 | 6697 | |
5581 | 6698 | #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) |
5582 | # define DPPP_SVPV_NOLEN_LP_ARG &PL_na | |
6699 | # define D_PPP_SVPV_NOLEN_LP_ARG &PL_na | |
5583 | 6700 | #else |
5584 | # define DPPP_SVPV_NOLEN_LP_ARG 0 | |
6701 | # define D_PPP_SVPV_NOLEN_LP_ARG 0 | |
5585 | 6702 | #endif |
5586 | 6703 | #ifndef SvPV_const |
5587 | 6704 | # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) |
5605 | 6722 | # define SvPV_flags_const_nolen(sv, flags) \ |
5606 | 6723 | ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ |
5607 | 6724 | ? SvPVX_const(sv) : \ |
5608 | (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) | |
6725 | (const char*) sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) | |
5609 | 6726 | #endif |
5610 | 6727 | #ifndef SvPV_flags_mutable |
5611 | 6728 | # define SvPV_flags_mutable(sv, lp, flags) \ |
5640 | 6757 | #ifndef SvPV_force_flags_nolen |
5641 | 6758 | # define SvPV_force_flags_nolen(sv, flags) \ |
5642 | 6759 | ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ |
5643 | ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) | |
6760 | ? SvPVX(sv) : sv_pvn_force_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags)) | |
5644 | 6761 | #endif |
5645 | 6762 | #ifndef SvPV_force_flags_mutable |
5646 | 6763 | # define SvPV_force_flags_mutable(sv, lp, flags) \ |
5651 | 6768 | #ifndef SvPV_nolen |
5652 | 6769 | # define SvPV_nolen(sv) \ |
5653 | 6770 | ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ |
5654 | ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) | |
6771 | ? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) | |
5655 | 6772 | #endif |
5656 | 6773 | #ifndef SvPV_nolen_const |
5657 | 6774 | # define SvPV_nolen_const(sv) \ |
5658 | 6775 | ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ |
5659 | ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) | |
6776 | ? SvPVX_const(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) | |
5660 | 6777 | #endif |
5661 | 6778 | #ifndef SvPV_nomg |
5662 | 6779 | # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) |
5672 | 6789 | |
5673 | 6790 | #ifndef SvPV_nomg_nolen |
5674 | 6791 | # define SvPV_nomg_nolen(sv) ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ |
5675 | ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, 0)) | |
6792 | ? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, 0)) | |
5676 | 6793 | #endif |
5677 | 6794 | #ifndef SvPV_renew |
5678 | 6795 | # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ |
5745 | 6862 | extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); |
5746 | 6863 | #endif |
5747 | 6864 | |
6865 | #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) | |
6866 | ||
5748 | 6867 | #ifdef vnewSVpvf |
5749 | 6868 | # undef vnewSVpvf |
5750 | 6869 | #endif |
5751 | 6870 | #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) |
5752 | 6871 | #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) |
5753 | 6872 | |
5754 | #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) | |
5755 | 6873 | |
5756 | 6874 | SV * |
5757 | 6875 | DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) |
5780 | 6898 | extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); |
5781 | 6899 | #endif |
5782 | 6900 | |
6901 | #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) | |
6902 | ||
5783 | 6903 | #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) |
5784 | 6904 | |
5785 | #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) | |
5786 | 6905 | |
5787 | 6906 | void |
5788 | 6907 | DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) |
5806 | 6925 | extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); |
5807 | 6926 | #endif |
5808 | 6927 | |
6928 | #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) | |
6929 | ||
5809 | 6930 | #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) |
5810 | 6931 | #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) |
5811 | 6932 | |
5812 | #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) | |
5813 | 6933 | |
5814 | 6934 | void |
5815 | 6935 | DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) |
5851 | 6971 | extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); |
5852 | 6972 | #endif |
5853 | 6973 | |
6974 | #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) | |
6975 | ||
5854 | 6976 | #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) |
5855 | 6977 | |
5856 | #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) | |
5857 | 6978 | |
5858 | 6979 | void |
5859 | 6980 | DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) |
5877 | 6998 | extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); |
5878 | 6999 | #endif |
5879 | 7000 | |
7001 | #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) | |
7002 | ||
5880 | 7003 | #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) |
5881 | 7004 | #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) |
5882 | 7005 | |
5883 | #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) | |
5884 | 7006 | |
5885 | 7007 | void |
5886 | 7008 | DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) |
5929 | 7051 | extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); |
5930 | 7052 | #endif |
5931 | 7053 | |
7054 | #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) | |
7055 | ||
5932 | 7056 | #ifdef newSVpvn_share |
5933 | 7057 | # undef newSVpvn_share |
5934 | 7058 | #endif |
5935 | 7059 | #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) |
5936 | 7060 | #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) |
5937 | 7061 | |
5938 | #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) | |
5939 | 7062 | |
5940 | 7063 | SV * |
5941 | 7064 | DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) |
5974 | 7097 | extern GV* DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types); |
5975 | 7098 | #endif |
5976 | 7099 | |
7100 | #if defined(NEED_gv_fetchpvn_flags) || defined(NEED_gv_fetchpvn_flags_GLOBAL) | |
7101 | ||
5977 | 7102 | #ifdef gv_fetchpvn_flags |
5978 | 7103 | # undef gv_fetchpvn_flags |
5979 | 7104 | #endif |
5980 | 7105 | #define gv_fetchpvn_flags(a,b,c,d) DPPP_(my_gv_fetchpvn_flags)(aTHX_ a,b,c,d) |
5981 | 7106 | #define Perl_gv_fetchpvn_flags DPPP_(my_gv_fetchpvn_flags) |
5982 | 7107 | |
5983 | #if defined(NEED_gv_fetchpvn_flags) || defined(NEED_gv_fetchpvn_flags_GLOBAL) | |
5984 | 7108 | |
5985 | 7109 | GV* |
5986 | 7110 | DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types) { |
6010 | 7134 | #ifndef gv_init_pvn |
6011 | 7135 | # define gv_init_pvn(gv, stash, ptr, len, flags) gv_init(gv, stash, ptr, len, flags & GV_ADDMULTI ? TRUE : FALSE) |
6012 | 7136 | #endif |
6013 | #ifndef WARN_ALL | |
6014 | # define WARN_ALL 0 | |
6015 | #endif | |
6016 | ||
6017 | #ifndef WARN_CLOSURE | |
6018 | # define WARN_CLOSURE 1 | |
6019 | #endif | |
6020 | ||
6021 | #ifndef WARN_DEPRECATED | |
6022 | # define WARN_DEPRECATED 2 | |
6023 | #endif | |
6024 | ||
6025 | #ifndef WARN_EXITING | |
6026 | # define WARN_EXITING 3 | |
6027 | #endif | |
6028 | ||
6029 | #ifndef WARN_GLOB | |
6030 | # define WARN_GLOB 4 | |
6031 | #endif | |
6032 | ||
6033 | #ifndef WARN_IO | |
6034 | # define WARN_IO 5 | |
6035 | #endif | |
6036 | ||
6037 | #ifndef WARN_CLOSED | |
6038 | # define WARN_CLOSED 6 | |
6039 | #endif | |
6040 | ||
6041 | #ifndef WARN_EXEC | |
6042 | # define WARN_EXEC 7 | |
6043 | #endif | |
6044 | ||
6045 | #ifndef WARN_LAYER | |
6046 | # define WARN_LAYER 8 | |
6047 | #endif | |
6048 | ||
6049 | #ifndef WARN_NEWLINE | |
6050 | # define WARN_NEWLINE 9 | |
6051 | #endif | |
6052 | ||
6053 | #ifndef WARN_PIPE | |
6054 | # define WARN_PIPE 10 | |
6055 | #endif | |
6056 | ||
6057 | #ifndef WARN_UNOPENED | |
6058 | # define WARN_UNOPENED 11 | |
6059 | #endif | |
6060 | ||
6061 | #ifndef WARN_MISC | |
6062 | # define WARN_MISC 12 | |
6063 | #endif | |
6064 | ||
6065 | #ifndef WARN_NUMERIC | |
6066 | # define WARN_NUMERIC 13 | |
6067 | #endif | |
6068 | ||
6069 | #ifndef WARN_ONCE | |
6070 | # define WARN_ONCE 14 | |
6071 | #endif | |
6072 | ||
6073 | #ifndef WARN_OVERFLOW | |
6074 | # define WARN_OVERFLOW 15 | |
6075 | #endif | |
6076 | ||
6077 | #ifndef WARN_PACK | |
6078 | # define WARN_PACK 16 | |
6079 | #endif | |
6080 | ||
6081 | #ifndef WARN_PORTABLE | |
6082 | # define WARN_PORTABLE 17 | |
6083 | #endif | |
6084 | ||
6085 | #ifndef WARN_RECURSION | |
6086 | # define WARN_RECURSION 18 | |
6087 | #endif | |
6088 | ||
6089 | #ifndef WARN_REDEFINE | |
6090 | # define WARN_REDEFINE 19 | |
6091 | #endif | |
6092 | ||
6093 | #ifndef WARN_REGEXP | |
6094 | # define WARN_REGEXP 20 | |
6095 | #endif | |
6096 | ||
6097 | #ifndef WARN_SEVERE | |
6098 | # define WARN_SEVERE 21 | |
6099 | #endif | |
6100 | ||
6101 | #ifndef WARN_DEBUGGING | |
6102 | # define WARN_DEBUGGING 22 | |
6103 | #endif | |
6104 | ||
6105 | #ifndef WARN_INPLACE | |
6106 | # define WARN_INPLACE 23 | |
6107 | #endif | |
6108 | ||
6109 | #ifndef WARN_INTERNAL | |
6110 | # define WARN_INTERNAL 24 | |
6111 | #endif | |
6112 | ||
6113 | #ifndef WARN_MALLOC | |
6114 | # define WARN_MALLOC 25 | |
6115 | #endif | |
6116 | ||
6117 | #ifndef WARN_SIGNAL | |
6118 | # define WARN_SIGNAL 26 | |
6119 | #endif | |
6120 | ||
6121 | #ifndef WARN_SUBSTR | |
6122 | # define WARN_SUBSTR 27 | |
6123 | #endif | |
6124 | ||
6125 | #ifndef WARN_SYNTAX | |
6126 | # define WARN_SYNTAX 28 | |
6127 | #endif | |
6128 | ||
6129 | #ifndef WARN_AMBIGUOUS | |
6130 | # define WARN_AMBIGUOUS 29 | |
6131 | #endif | |
6132 | ||
6133 | #ifndef WARN_BAREWORD | |
6134 | # define WARN_BAREWORD 30 | |
6135 | #endif | |
6136 | ||
6137 | #ifndef WARN_DIGIT | |
6138 | # define WARN_DIGIT 31 | |
6139 | #endif | |
6140 | ||
6141 | #ifndef WARN_PARENTHESIS | |
6142 | # define WARN_PARENTHESIS 32 | |
6143 | #endif | |
6144 | ||
6145 | #ifndef WARN_PRECEDENCE | |
6146 | # define WARN_PRECEDENCE 33 | |
6147 | #endif | |
6148 | ||
6149 | #ifndef WARN_PRINTF | |
6150 | # define WARN_PRINTF 34 | |
6151 | #endif | |
6152 | ||
6153 | #ifndef WARN_PROTOTYPE | |
6154 | # define WARN_PROTOTYPE 35 | |
6155 | #endif | |
6156 | ||
6157 | #ifndef WARN_QW | |
6158 | # define WARN_QW 36 | |
6159 | #endif | |
6160 | ||
6161 | #ifndef WARN_RESERVED | |
6162 | # define WARN_RESERVED 37 | |
6163 | #endif | |
6164 | ||
6165 | #ifndef WARN_SEMICOLON | |
6166 | # define WARN_SEMICOLON 38 | |
6167 | #endif | |
6168 | ||
6169 | #ifndef WARN_TAINT | |
6170 | # define WARN_TAINT 39 | |
6171 | #endif | |
6172 | ||
6173 | #ifndef WARN_THREADS | |
6174 | # define WARN_THREADS 40 | |
6175 | #endif | |
6176 | ||
6177 | #ifndef WARN_UNINITIALIZED | |
6178 | # define WARN_UNINITIALIZED 41 | |
6179 | #endif | |
6180 | ||
6181 | #ifndef WARN_UNPACK | |
6182 | # define WARN_UNPACK 42 | |
6183 | #endif | |
6184 | ||
6185 | #ifndef WARN_UNTIE | |
6186 | # define WARN_UNTIE 43 | |
6187 | #endif | |
6188 | ||
6189 | #ifndef WARN_UTF8 | |
6190 | # define WARN_UTF8 44 | |
6191 | #endif | |
6192 | ||
6193 | #ifndef WARN_VOID | |
6194 | # define WARN_VOID 45 | |
6195 | #endif | |
6196 | ||
6197 | #ifndef WARN_ASSERTIONS | |
6198 | # define WARN_ASSERTIONS 46 | |
6199 | #endif | |
6200 | #ifndef packWARN | |
6201 | # define packWARN(a) (a) | |
6202 | #endif | |
6203 | ||
6204 | #ifndef ckWARN | |
6205 | # ifdef G_WARN_ON | |
6206 | # define ckWARN(a) (PL_dowarn & G_WARN_ON) | |
6207 | # else | |
6208 | # define ckWARN(a) PL_dowarn | |
6209 | # endif | |
6210 | #endif | |
6211 | ||
6212 | #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) | |
6213 | #if defined(NEED_warner) | |
6214 | static void DPPP_(my_warner)(U32 err, const char *pat, ...); | |
6215 | static | |
6216 | #else | |
6217 | extern void DPPP_(my_warner)(U32 err, const char *pat, ...); | |
6218 | #endif | |
6219 | ||
6220 | #define Perl_warner DPPP_(my_warner) | |
6221 | ||
6222 | #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) | |
6223 | ||
6224 | void | |
6225 | DPPP_(my_warner)(U32 err, const char *pat, ...) | |
6226 | { | |
6227 | SV *sv; | |
6228 | va_list args; | |
6229 | ||
6230 | PERL_UNUSED_ARG(err); | |
6231 | ||
6232 | va_start(args, pat); | |
6233 | sv = vnewSVpvf(pat, &args); | |
6234 | va_end(args); | |
6235 | sv_2mortal(sv); | |
6236 | warn("%s", SvPV_nolen(sv)); | |
6237 | } | |
6238 | ||
6239 | #define warner Perl_warner | |
6240 | ||
6241 | #define Perl_warner_nocontext Perl_warner | |
6242 | ||
6243 | #endif | |
6244 | #endif | |
6245 | 7137 | |
6246 | 7138 | /* concatenating with "" ensures that only literal strings are accepted as argument |
6247 | 7139 | * note that STR_WITH_LEN() can't be used as argument to macros or functions that |
6289 | 7181 | #endif |
6290 | 7182 | #ifndef SvGETMAGIC |
6291 | 7183 | # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END |
6292 | #endif | |
6293 | ||
6294 | /* Some random bits for sv_unmagicext. These should probably be pulled in for | |
6295 | real and organized at some point */ | |
6296 | #ifndef HEf_SVKEY | |
6297 | # define HEf_SVKEY -2 | |
6298 | #endif | |
6299 | ||
6300 | #ifndef MUTABLE_PTR | |
6301 | #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) | |
6302 | # define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) | |
6303 | #else | |
6304 | # define MUTABLE_PTR(p) ((void *) (p)) | |
6305 | #endif | |
6306 | #endif | |
6307 | #ifndef MUTABLE_SV | |
6308 | # define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) | |
6309 | #endif | |
6310 | ||
6311 | /* end of random bits */ | |
6312 | #ifndef PERL_MAGIC_sv | |
6313 | # define PERL_MAGIC_sv '\0' | |
6314 | #endif | |
6315 | ||
6316 | #ifndef PERL_MAGIC_overload | |
6317 | # define PERL_MAGIC_overload 'A' | |
6318 | #endif | |
6319 | ||
6320 | #ifndef PERL_MAGIC_overload_elem | |
6321 | # define PERL_MAGIC_overload_elem 'a' | |
6322 | #endif | |
6323 | ||
6324 | #ifndef PERL_MAGIC_overload_table | |
6325 | # define PERL_MAGIC_overload_table 'c' | |
6326 | #endif | |
6327 | ||
6328 | #ifndef PERL_MAGIC_bm | |
6329 | # define PERL_MAGIC_bm 'B' | |
6330 | #endif | |
6331 | ||
6332 | #ifndef PERL_MAGIC_regdata | |
6333 | # define PERL_MAGIC_regdata 'D' | |
6334 | #endif | |
6335 | ||
6336 | #ifndef PERL_MAGIC_regdatum | |
6337 | # define PERL_MAGIC_regdatum 'd' | |
6338 | #endif | |
6339 | ||
6340 | #ifndef PERL_MAGIC_env | |
6341 | # define PERL_MAGIC_env 'E' | |
6342 | #endif | |
6343 | ||
6344 | #ifndef PERL_MAGIC_envelem | |
6345 | # define PERL_MAGIC_envelem 'e' | |
6346 | #endif | |
6347 | ||
6348 | #ifndef PERL_MAGIC_fm | |
6349 | # define PERL_MAGIC_fm 'f' | |
6350 | #endif | |
6351 | ||
6352 | #ifndef PERL_MAGIC_regex_global | |
6353 | # define PERL_MAGIC_regex_global 'g' | |
6354 | #endif | |
6355 | ||
6356 | #ifndef PERL_MAGIC_isa | |
6357 | # define PERL_MAGIC_isa 'I' | |
6358 | #endif | |
6359 | ||
6360 | #ifndef PERL_MAGIC_isaelem | |
6361 | # define PERL_MAGIC_isaelem 'i' | |
6362 | #endif | |
6363 | ||
6364 | #ifndef PERL_MAGIC_nkeys | |
6365 | # define PERL_MAGIC_nkeys 'k' | |
6366 | #endif | |
6367 | ||
6368 | #ifndef PERL_MAGIC_dbfile | |
6369 | # define PERL_MAGIC_dbfile 'L' | |
6370 | #endif | |
6371 | ||
6372 | #ifndef PERL_MAGIC_dbline | |
6373 | # define PERL_MAGIC_dbline 'l' | |
6374 | #endif | |
6375 | ||
6376 | #ifndef PERL_MAGIC_mutex | |
6377 | # define PERL_MAGIC_mutex 'm' | |
6378 | #endif | |
6379 | ||
6380 | #ifndef PERL_MAGIC_shared | |
6381 | # define PERL_MAGIC_shared 'N' | |
6382 | #endif | |
6383 | ||
6384 | #ifndef PERL_MAGIC_shared_scalar | |
6385 | # define PERL_MAGIC_shared_scalar 'n' | |
6386 | #endif | |
6387 | ||
6388 | #ifndef PERL_MAGIC_collxfrm | |
6389 | # define PERL_MAGIC_collxfrm 'o' | |
6390 | #endif | |
6391 | ||
6392 | #ifndef PERL_MAGIC_tied | |
6393 | # define PERL_MAGIC_tied 'P' | |
6394 | #endif | |
6395 | ||
6396 | #ifndef PERL_MAGIC_tiedelem | |
6397 | # define PERL_MAGIC_tiedelem 'p' | |
6398 | #endif | |
6399 | ||
6400 | #ifndef PERL_MAGIC_tiedscalar | |
6401 | # define PERL_MAGIC_tiedscalar 'q' | |
6402 | #endif | |
6403 | ||
6404 | #ifndef PERL_MAGIC_qr | |
6405 | # define PERL_MAGIC_qr 'r' | |
6406 | #endif | |
6407 | ||
6408 | #ifndef PERL_MAGIC_sig | |
6409 | # define PERL_MAGIC_sig 'S' | |
6410 | #endif | |
6411 | ||
6412 | #ifndef PERL_MAGIC_sigelem | |
6413 | # define PERL_MAGIC_sigelem 's' | |
6414 | #endif | |
6415 | ||
6416 | #ifndef PERL_MAGIC_taint | |
6417 | # define PERL_MAGIC_taint 't' | |
6418 | #endif | |
6419 | ||
6420 | #ifndef PERL_MAGIC_uvar | |
6421 | # define PERL_MAGIC_uvar 'U' | |
6422 | #endif | |
6423 | ||
6424 | #ifndef PERL_MAGIC_uvar_elem | |
6425 | # define PERL_MAGIC_uvar_elem 'u' | |
6426 | #endif | |
6427 | ||
6428 | #ifndef PERL_MAGIC_vstring | |
6429 | # define PERL_MAGIC_vstring 'V' | |
6430 | #endif | |
6431 | ||
6432 | #ifndef PERL_MAGIC_vec | |
6433 | # define PERL_MAGIC_vec 'v' | |
6434 | #endif | |
6435 | ||
6436 | #ifndef PERL_MAGIC_utf8 | |
6437 | # define PERL_MAGIC_utf8 'w' | |
6438 | #endif | |
6439 | ||
6440 | #ifndef PERL_MAGIC_substr | |
6441 | # define PERL_MAGIC_substr 'x' | |
6442 | #endif | |
6443 | ||
6444 | #ifndef PERL_MAGIC_defelem | |
6445 | # define PERL_MAGIC_defelem 'y' | |
6446 | #endif | |
6447 | ||
6448 | #ifndef PERL_MAGIC_glob | |
6449 | # define PERL_MAGIC_glob '*' | |
6450 | #endif | |
6451 | ||
6452 | #ifndef PERL_MAGIC_arylen | |
6453 | # define PERL_MAGIC_arylen '#' | |
6454 | #endif | |
6455 | ||
6456 | #ifndef PERL_MAGIC_pos | |
6457 | # define PERL_MAGIC_pos '.' | |
6458 | #endif | |
6459 | ||
6460 | #ifndef PERL_MAGIC_backref | |
6461 | # define PERL_MAGIC_backref '<' | |
6462 | #endif | |
6463 | ||
6464 | #ifndef PERL_MAGIC_ext | |
6465 | # define PERL_MAGIC_ext '~' | |
6466 | 7184 | #endif |
6467 | 7185 | |
6468 | 7186 | /* That's the best we can do... */ |
6632 | 7350 | extern MAGIC * DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl); |
6633 | 7351 | #endif |
6634 | 7352 | |
7353 | #if defined(NEED_mg_findext) || defined(NEED_mg_findext_GLOBAL) | |
7354 | ||
6635 | 7355 | #define mg_findext DPPP_(my_mg_findext) |
6636 | 7356 | #define Perl_mg_findext DPPP_(my_mg_findext) |
6637 | 7357 | |
6638 | #if defined(NEED_mg_findext) || defined(NEED_mg_findext_GLOBAL) | |
6639 | 7358 | |
6640 | 7359 | MAGIC * |
6641 | 7360 | DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl) { |
6666 | 7385 | extern int DPPP_(my_sv_unmagicext)(pTHX_ SV * const sv, const int type, MGVTBL * vtbl); |
6667 | 7386 | #endif |
6668 | 7387 | |
7388 | #if defined(NEED_sv_unmagicext) || defined(NEED_sv_unmagicext_GLOBAL) | |
7389 | ||
6669 | 7390 | #ifdef sv_unmagicext |
6670 | 7391 | # undef sv_unmagicext |
6671 | 7392 | #endif |
6672 | 7393 | #define sv_unmagicext(a,b,c) DPPP_(my_sv_unmagicext)(aTHX_ a,b,c) |
6673 | 7394 | #define Perl_sv_unmagicext DPPP_(my_sv_unmagicext) |
6674 | 7395 | |
6675 | #if defined(NEED_sv_unmagicext) || defined(NEED_sv_unmagicext_GLOBAL) | |
6676 | 7396 | |
6677 | 7397 | int |
6678 | 7398 | DPPP_(my_sv_unmagicext)(pTHX_ SV *const sv, const int type, MGVTBL *vtbl) |
6839 | 7559 | extern const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp); |
6840 | 7560 | #endif |
6841 | 7561 | |
7562 | #if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) | |
7563 | ||
6842 | 7564 | #ifdef caller_cx |
6843 | 7565 | # undef caller_cx |
6844 | 7566 | #endif |
6845 | 7567 | #define caller_cx(a,b) DPPP_(my_caller_cx)(aTHX_ a,b) |
6846 | 7568 | #define Perl_caller_cx DPPP_(my_caller_cx) |
6847 | 7569 | |
6848 | #if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) | |
6849 | 7570 | |
6850 | 7571 | const PERL_CONTEXT * |
6851 | 7572 | DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp) |
6956 | 7677 | extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); |
6957 | 7678 | #endif |
6958 | 7679 | |
7680 | #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) | |
7681 | ||
6959 | 7682 | #ifdef grok_numeric_radix |
6960 | 7683 | # undef grok_numeric_radix |
6961 | 7684 | #endif |
6962 | 7685 | #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) |
6963 | 7686 | #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) |
6964 | 7687 | |
6965 | #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) | |
6966 | 7688 | bool |
6967 | 7689 | DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) |
6968 | 7690 | { |
7012 | 7734 | extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); |
7013 | 7735 | #endif |
7014 | 7736 | |
7737 | #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) | |
7738 | ||
7015 | 7739 | #ifdef grok_number |
7016 | 7740 | # undef grok_number |
7017 | 7741 | #endif |
7018 | 7742 | #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) |
7019 | 7743 | #define Perl_grok_number DPPP_(my_grok_number) |
7020 | 7744 | |
7021 | #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) | |
7022 | 7745 | int |
7023 | 7746 | DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) |
7024 | 7747 | { |
7226 | 7949 | extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); |
7227 | 7950 | #endif |
7228 | 7951 | |
7952 | #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) | |
7953 | ||
7229 | 7954 | #ifdef grok_bin |
7230 | 7955 | # undef grok_bin |
7231 | 7956 | #endif |
7232 | 7957 | #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) |
7233 | 7958 | #define Perl_grok_bin DPPP_(my_grok_bin) |
7234 | 7959 | |
7235 | #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) | |
7236 | 7960 | UV |
7237 | 7961 | DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) |
7238 | 7962 | { |
7328 | 8052 | extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); |
7329 | 8053 | #endif |
7330 | 8054 | |
8055 | #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) | |
8056 | ||
7331 | 8057 | #ifdef grok_hex |
7332 | 8058 | # undef grok_hex |
7333 | 8059 | #endif |
7334 | 8060 | #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) |
7335 | 8061 | #define Perl_grok_hex DPPP_(my_grok_hex) |
7336 | 8062 | |
7337 | #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) | |
7338 | 8063 | UV |
7339 | 8064 | DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) |
7340 | 8065 | { |
7430 | 8155 | extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); |
7431 | 8156 | #endif |
7432 | 8157 | |
8158 | #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) | |
8159 | ||
7433 | 8160 | #ifdef grok_oct |
7434 | 8161 | # undef grok_oct |
7435 | 8162 | #endif |
7436 | 8163 | #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) |
7437 | 8164 | #define Perl_grok_oct DPPP_(my_grok_oct) |
7438 | 8165 | |
7439 | #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) | |
7440 | 8166 | UV |
7441 | 8167 | DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) |
7442 | 8168 | { |
7523 | 8249 | extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); |
7524 | 8250 | #endif |
7525 | 8251 | |
8252 | #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) | |
8253 | ||
7526 | 8254 | #define my_snprintf DPPP_(my_my_snprintf) |
7527 | 8255 | #define Perl_my_snprintf DPPP_(my_my_snprintf) |
7528 | 8256 | |
7529 | #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) | |
7530 | 8257 | |
7531 | 8258 | int |
7532 | 8259 | DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) |
7557 | 8284 | extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); |
7558 | 8285 | #endif |
7559 | 8286 | |
8287 | #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) | |
8288 | ||
7560 | 8289 | #define my_sprintf DPPP_(my_my_sprintf) |
7561 | 8290 | #define Perl_my_sprintf DPPP_(my_my_sprintf) |
7562 | 8291 | |
7563 | #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) | |
7564 | 8292 | |
7565 | 8293 | int |
7566 | 8294 | DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) |
7599 | 8327 | extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); |
7600 | 8328 | #endif |
7601 | 8329 | |
8330 | #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) | |
8331 | ||
7602 | 8332 | #define my_strlcat DPPP_(my_my_strlcat) |
7603 | 8333 | #define Perl_my_strlcat DPPP_(my_my_strlcat) |
7604 | 8334 | |
7605 | #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) | |
7606 | 8335 | |
7607 | 8336 | Size_t |
7608 | 8337 | DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) |
7629 | 8358 | extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); |
7630 | 8359 | #endif |
7631 | 8360 | |
8361 | #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) | |
8362 | ||
7632 | 8363 | #define my_strlcpy DPPP_(my_my_strlcpy) |
7633 | 8364 | #define Perl_my_strlcpy DPPP_(my_my_strlcpy) |
7634 | 8365 | |
7635 | #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) | |
7636 | 8366 | |
7637 | 8367 | Size_t |
7638 | 8368 | DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) |
7719 | 8449 | extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); |
7720 | 8450 | #endif |
7721 | 8451 | |
8452 | #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) | |
8453 | ||
7722 | 8454 | #ifdef pv_escape |
7723 | 8455 | # undef pv_escape |
7724 | 8456 | #endif |
7725 | 8457 | #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) |
7726 | 8458 | #define Perl_pv_escape DPPP_(my_pv_escape) |
7727 | 8459 | |
7728 | #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) | |
7729 | 8460 | |
7730 | 8461 | char * |
7731 | 8462 | DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, |
7738 | 8469 | STRLEN wrote = 0; |
7739 | 8470 | STRLEN chsize = 0; |
7740 | 8471 | STRLEN readsize = 1; |
7741 | #if defined(is_utf8_string) && defined(utf8_to_uvchr) | |
8472 | #if defined(is_utf8_string) && defined(utf8_to_uvchr_buf) | |
7742 | 8473 | bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; |
7743 | 8474 | #endif |
7744 | 8475 | const char *pv = str; |
7748 | 8479 | if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) |
7749 | 8480 | sv_setpvs(dsv, ""); |
7750 | 8481 | |
7751 | #if defined(is_utf8_string) && defined(utf8_to_uvchr) | |
8482 | #if defined(is_utf8_string) && defined(utf8_to_uvchr_buf) | |
7752 | 8483 | if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) |
7753 | 8484 | isuni = 1; |
7754 | 8485 | #endif |
7755 | 8486 | |
7756 | 8487 | for (; pv < end && (!max || wrote < max) ; pv += readsize) { |
7757 | 8488 | const UV u = |
7758 | #if defined(is_utf8_string) && defined(utf8_to_uvchr) | |
7759 | isuni ? utf8_to_uvchr((U8*)pv, &readsize) : | |
8489 | #if defined(is_utf8_string) && defined(utf8_to_uvchr_buf) | |
8490 | isuni ? utf8_to_uvchr_buf((U8*)pv, end, &readsize) : | |
7760 | 8491 | #endif |
7761 | 8492 | (U8)*pv; |
7762 | 8493 | const U8 c = (U8)u & 0xFF; |
7828 | 8559 | extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); |
7829 | 8560 | #endif |
7830 | 8561 | |
8562 | #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) | |
8563 | ||
7831 | 8564 | #ifdef pv_pretty |
7832 | 8565 | # undef pv_pretty |
7833 | 8566 | #endif |
7834 | 8567 | #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) |
7835 | 8568 | #define Perl_pv_pretty DPPP_(my_pv_pretty) |
7836 | 8569 | |
7837 | #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) | |
7838 | 8570 | |
7839 | 8571 | char * |
7840 | 8572 | DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, |
7882 | 8614 | extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); |
7883 | 8615 | #endif |
7884 | 8616 | |
8617 | #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) | |
8618 | ||
7885 | 8619 | #ifdef pv_display |
7886 | 8620 | # undef pv_display |
7887 | 8621 | #endif |
7888 | 8622 | #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) |
7889 | 8623 | #define Perl_pv_display DPPP_(my_pv_display) |
7890 | 8624 | |
7891 | #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) | |
7892 | 8625 | |
7893 | 8626 | char * |
7894 | 8627 | DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) |
95 | 95 | ltc/pk/asn1/der/utctime/der_length_utctime.o ltc/pk/asn1/der/utf8/der_decode_utf8_string.o \ |
96 | 96 | ltc/pk/asn1/der/utf8/der_encode_utf8_string.o ltc/pk/asn1/der/utf8/der_length_utf8_string.o \ |
97 | 97 | ltc/pk/asn1/oid/pk_get_oid.o ltc/pk/asn1/oid/pk_oid_cmp.o ltc/pk/asn1/oid/pk_oid_str.o \ |
98 | ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.o ltc/pk/asn1/x509/x509_decode_subject_public_key_info.o \ | |
99 | ltc/pk/asn1/x509/x509_encode_subject_public_key_info.o ltc/pk/dh/dh.o ltc/pk/dh/dh_check_pubkey.o \ | |
100 | ltc/pk/dh/dh_export.o ltc/pk/dh/dh_export_key.o ltc/pk/dh/dh_free.o ltc/pk/dh/dh_generate_key.o \ | |
101 | ltc/pk/dh/dh_import.o ltc/pk/dh/dh_set.o ltc/pk/dh/dh_set_pg_dhparam.o ltc/pk/dh/dh_shared_secret.o \ | |
102 | ltc/pk/dsa/dsa_decrypt_key.o ltc/pk/dsa/dsa_encrypt_key.o ltc/pk/dsa/dsa_export.o \ | |
103 | ltc/pk/dsa/dsa_free.o ltc/pk/dsa/dsa_generate_key.o ltc/pk/dsa/dsa_generate_pqg.o \ | |
104 | ltc/pk/dsa/dsa_import.o ltc/pk/dsa/dsa_make_key.o ltc/pk/dsa/dsa_set.o ltc/pk/dsa/dsa_set_pqg_dsaparam.o \ | |
105 | ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_sign_hash.o ltc/pk/dsa/dsa_verify_hash.o \ | |
106 | ltc/pk/dsa/dsa_verify_key.o ltc/pk/ecc/ecc.o ltc/pk/ecc/ecc_ansi_x963_export.o ltc/pk/ecc/ecc_ansi_x963_import.o \ | |
107 | ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.o ltc/pk/ecc/ecc_export.o \ | |
108 | ltc/pk/ecc/ecc_export_openssl.o ltc/pk/ecc/ecc_find_curve.o ltc/pk/ecc/ecc_free.o \ | |
109 | ltc/pk/ecc/ecc_get_key.o ltc/pk/ecc/ecc_get_oid_str.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o \ | |
110 | ltc/pk/ecc/ecc_import_openssl.o ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o \ | |
111 | ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_recover_key.o ltc/pk/ecc/ecc_set_curve.o \ | |
112 | ltc/pk/ecc/ecc_set_curve_internal.o ltc/pk/ecc/ecc_set_key.o ltc/pk/ecc/ecc_shared_secret.o \ | |
113 | ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.o \ | |
114 | ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o ltc/pk/ecc/ltc_ecc_import_point.o \ | |
115 | ltc/pk/ecc/ltc_ecc_is_point.o ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o ltc/pk/ecc/ltc_ecc_map.o \ | |
116 | ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o ltc/pk/ecc/ltc_ecc_mulmod_timing.o \ | |
117 | ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o ltc/pk/ecc/ltc_ecc_projective_dbl_point.o \ | |
118 | ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o ltc/pk/pkcs1/pkcs_1_mgf1.o \ | |
119 | ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o ltc/pk/pkcs1/pkcs_1_os2ip.o \ | |
120 | ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o ltc/pk/pkcs1/pkcs_1_v1_5_decode.o \ | |
121 | ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o ltc/pk/rsa/rsa_encrypt_key.o \ | |
122 | ltc/pk/rsa/rsa_export.o ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o ltc/pk/rsa/rsa_get_size.o \ | |
123 | ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \ | |
98 | ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.o ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.o \ | |
99 | ltc/pk/asn1/x509/x509_decode_subject_public_key_info.o ltc/pk/asn1/x509/x509_encode_subject_public_key_info.o \ | |
100 | ltc/pk/dh/dh.o ltc/pk/dh/dh_check_pubkey.o ltc/pk/dh/dh_export.o ltc/pk/dh/dh_export_key.o \ | |
101 | ltc/pk/dh/dh_free.o ltc/pk/dh/dh_generate_key.o ltc/pk/dh/dh_import.o ltc/pk/dh/dh_set.o \ | |
102 | ltc/pk/dh/dh_set_pg_dhparam.o ltc/pk/dh/dh_shared_secret.o ltc/pk/dsa/dsa_decrypt_key.o \ | |
103 | ltc/pk/dsa/dsa_encrypt_key.o ltc/pk/dsa/dsa_export.o ltc/pk/dsa/dsa_free.o ltc/pk/dsa/dsa_generate_key.o \ | |
104 | ltc/pk/dsa/dsa_generate_pqg.o ltc/pk/dsa/dsa_import.o ltc/pk/dsa/dsa_make_key.o ltc/pk/dsa/dsa_set.o \ | |
105 | ltc/pk/dsa/dsa_set_pqg_dsaparam.o ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_sign_hash.o \ | |
106 | ltc/pk/dsa/dsa_verify_hash.o ltc/pk/dsa/dsa_verify_key.o ltc/pk/ecc/ecc.o ltc/pk/ecc/ecc_ansi_x963_export.o \ | |
107 | ltc/pk/ecc/ecc_ansi_x963_import.o ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.o \ | |
108 | ltc/pk/ecc/ecc_export.o ltc/pk/ecc/ecc_export_openssl.o ltc/pk/ecc/ecc_find_curve.o \ | |
109 | ltc/pk/ecc/ecc_free.o ltc/pk/ecc/ecc_get_key.o ltc/pk/ecc/ecc_get_oid_str.o ltc/pk/ecc/ecc_get_size.o \ | |
110 | ltc/pk/ecc/ecc_import.o ltc/pk/ecc/ecc_import_openssl.o ltc/pk/ecc/ecc_import_pkcs8.o \ | |
111 | ltc/pk/ecc/ecc_import_x509.o ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_recover_key.o \ | |
112 | ltc/pk/ecc/ecc_set_curve.o ltc/pk/ecc/ecc_set_curve_internal.o ltc/pk/ecc/ecc_set_key.o \ | |
113 | ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o \ | |
114 | ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.o ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o \ | |
115 | ltc/pk/ecc/ltc_ecc_import_point.o ltc/pk/ecc/ltc_ecc_is_point.o ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o \ | |
116 | ltc/pk/ecc/ltc_ecc_map.o ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o \ | |
117 | ltc/pk/ecc/ltc_ecc_mulmod_timing.o ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o \ | |
118 | ltc/pk/ecc/ltc_ecc_projective_dbl_point.o ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o \ | |
119 | ltc/pk/pkcs1/pkcs_1_mgf1.o ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o \ | |
120 | ltc/pk/pkcs1/pkcs_1_os2ip.o ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o \ | |
121 | ltc/pk/pkcs1/pkcs_1_v1_5_decode.o ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o \ | |
122 | ltc/pk/rsa/rsa_encrypt_key.o ltc/pk/rsa/rsa_export.o ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o \ | |
123 | ltc/pk/rsa/rsa_get_size.o ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \ | |
124 | 124 | ltc/pk/rsa/rsa_make_key.o ltc/pk/rsa/rsa_set.o ltc/pk/rsa/rsa_sign_hash.o ltc/pk/rsa/rsa_sign_saltlen_get.o \ |
125 | 125 | ltc/pk/rsa/rsa_verify_hash.o ltc/prngs/chacha20.o ltc/prngs/fortuna.o ltc/prngs/rc4.o \ |
126 | 126 | ltc/prngs/rng_get_bytes.o ltc/prngs/rng_make_prng.o ltc/prngs/sober128.o ltc/prngs/sprng.o \ |
141 | 141 | ltm/bn_mp_div_3.o ltm/bn_mp_div_d.o ltm/bn_mp_dr_is_modulus.o ltm/bn_mp_dr_reduce.o \ |
142 | 142 | ltm/bn_mp_dr_setup.o ltm/bn_mp_exch.o ltm/bn_mp_export.o ltm/bn_mp_exptmod.o ltm/bn_mp_exptmod_fast.o \ |
143 | 143 | ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o ltm/bn_mp_fread.o \ |
144 | ltm/bn_mp_fwrite.o ltm/bn_mp_gcd.o ltm/bn_mp_get_int.o ltm/bn_mp_get_long.o ltm/bn_mp_grow.o \ | |
145 | ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \ | |
144 | ltm/bn_mp_fwrite.o ltm/bn_mp_gcd.o ltm/bn_mp_get_bit.o ltm/bn_mp_get_int.o ltm/bn_mp_get_long.o \ | |
145 | ltm/bn_mp_grow.o ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \ | |
146 | 146 | ltm/bn_mp_init_set.o ltm/bn_mp_init_set_int.o ltm/bn_mp_init_size.o ltm/bn_mp_invmod.o \ |
147 | 147 | ltm/bn_mp_invmod_slow.o ltm/bn_mp_is_square.o ltm/bn_mp_jacobi.o ltm/bn_mp_karatsuba_mul.o \ |
148 | ltm/bn_mp_karatsuba_sqr.o ltm/bn_mp_lcm.o ltm/bn_mp_lshd.o ltm/bn_mp_mod.o ltm/bn_mp_mod_2d.o \ | |
149 | ltm/bn_mp_mod_d.o ltm/bn_mp_montgomery_calc_normalization.o ltm/bn_mp_montgomery_reduce.o \ | |
150 | ltm/bn_mp_montgomery_setup.o ltm/bn_mp_mul.o ltm/bn_mp_mulmod.o ltm/bn_mp_mul_2.o \ | |
151 | ltm/bn_mp_mul_2d.o ltm/bn_mp_mul_d.o ltm/bn_mp_neg.o ltm/bn_mp_n_root.o ltm/bn_mp_n_root_ex.o \ | |
152 | ltm/bn_mp_or.o ltm/bn_mp_prime_fermat.o ltm/bn_mp_prime_is_divisible.o ltm/bn_mp_prime_is_prime.o \ | |
153 | ltm/bn_mp_prime_miller_rabin.o ltm/bn_mp_prime_next_prime.o ltm/bn_mp_prime_rabin_miller_trials.o \ | |
154 | ltm/bn_mp_prime_random_ex.o ltm/bn_mp_radix_size.o ltm/bn_mp_radix_smap.o ltm/bn_mp_rand.o \ | |
155 | ltm/bn_mp_read_radix.o ltm/bn_mp_read_signed_bin.o ltm/bn_mp_read_unsigned_bin.o \ | |
148 | ltm/bn_mp_karatsuba_sqr.o ltm/bn_mp_kronecker.o ltm/bn_mp_lcm.o ltm/bn_mp_lshd.o \ | |
149 | ltm/bn_mp_mod.o ltm/bn_mp_mod_2d.o ltm/bn_mp_mod_d.o ltm/bn_mp_montgomery_calc_normalization.o \ | |
150 | ltm/bn_mp_montgomery_reduce.o ltm/bn_mp_montgomery_setup.o ltm/bn_mp_mul.o ltm/bn_mp_mulmod.o \ | |
151 | ltm/bn_mp_mul_2.o ltm/bn_mp_mul_2d.o ltm/bn_mp_mul_d.o ltm/bn_mp_neg.o ltm/bn_mp_n_root.o \ | |
152 | ltm/bn_mp_n_root_ex.o ltm/bn_mp_or.o ltm/bn_mp_prime_fermat.o ltm/bn_mp_prime_frobenius_underwood.o \ | |
153 | ltm/bn_mp_prime_is_divisible.o ltm/bn_mp_prime_is_prime.o ltm/bn_mp_prime_miller_rabin.o \ | |
154 | ltm/bn_mp_prime_next_prime.o ltm/bn_mp_prime_rabin_miller_trials.o ltm/bn_mp_prime_random_ex.o \ | |
155 | ltm/bn_mp_prime_strong_lucas_selfridge.o ltm/bn_mp_radix_size.o ltm/bn_mp_radix_smap.o \ | |
156 | ltm/bn_mp_rand.o ltm/bn_mp_read_radix.o ltm/bn_mp_read_signed_bin.o ltm/bn_mp_read_unsigned_bin.o \ | |
156 | 157 | ltm/bn_mp_reduce.o ltm/bn_mp_reduce_2k.o ltm/bn_mp_reduce_2k_l.o ltm/bn_mp_reduce_2k_setup.o \ |
157 | 158 | ltm/bn_mp_reduce_2k_setup_l.o ltm/bn_mp_reduce_is_2k.o ltm/bn_mp_reduce_is_2k_l.o \ |
158 | 159 | ltm/bn_mp_reduce_setup.o ltm/bn_mp_rshd.o ltm/bn_mp_set.o ltm/bn_mp_set_int.o ltm/bn_mp_set_long.o \ |
101 | 101 | ltc/pk/asn1/der/utctime/der_length_utctime.obj ltc/pk/asn1/der/utf8/der_decode_utf8_string.obj \ |
102 | 102 | ltc/pk/asn1/der/utf8/der_encode_utf8_string.obj ltc/pk/asn1/der/utf8/der_length_utf8_string.obj \ |
103 | 103 | ltc/pk/asn1/oid/pk_get_oid.obj ltc/pk/asn1/oid/pk_oid_cmp.obj ltc/pk/asn1/oid/pk_oid_str.obj \ |
104 | ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.obj ltc/pk/asn1/x509/x509_decode_subject_public_key_info.obj \ | |
105 | ltc/pk/asn1/x509/x509_encode_subject_public_key_info.obj ltc/pk/dh/dh.obj ltc/pk/dh/dh_check_pubkey.obj \ | |
106 | ltc/pk/dh/dh_export.obj ltc/pk/dh/dh_export_key.obj ltc/pk/dh/dh_free.obj ltc/pk/dh/dh_generate_key.obj \ | |
107 | ltc/pk/dh/dh_import.obj ltc/pk/dh/dh_set.obj ltc/pk/dh/dh_set_pg_dhparam.obj ltc/pk/dh/dh_shared_secret.obj \ | |
108 | ltc/pk/dsa/dsa_decrypt_key.obj ltc/pk/dsa/dsa_encrypt_key.obj ltc/pk/dsa/dsa_export.obj \ | |
109 | ltc/pk/dsa/dsa_free.obj ltc/pk/dsa/dsa_generate_key.obj ltc/pk/dsa/dsa_generate_pqg.obj \ | |
110 | ltc/pk/dsa/dsa_import.obj ltc/pk/dsa/dsa_make_key.obj ltc/pk/dsa/dsa_set.obj ltc/pk/dsa/dsa_set_pqg_dsaparam.obj \ | |
104 | ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.obj ltc/pk/asn1/x509/x509_decode_public_key_from_certificate.obj \ | |
105 | ltc/pk/asn1/x509/x509_decode_subject_public_key_info.obj ltc/pk/asn1/x509/x509_encode_subject_public_key_info.obj \ | |
106 | ltc/pk/dh/dh.obj ltc/pk/dh/dh_check_pubkey.obj ltc/pk/dh/dh_export.obj ltc/pk/dh/dh_export_key.obj \ | |
107 | ltc/pk/dh/dh_free.obj ltc/pk/dh/dh_generate_key.obj ltc/pk/dh/dh_import.obj ltc/pk/dh/dh_set.obj \ | |
108 | ltc/pk/dh/dh_set_pg_dhparam.obj ltc/pk/dh/dh_shared_secret.obj ltc/pk/dsa/dsa_decrypt_key.obj \ | |
109 | ltc/pk/dsa/dsa_encrypt_key.obj ltc/pk/dsa/dsa_export.obj ltc/pk/dsa/dsa_free.obj \ | |
110 | ltc/pk/dsa/dsa_generate_key.obj ltc/pk/dsa/dsa_generate_pqg.obj ltc/pk/dsa/dsa_import.obj \ | |
111 | ltc/pk/dsa/dsa_make_key.obj ltc/pk/dsa/dsa_set.obj ltc/pk/dsa/dsa_set_pqg_dsaparam.obj \ | |
111 | 112 | ltc/pk/dsa/dsa_shared_secret.obj ltc/pk/dsa/dsa_sign_hash.obj ltc/pk/dsa/dsa_verify_hash.obj \ |
112 | 113 | ltc/pk/dsa/dsa_verify_key.obj ltc/pk/ecc/ecc.obj ltc/pk/ecc/ecc_ansi_x963_export.obj \ |
113 | 114 | ltc/pk/ecc/ecc_ansi_x963_import.obj ltc/pk/ecc/ecc_decrypt_key.obj ltc/pk/ecc/ecc_encrypt_key.obj \ |
149 | 150 | ltm/bn_mp_dr_is_modulus.obj ltm/bn_mp_dr_reduce.obj ltm/bn_mp_dr_setup.obj ltm/bn_mp_exch.obj \ |
150 | 151 | ltm/bn_mp_export.obj ltm/bn_mp_exptmod.obj ltm/bn_mp_exptmod_fast.obj ltm/bn_mp_expt_d.obj \ |
151 | 152 | ltm/bn_mp_expt_d_ex.obj ltm/bn_mp_exteuclid.obj ltm/bn_mp_fread.obj ltm/bn_mp_fwrite.obj \ |
152 | ltm/bn_mp_gcd.obj ltm/bn_mp_get_int.obj ltm/bn_mp_get_long.obj ltm/bn_mp_grow.obj \ | |
153 | ltm/bn_mp_import.obj ltm/bn_mp_init.obj ltm/bn_mp_init_copy.obj ltm/bn_mp_init_multi.obj \ | |
154 | ltm/bn_mp_init_set.obj ltm/bn_mp_init_set_int.obj ltm/bn_mp_init_size.obj ltm/bn_mp_invmod.obj \ | |
155 | ltm/bn_mp_invmod_slow.obj ltm/bn_mp_is_square.obj ltm/bn_mp_jacobi.obj ltm/bn_mp_karatsuba_mul.obj \ | |
156 | ltm/bn_mp_karatsuba_sqr.obj ltm/bn_mp_lcm.obj ltm/bn_mp_lshd.obj ltm/bn_mp_mod.obj \ | |
157 | ltm/bn_mp_mod_2d.obj ltm/bn_mp_mod_d.obj ltm/bn_mp_montgomery_calc_normalization.obj \ | |
153 | ltm/bn_mp_gcd.obj ltm/bn_mp_get_bit.obj ltm/bn_mp_get_int.obj ltm/bn_mp_get_long.obj \ | |
154 | ltm/bn_mp_grow.obj ltm/bn_mp_import.obj ltm/bn_mp_init.obj ltm/bn_mp_init_copy.obj \ | |
155 | ltm/bn_mp_init_multi.obj ltm/bn_mp_init_set.obj ltm/bn_mp_init_set_int.obj ltm/bn_mp_init_size.obj \ | |
156 | ltm/bn_mp_invmod.obj ltm/bn_mp_invmod_slow.obj ltm/bn_mp_is_square.obj ltm/bn_mp_jacobi.obj \ | |
157 | ltm/bn_mp_karatsuba_mul.obj ltm/bn_mp_karatsuba_sqr.obj ltm/bn_mp_kronecker.obj ltm/bn_mp_lcm.obj \ | |
158 | ltm/bn_mp_lshd.obj ltm/bn_mp_mod.obj ltm/bn_mp_mod_2d.obj ltm/bn_mp_mod_d.obj ltm/bn_mp_montgomery_calc_normalization.obj \ | |
158 | 159 | ltm/bn_mp_montgomery_reduce.obj ltm/bn_mp_montgomery_setup.obj ltm/bn_mp_mul.obj \ |
159 | 160 | ltm/bn_mp_mulmod.obj ltm/bn_mp_mul_2.obj ltm/bn_mp_mul_2d.obj ltm/bn_mp_mul_d.obj \ |
160 | 161 | ltm/bn_mp_neg.obj ltm/bn_mp_n_root.obj ltm/bn_mp_n_root_ex.obj ltm/bn_mp_or.obj ltm/bn_mp_prime_fermat.obj \ |
161 | ltm/bn_mp_prime_is_divisible.obj ltm/bn_mp_prime_is_prime.obj ltm/bn_mp_prime_miller_rabin.obj \ | |
162 | ltm/bn_mp_prime_next_prime.obj ltm/bn_mp_prime_rabin_miller_trials.obj ltm/bn_mp_prime_random_ex.obj \ | |
163 | ltm/bn_mp_radix_size.obj ltm/bn_mp_radix_smap.obj ltm/bn_mp_rand.obj ltm/bn_mp_read_radix.obj \ | |
164 | ltm/bn_mp_read_signed_bin.obj ltm/bn_mp_read_unsigned_bin.obj ltm/bn_mp_reduce.obj \ | |
165 | ltm/bn_mp_reduce_2k.obj ltm/bn_mp_reduce_2k_l.obj ltm/bn_mp_reduce_2k_setup.obj ltm/bn_mp_reduce_2k_setup_l.obj \ | |
166 | ltm/bn_mp_reduce_is_2k.obj ltm/bn_mp_reduce_is_2k_l.obj ltm/bn_mp_reduce_setup.obj \ | |
167 | ltm/bn_mp_rshd.obj ltm/bn_mp_set.obj ltm/bn_mp_set_int.obj ltm/bn_mp_set_long.obj \ | |
168 | ltm/bn_mp_shrink.obj ltm/bn_mp_signed_bin_size.obj ltm/bn_mp_sqr.obj ltm/bn_mp_sqrmod.obj \ | |
169 | ltm/bn_mp_sqrt.obj ltm/bn_mp_sqrtmod_prime.obj ltm/bn_mp_sub.obj ltm/bn_mp_submod.obj \ | |
170 | ltm/bn_mp_sub_d.obj ltm/bn_mp_tc_and.obj ltm/bn_mp_tc_div_2d.obj ltm/bn_mp_tc_or.obj \ | |
171 | ltm/bn_mp_tc_xor.obj ltm/bn_mp_toom_mul.obj ltm/bn_mp_toom_sqr.obj ltm/bn_mp_toradix.obj \ | |
172 | ltm/bn_mp_toradix_n.obj ltm/bn_mp_to_signed_bin.obj ltm/bn_mp_to_signed_bin_n.obj \ | |
162 | ltm/bn_mp_prime_frobenius_underwood.obj ltm/bn_mp_prime_is_divisible.obj ltm/bn_mp_prime_is_prime.obj \ | |
163 | ltm/bn_mp_prime_miller_rabin.obj ltm/bn_mp_prime_next_prime.obj ltm/bn_mp_prime_rabin_miller_trials.obj \ | |
164 | ltm/bn_mp_prime_random_ex.obj ltm/bn_mp_prime_strong_lucas_selfridge.obj ltm/bn_mp_radix_size.obj \ | |
165 | ltm/bn_mp_radix_smap.obj ltm/bn_mp_rand.obj ltm/bn_mp_read_radix.obj ltm/bn_mp_read_signed_bin.obj \ | |
166 | ltm/bn_mp_read_unsigned_bin.obj ltm/bn_mp_reduce.obj ltm/bn_mp_reduce_2k.obj ltm/bn_mp_reduce_2k_l.obj \ | |
167 | ltm/bn_mp_reduce_2k_setup.obj ltm/bn_mp_reduce_2k_setup_l.obj ltm/bn_mp_reduce_is_2k.obj \ | |
168 | ltm/bn_mp_reduce_is_2k_l.obj ltm/bn_mp_reduce_setup.obj ltm/bn_mp_rshd.obj ltm/bn_mp_set.obj \ | |
169 | ltm/bn_mp_set_int.obj ltm/bn_mp_set_long.obj ltm/bn_mp_shrink.obj ltm/bn_mp_signed_bin_size.obj \ | |
170 | ltm/bn_mp_sqr.obj ltm/bn_mp_sqrmod.obj ltm/bn_mp_sqrt.obj ltm/bn_mp_sqrtmod_prime.obj \ | |
171 | ltm/bn_mp_sub.obj ltm/bn_mp_submod.obj ltm/bn_mp_sub_d.obj ltm/bn_mp_tc_and.obj ltm/bn_mp_tc_div_2d.obj \ | |
172 | ltm/bn_mp_tc_or.obj ltm/bn_mp_tc_xor.obj ltm/bn_mp_toom_mul.obj ltm/bn_mp_toom_sqr.obj \ | |
173 | ltm/bn_mp_toradix.obj ltm/bn_mp_toradix_n.obj ltm/bn_mp_to_signed_bin.obj ltm/bn_mp_to_signed_bin_n.obj \ | |
173 | 174 | ltm/bn_mp_to_unsigned_bin.obj ltm/bn_mp_to_unsigned_bin_n.obj ltm/bn_mp_unsigned_bin_size.obj \ |
174 | 175 | ltm/bn_mp_xor.obj ltm/bn_mp_zero.obj ltm/bn_prime_tab.obj ltm/bn_reverse.obj ltm/bn_s_mp_add.obj \ |
175 | 176 | ltm/bn_s_mp_exptmod.obj ltm/bn_s_mp_mul_digs.obj ltm/bn_s_mp_mul_high_digs.obj ltm/bn_s_mp_sqr.obj \ |
8 | 8 | |
9 | 9 | /* Defines the LTC_ARGCHK macro used within the library */ |
10 | 10 | /* ARGTYPE is defined in tomcrypt_cfg.h */ |
11 | ||
12 | /* ARGTYPE is per default defined to 0 */ | |
11 | 13 | #if ARGTYPE == 0 |
12 | 14 | |
13 | 15 | #include <signal.h> |
14 | 16 | |
15 | /* this is the default LibTomCrypt macro */ | |
16 | #if defined(__clang__) || defined(__GNUC_MINOR__) | |
17 | #define NORETURN __attribute__ ((noreturn)) | |
18 | #else | |
19 | #define NORETURN | |
20 | #endif | |
21 | ||
22 | void crypt_argchk(const char *v, const char *s, int d) NORETURN; | |
17 | LTC_NORETURN void crypt_argchk(const char *v, const char *s, int d); | |
23 | 18 | #define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0) |
24 | 19 | #define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0) |
25 | 20 | |
36 | 31 | |
37 | 32 | #elif ARGTYPE == 3 |
38 | 33 | |
39 | #define LTC_ARGCHK(x) | |
34 | #define LTC_ARGCHK(x) LTC_UNUSED_PARAM(x) | |
40 | 35 | #define LTC_ARGCHKVD(x) LTC_ARGCHK(x) |
41 | 36 | |
42 | 37 | #elif ARGTYPE == 4 |
58 | 58 | #define LTC_INLINE inline |
59 | 59 | #else |
60 | 60 | #define LTC_INLINE |
61 | #endif | |
62 | ||
63 | #if defined(__clang__) || defined(__GNUC_MINOR__) | |
64 | #define LTC_NORETURN __attribute__ ((noreturn)) | |
65 | #elif defined(_MSC_VER) | |
66 | #define LTC_NORETURN __declspec(noreturn) | |
67 | #else | |
68 | #define LTC_NORETURN | |
61 | 69 | #endif |
62 | 70 | |
63 | 71 | /* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */ |
553 | 553 | #endif |
554 | 554 | #endif |
555 | 555 | |
556 | #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) | |
556 | #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_SSH) | |
557 | 557 | /* Include the MPI functionality? (required by the PK algorithms) */ |
558 | 558 | #define LTC_MPI |
559 | 559 |
258 | 258 | /** the ECC params provided */ |
259 | 259 | extern const ltc_ecc_curve ltc_ecc_curves[]; |
260 | 260 | |
261 | int ecc_test(void); | |
262 | 261 | void ecc_sizes(int *low, int *high); |
263 | 262 | int ecc_get_size(const ecc_key *key); |
264 | 263 |
329 | 329 | |
330 | 330 | int der_utf8_valid_char(const wchar_t c); |
331 | 331 | |
332 | typedef int (*public_key_decode_cb)(const unsigned char *in, unsigned long inlen, void *ctx); | |
333 | ||
334 | int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned long inlen, | |
335 | enum ltc_oid_id algorithm, ltc_asn1_type param_type, | |
336 | ltc_asn1_list* parameters, unsigned long *parameters_len, | |
337 | public_key_decode_cb callback, void *ctx); | |
338 | ||
332 | 339 | /* SUBJECT PUBLIC KEY INFO */ |
333 | 340 | int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen, |
334 | 341 | unsigned int algorithm, const void* public_key, unsigned long public_key_len, |
88 | 88 | static int set_int(void *a, ltc_mp_digit b) |
89 | 89 | { |
90 | 90 | LTC_ARGCHK(a != NULL); |
91 | #ifdef BN_MP_SET_INT_C | |
91 | 92 | return mpi_to_ltc_error(mp_set_int(a, b)); |
93 | #else | |
94 | mp_set_u32(a, b); | |
95 | return CRYPT_OK; | |
96 | #endif | |
92 | 97 | } |
93 | 98 | |
94 | 99 | static unsigned long get_int(void *a) |
95 | 100 | { |
96 | 101 | LTC_ARGCHK(a != NULL); |
102 | #ifdef BN_MP_GET_INT_C | |
97 | 103 | return mp_get_int(a); |
104 | #else | |
105 | return mp_get_ul(a); | |
106 | #endif | |
98 | 107 | } |
99 | 108 | |
100 | 109 | static ltc_mp_digit get_digit(void *a, int n) |
411 | 420 | int err; |
412 | 421 | LTC_ARGCHK(a != NULL); |
413 | 422 | LTC_ARGCHK(c != NULL); |
414 | if (b == 0) { | |
415 | b = LTC_MILLER_RABIN_REPS; | |
416 | } /* if */ | |
423 | b = mp_prime_rabin_miller_trials(mp_count_bits(a)); | |
417 | 424 | err = mpi_to_ltc_error(mp_prime_is_prime(a, b, c)); |
418 | 425 | *c = (*c == MP_YES) ? LTC_MP_YES : LTC_MP_NO; |
419 | 426 | return err; |
425 | 432 | return mpi_to_ltc_error(mp_rand(a, size)); |
426 | 433 | } |
427 | 434 | |
435 | #ifndef MP_DIGIT_BIT | |
436 | #define MP_DIGIT_BIT DIGIT_BIT | |
437 | #endif | |
438 | ||
428 | 439 | const ltc_math_descriptor ltm_desc = { |
429 | 440 | |
430 | 441 | "LibTomMath", |
431 | (int)DIGIT_BIT, | |
442 | (int)MP_DIGIT_BIT, | |
432 | 443 | |
433 | 444 | &init, |
434 | 445 | &init_copy, |
98 | 98 | type = mode & LTC_PAD_MASK; |
99 | 99 | |
100 | 100 | if (*padded_length < l) { |
101 | #ifdef LTC_RNG_GET_BYTES | |
101 | 102 | if (type != LTC_PAD_ISO_10126) { |
102 | 103 | *padded_length = l; |
103 | 104 | } else { |
104 | 105 | *padded_length = length + 256; |
105 | 106 | } |
107 | #else | |
108 | *padded_length = l; | |
109 | #endif | |
106 | 110 | return CRYPT_BUFFER_OVERFLOW; |
107 | 111 | } |
108 | 112 |
120 | 120 | size = strlen(sdata); |
121 | 121 | STORE32H(size, out); |
122 | 122 | out += 4; |
123 | XSTRNCPY((char *)out, sdata, size); | |
123 | XMEMCPY(out, sdata, size); | |
124 | 124 | out += size; |
125 | 125 | break; |
126 | 126 | case LTC_SSHDATA_MPINT: |
0 | /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
1 | * | |
2 | * LibTomCrypt is a library that provides various cryptographic | |
3 | * algorithms in a highly modular and flexible manner. | |
4 | * | |
5 | * The library is free for all purposes without any express | |
6 | * guarantee it works. | |
7 | */ | |
8 | #include "tomcrypt_private.h" | |
9 | ||
10 | /** | |
11 | @file x509_decode_public_key_from_certificate.c | |
12 | ASN.1 DER/X.509, decode a certificate | |
13 | */ | |
14 | ||
15 | #ifdef LTC_DER | |
16 | ||
17 | /* Check if it looks like a SubjectPublicKeyInfo */ | |
18 | #define LOOKS_LIKE_SPKI(l) ((l) != NULL) \ | |
19 | && ((l)->type == LTC_ASN1_SEQUENCE) \ | |
20 | && ((l)->child != NULL) \ | |
21 | && ((l)->child->type == LTC_ASN1_OBJECT_IDENTIFIER) \ | |
22 | && ((l)->next != NULL) \ | |
23 | && ((l)->next->type == LTC_ASN1_BIT_STRING) | |
24 | ||
25 | /** | |
26 | Try to decode the public key from a X.509 certificate | |
27 | @param in The input buffer | |
28 | @param inlen The length of the input buffer | |
29 | @param algorithm One out of the enum #public_key_algorithms | |
30 | @param param_type The parameters' type out of the enum ltc_asn1_type | |
31 | @param parameters The parameters to include | |
32 | @param parameters_len [in/out] The number of parameters to include | |
33 | @param callback The callback | |
34 | @param ctx The context passed to the callback | |
35 | @return CRYPT_OK on success, CRYPT_NOP if no SubjectPublicKeyInfo was found | |
36 | */ | |
37 | int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned long inlen, | |
38 | enum ltc_oid_id algorithm, ltc_asn1_type param_type, | |
39 | ltc_asn1_list* parameters, unsigned long *parameters_len, | |
40 | public_key_decode_cb callback, void *ctx) | |
41 | { | |
42 | int err; | |
43 | unsigned char *tmpbuf; | |
44 | unsigned long tmpbuf_len, tmp_inlen; | |
45 | ltc_asn1_list *decoded_list = NULL, *l; | |
46 | ||
47 | LTC_ARGCHK(in != NULL); | |
48 | LTC_ARGCHK(inlen != 0); | |
49 | ||
50 | tmpbuf_len = inlen; | |
51 | tmpbuf = XCALLOC(1, tmpbuf_len); | |
52 | if (tmpbuf == NULL) { | |
53 | err = CRYPT_MEM; | |
54 | goto LBL_OUT; | |
55 | } | |
56 | ||
57 | tmp_inlen = inlen; | |
58 | if ((err = der_decode_sequence_flexi(in, &tmp_inlen, &decoded_list)) == CRYPT_OK) { | |
59 | l = decoded_list; | |
60 | ||
61 | err = CRYPT_NOP; | |
62 | ||
63 | /* Move 2 levels up in the tree | |
64 | SEQUENCE | |
65 | SEQUENCE | |
66 | ... | |
67 | */ | |
68 | if ((l->type == LTC_ASN1_SEQUENCE) && (l->child != NULL)) { | |
69 | l = l->child; | |
70 | if ((l->type == LTC_ASN1_SEQUENCE) && (l->child != NULL)) { | |
71 | l = l->child; | |
72 | ||
73 | /* Move forward in the tree until we find this combination | |
74 | ... | |
75 | SEQUENCE | |
76 | SEQUENCE | |
77 | OBJECT IDENTIFIER <some PKA OID, e.g. 1.2.840.113549.1.1.1> | |
78 | NULL | |
79 | BIT STRING | |
80 | */ | |
81 | do { | |
82 | /* The additional check for l->data is there to make sure | |
83 | * we won't try to decode a list that has been 'shrunk' | |
84 | */ | |
85 | if ((l->type == LTC_ASN1_SEQUENCE) | |
86 | && (l->data != NULL) | |
87 | && LOOKS_LIKE_SPKI(l->child)) { | |
88 | if (algorithm == PKA_EC) { | |
89 | err = ecc_import_subject_public_key_info(l->data, l->size, ctx); | |
90 | } else { | |
91 | err = x509_decode_subject_public_key_info(l->data, l->size, | |
92 | algorithm, tmpbuf, &tmpbuf_len, | |
93 | param_type, parameters, parameters_len); | |
94 | if (err == CRYPT_OK) { | |
95 | err = callback(tmpbuf, tmpbuf_len, ctx); | |
96 | goto LBL_OUT; | |
97 | } | |
98 | } | |
99 | } | |
100 | l = l->next; | |
101 | } while(l); | |
102 | } | |
103 | } | |
104 | } | |
105 | ||
106 | LBL_OUT: | |
107 | if (decoded_list) der_free_sequence_flexi(decoded_list); | |
108 | if (tmpbuf != NULL) XFREE(tmpbuf); | |
109 | ||
110 | return err; | |
111 | } | |
112 | ||
113 | #endif | |
114 | ||
115 | /* ref: $Format:%D$ */ | |
116 | /* git commit: $Format:%H$ */ | |
117 | /* commit time: $Format:%ai$ */ |
33 | 33 | @param public_key_len [in/out] The length of the public key buffer and the written length |
34 | 34 | @param parameters_type The parameters' type out of the enum ltc_asn1_type |
35 | 35 | @param parameters The parameters to include |
36 | @param parameters_len [in/out]The number of parameters to include | |
36 | @param parameters_len [in/out] The number of parameters to include | |
37 | 37 | @return CRYPT_OK on success |
38 | 38 | */ |
39 | 39 | int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen, |
41 | 41 | ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long *parameters_len) |
42 | 42 | { |
43 | 43 | int err; |
44 | unsigned long len, alg_id_num; | |
44 | unsigned long len, alg_id_num, tmplen; | |
45 | 45 | const char* oid; |
46 | 46 | unsigned char *tmpbuf; |
47 | 47 | unsigned long tmpoid[16]; |
48 | unsigned long *_parameters_len; | |
48 | 49 | ltc_asn1_list alg_id[2]; |
49 | 50 | ltc_asn1_list subject_pubkey[2]; |
50 | 51 | |
51 | 52 | LTC_ARGCHK(in != NULL); |
52 | 53 | LTC_ARGCHK(inlen != 0); |
53 | 54 | LTC_ARGCHK(public_key_len != NULL); |
55 | ||
54 | 56 | if (parameters_type != LTC_ASN1_EOL) { |
55 | LTC_ARGCHK(parameters_len != NULL); | |
57 | if ((parameters == NULL) || (parameters_len == NULL)) { | |
58 | tmplen = 0; | |
59 | _parameters_len = &tmplen; | |
60 | } else { | |
61 | _parameters_len = parameters_len; | |
62 | } | |
56 | 63 | } |
57 | 64 | |
58 | 65 | err = pk_get_oid(algorithm, &oid); |
71 | 78 | LTC_SET_ASN1(alg_id, 0, LTC_ASN1_OBJECT_IDENTIFIER, tmpoid, sizeof(tmpoid)/sizeof(tmpoid[0])); |
72 | 79 | if (parameters_type == LTC_ASN1_EOL) { |
73 | 80 | alg_id_num = 1; |
74 | } | |
75 | else { | |
76 | LTC_SET_ASN1(alg_id, 1, parameters_type, parameters, *parameters_len); | |
81 | } else { | |
82 | LTC_SET_ASN1(alg_id, 1, parameters_type, parameters, *_parameters_len); | |
77 | 83 | alg_id_num = 2; |
78 | 84 | } |
79 | 85 | |
88 | 94 | goto LBL_ERR; |
89 | 95 | } |
90 | 96 | if (parameters_type != LTC_ASN1_EOL) { |
91 | *parameters_len = alg_id[1].size; | |
97 | *_parameters_len = alg_id[1].size; | |
92 | 98 | } |
93 | 99 | |
94 | 100 | if ((err = pk_oid_cmp_with_asn1(oid, &alg_id[0])) != CRYPT_OK) { |
111 | 111 | */ |
112 | 112 | int ecc_import_x509(const unsigned char *in, unsigned long inlen, ecc_key *key) |
113 | 113 | { |
114 | int err; | |
115 | unsigned long len; | |
116 | ltc_asn1_list *decoded_list = NULL, *l; | |
117 | ||
118 | LTC_ARGCHK(in != NULL); | |
119 | LTC_ARGCHK(key != NULL); | |
120 | ||
121 | len = inlen; | |
122 | if ((err = der_decode_sequence_flexi(in, &len, &decoded_list)) == CRYPT_OK) { | |
123 | err = CRYPT_ERROR; | |
124 | l = decoded_list; | |
125 | if (l->type == LTC_ASN1_SEQUENCE && | |
126 | l->child && l->child->type == LTC_ASN1_SEQUENCE) { | |
127 | l = l->child->child; | |
128 | while (l) { | |
129 | if (l->type == LTC_ASN1_SEQUENCE && l->data && | |
130 | l->child && l->child->type == LTC_ASN1_SEQUENCE && | |
131 | l->child->child && l->child->child->type == LTC_ASN1_OBJECT_IDENTIFIER && | |
132 | l->child->next && l->child->next->type == LTC_ASN1_BIT_STRING) { | |
133 | err = ecc_import_subject_public_key_info(l->data, l->size, key); | |
134 | goto LBL_DONE; | |
135 | } | |
136 | l = l->next; | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
141 | LBL_DONE: | |
142 | if (decoded_list) der_free_sequence_flexi(decoded_list); | |
143 | return err; | |
114 | return x509_decode_public_key_from_certificate(in, inlen, PKA_EC, LTC_ASN1_EOL, NULL, NULL, NULL, key); | |
144 | 115 | } |
145 | 116 | |
146 | 117 | #endif /* LTC_MECC */ |
14 | 14 | |
15 | 15 | #ifdef LTC_MRSA |
16 | 16 | |
17 | static int _rsa_decode(const unsigned char *in, unsigned long inlen, rsa_key *key) | |
18 | { | |
19 | /* now it should be SEQUENCE { INTEGER, INTEGER } */ | |
20 | return der_decode_sequence_multi(in, inlen, | |
21 | LTC_ASN1_INTEGER, 1UL, key->N, | |
22 | LTC_ASN1_INTEGER, 1UL, key->e, | |
23 | LTC_ASN1_EOL, 0UL, NULL); | |
24 | } | |
25 | ||
17 | 26 | /** |
18 | 27 | Import an RSA key from a X.509 certificate |
19 | 28 | @param in The packet to import from |
24 | 33 | int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key) |
25 | 34 | { |
26 | 35 | int err; |
27 | unsigned char *tmpbuf; | |
28 | unsigned long tmpbuf_len, tmp_inlen, len; | |
29 | ltc_asn1_list *decoded_list = NULL, *l; | |
30 | 36 | |
31 | 37 | LTC_ARGCHK(in != NULL); |
32 | 38 | LTC_ARGCHK(key != NULL); |
38 | 44 | return err; |
39 | 45 | } |
40 | 46 | |
41 | tmpbuf_len = inlen; | |
42 | tmpbuf = XCALLOC(1, tmpbuf_len); | |
43 | if (tmpbuf == NULL) { | |
44 | err = CRYPT_MEM; | |
45 | goto LBL_ERR; | |
47 | if ((err = x509_decode_public_key_from_certificate(in, inlen, | |
48 | PKA_RSA, LTC_ASN1_NULL, | |
49 | NULL, NULL, | |
50 | (public_key_decode_cb)_rsa_decode, key)) != CRYPT_OK) { | |
51 | rsa_free(key); | |
52 | } else { | |
53 | key->type = PK_PUBLIC; | |
46 | 54 | } |
47 | ||
48 | tmp_inlen = inlen; | |
49 | if ((err = der_decode_sequence_flexi(in, &tmp_inlen, &decoded_list)) == CRYPT_OK) { | |
50 | l = decoded_list; | |
51 | /* Move 2 levels up in the tree | |
52 | SEQUENCE | |
53 | SEQUENCE | |
54 | ... | |
55 | */ | |
56 | if (l->type == LTC_ASN1_SEQUENCE && l->child) { | |
57 | l = l->child; | |
58 | if (l->type == LTC_ASN1_SEQUENCE && l->child) { | |
59 | l = l->child; | |
60 | ||
61 | err = CRYPT_ERROR; | |
62 | ||
63 | /* Move forward in the tree until we find this combination | |
64 | ... | |
65 | SEQUENCE | |
66 | SEQUENCE | |
67 | OBJECT IDENTIFIER 1.2.840.113549.1.1.1 | |
68 | NULL | |
69 | BIT STRING | |
70 | */ | |
71 | do { | |
72 | /* The additional check for l->data is there to make sure | |
73 | * we won't try to decode a list that has been 'shrunk' | |
74 | */ | |
75 | if (l->type == LTC_ASN1_SEQUENCE && l->data && l->child && | |
76 | l->child->type == LTC_ASN1_SEQUENCE && l->child->child && | |
77 | l->child->child->type == LTC_ASN1_OBJECT_IDENTIFIER && l->child->next && | |
78 | l->child->next->type == LTC_ASN1_BIT_STRING) { | |
79 | len = 0; | |
80 | err = x509_decode_subject_public_key_info(l->data, l->size, | |
81 | PKA_RSA, tmpbuf, &tmpbuf_len, | |
82 | LTC_ASN1_NULL, NULL, &len); | |
83 | if (err == CRYPT_OK) { | |
84 | /* now it should be SEQUENCE { INTEGER, INTEGER } */ | |
85 | if ((err = der_decode_sequence_multi(tmpbuf, tmpbuf_len, | |
86 | LTC_ASN1_INTEGER, 1UL, key->N, | |
87 | LTC_ASN1_INTEGER, 1UL, key->e, | |
88 | LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { | |
89 | goto LBL_ERR; | |
90 | } | |
91 | key->type = PK_PUBLIC; | |
92 | err = CRYPT_OK; | |
93 | goto LBL_FREE; | |
94 | } | |
95 | } | |
96 | l = l->next; | |
97 | } while(l); | |
98 | } | |
99 | } | |
100 | } | |
101 | ||
102 | ||
103 | LBL_ERR: | |
104 | rsa_free(key); | |
105 | ||
106 | LBL_FREE: | |
107 | if (decoded_list) der_free_sequence_flexi(decoded_list); | |
108 | if (tmpbuf != NULL) XFREE(tmpbuf); | |
109 | 55 | |
110 | 56 | return err; |
111 | 57 | } |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | static const struct { |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes the modular inverse via binary extended euclidean algorithm, |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes xR**-1 == x (mod N) via Montgomery Reduction |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Fast (comba) multiplier |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* this is a modified version of fast_s_mul_digs that only produces |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* the jist of squaring... |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes a = 2**b |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* b = |a| |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* high level addition (handles signs) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* single digit addition */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* d = a + b (mod c) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* AND two ints together */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* trim unused digits |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* clear one (frees) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | #include <stdarg.h> |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* compare two ints (signed)*/ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* compare a digit */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* compare maginitude of two ints (unsigned) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | static const int lnz[16] = { |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* b = ~a */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* copy, b = a */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* returns the number of bits in an int */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | #ifdef BN_MP_DIV_SMALL |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* b = a/2 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* shift right by a certain bit count (store quotient in c, optional remainder in d) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* divide by three (based on routine from MPI and the GMP manual) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | static int s_is_power_of_two(mp_digit b, int *p) |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines if a number is a valid DR modulus */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* reduce "x" in place modulo "n" using the Diminished Radix algorithm. |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines the setup value */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* swap the elements of two integers, for cases where you can't simply swap the |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* based on gmp's mpz_export. |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* wrapper function for mp_expt_d_ex() */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* calculate c = a**b using a square-multiply algorithm */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85 |
164 | 163 | } |
165 | 164 | |
166 | 165 | /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */ |
167 | if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) { | |
166 | if ((err = mp_copy(&M[1], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) { | |
168 | 167 | goto LBL_RES; |
169 | 168 | } |
170 | 169 | |
171 | 170 | for (x = 0; x < (winsize - 1); x++) { |
172 | if ((err = mp_sqr(&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) { | |
173 | goto LBL_RES; | |
174 | } | |
175 | if ((err = redux(&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) { | |
171 | if ((err = mp_sqr(&M[(size_t)1 << (winsize - 1)], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) { | |
172 | goto LBL_RES; | |
173 | } | |
174 | if ((err = redux(&M[(size_t)1 << (winsize - 1)], P, mp)) != MP_OKAY) { | |
176 | 175 | goto LBL_RES; |
177 | 176 | } |
178 | 177 | } |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Extended euclidean algorithm of (a, b) produces |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | #ifndef LTM_NO_FILE |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | #ifndef LTM_NO_FILE |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Greatest Common Divisor using the binary method */ |
0 | #include "tommath_private.h" | |
1 | #ifdef BN_MP_GET_BIT_C | |
2 | ||
3 | /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
4 | * | |
5 | * LibTomMath is a library that provides multiple-precision | |
6 | * integer arithmetic as well as number theoretic functionality. | |
7 | * | |
8 | * The library was designed directly after the MPI library by | |
9 | * Michael Fromberger but has been written from scratch with | |
10 | * additional optimizations in place. | |
11 | * | |
12 | * SPDX-License-Identifier: Unlicense | |
13 | */ | |
14 | ||
15 | /* Checks the bit at position b and returns MP_YES | |
16 | if the bit is 1, MP_NO if it is 0 and MP_VAL | |
17 | in case of error */ | |
18 | int mp_get_bit(const mp_int *a, int b) | |
19 | { | |
20 | int limb; | |
21 | mp_digit bit, isset; | |
22 | ||
23 | if (b < 0) { | |
24 | return MP_VAL; | |
25 | } | |
26 | ||
27 | limb = b / DIGIT_BIT; | |
28 | ||
29 | /* | |
30 | * Zero is a special value with the member "used" set to zero. | |
31 | * Needs to be tested before the check for the upper boundary | |
32 | * otherwise (limb >= a->used) would be true for a = 0 | |
33 | */ | |
34 | ||
35 | if (mp_iszero(a) != MP_NO) { | |
36 | return MP_NO; | |
37 | } | |
38 | ||
39 | if (limb >= a->used) { | |
40 | return MP_VAL; | |
41 | } | |
42 | ||
43 | bit = (mp_digit)(1) << (b % DIGIT_BIT); | |
44 | ||
45 | isset = a->dp[limb] & bit; | |
46 | return (isset != 0u) ? MP_YES : MP_NO; | |
47 | } | |
48 | ||
49 | #endif | |
50 | ||
51 | /* ref: $Format:%D$ */ | |
52 | /* git commit: $Format:%H$ */ | |
53 | /* commit time: $Format:%ai$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* get the lower 32-bits of an mp_int */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* get the lower unsigned long of an mp_int, platform dependent */ |
36 | 35 | return res; |
37 | 36 | } |
38 | 37 | #endif |
38 | ||
39 | /* ref: $Format:%D$ */ | |
40 | /* git commit: $Format:%H$ */ | |
41 | /* commit time: $Format:%ai$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* grow as required */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* based on gmp's mpz_import. |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* init a new mp_int */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* creates "a" then copies b into it */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | #include <stdarg.h> |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* initialize and set a digit */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* initialize and set a digit */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* init an mp_init for a given size */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* hac 14.61, pp608 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* hac 14.61, pp608 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Check if remainders are possible squares - fast exclude non-squares */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes the jacobi c = (a | n) (or Legendre if n is prime) |
16 | * HAC pp. 73 Algorithm 2.149 | |
17 | * HAC is wrong here, as the special case of (0 | 1) is not | |
18 | * handled correctly. | |
15 | * Kept for legacy reasons, please use mp_kronecker() instead | |
19 | 16 | */ |
20 | 17 | int mp_jacobi(const mp_int *a, const mp_int *n, int *c) |
21 | 18 | { |
22 | mp_int a1, p1; | |
23 | int k, s, r, res; | |
24 | mp_digit residue; | |
25 | ||
26 | 19 | /* if a < 0 return MP_VAL */ |
27 | 20 | if (mp_isneg(a) == MP_YES) { |
28 | 21 | return MP_VAL; |
33 | 26 | return MP_VAL; |
34 | 27 | } |
35 | 28 | |
36 | /* step 1. handle case of a == 0 */ | |
37 | if (mp_iszero(a) == MP_YES) { | |
38 | /* special case of a == 0 and n == 1 */ | |
39 | if (mp_cmp_d(n, 1uL) == MP_EQ) { | |
40 | *c = 1; | |
41 | } else { | |
42 | *c = 0; | |
43 | } | |
44 | return MP_OKAY; | |
45 | } | |
46 | ||
47 | /* step 2. if a == 1, return 1 */ | |
48 | if (mp_cmp_d(a, 1uL) == MP_EQ) { | |
49 | *c = 1; | |
50 | return MP_OKAY; | |
51 | } | |
52 | ||
53 | /* default */ | |
54 | s = 0; | |
55 | ||
56 | /* step 3. write a = a1 * 2**k */ | |
57 | if ((res = mp_init_copy(&a1, a)) != MP_OKAY) { | |
58 | return res; | |
59 | } | |
60 | ||
61 | if ((res = mp_init(&p1)) != MP_OKAY) { | |
62 | goto LBL_A1; | |
63 | } | |
64 | ||
65 | /* divide out larger power of two */ | |
66 | k = mp_cnt_lsb(&a1); | |
67 | if ((res = mp_div_2d(&a1, k, &a1, NULL)) != MP_OKAY) { | |
68 | goto LBL_P1; | |
69 | } | |
70 | ||
71 | /* step 4. if e is even set s=1 */ | |
72 | if (((unsigned)k & 1u) == 0u) { | |
73 | s = 1; | |
74 | } else { | |
75 | /* else set s=1 if p = 1/7 (mod 8) or s=-1 if p = 3/5 (mod 8) */ | |
76 | residue = n->dp[0] & 7u; | |
77 | ||
78 | if ((residue == 1u) || (residue == 7u)) { | |
79 | s = 1; | |
80 | } else if ((residue == 3u) || (residue == 5u)) { | |
81 | s = -1; | |
82 | } | |
83 | } | |
84 | ||
85 | /* step 5. if p == 3 (mod 4) *and* a1 == 3 (mod 4) then s = -s */ | |
86 | if (((n->dp[0] & 3u) == 3u) && ((a1.dp[0] & 3u) == 3u)) { | |
87 | s = -s; | |
88 | } | |
89 | ||
90 | /* if a1 == 1 we're done */ | |
91 | if (mp_cmp_d(&a1, 1uL) == MP_EQ) { | |
92 | *c = s; | |
93 | } else { | |
94 | /* n1 = n mod a1 */ | |
95 | if ((res = mp_mod(n, &a1, &p1)) != MP_OKAY) { | |
96 | goto LBL_P1; | |
97 | } | |
98 | if ((res = mp_jacobi(&p1, &a1, &r)) != MP_OKAY) { | |
99 | goto LBL_P1; | |
100 | } | |
101 | *c = s * r; | |
102 | } | |
103 | ||
104 | /* done */ | |
105 | res = MP_OKAY; | |
106 | LBL_P1: | |
107 | mp_clear(&p1); | |
108 | LBL_A1: | |
109 | mp_clear(&a1); | |
110 | return res; | |
29 | return mp_kronecker(a, n, c); | |
111 | 30 | } |
112 | 31 | #endif |
113 | 32 |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* c = |a| * |b| using Karatsuba Multiplication using |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Karatsuba squaring, computes b = a*a using three |
0 | #include "tommath_private.h" | |
1 | #ifdef BN_MP_KRONECKER_C | |
2 | ||
3 | /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
4 | * | |
5 | * LibTomMath is a library that provides multiple-precision | |
6 | * integer arithmetic as well as number theoretic functionality. | |
7 | * | |
8 | * The library was designed directly after the MPI library by | |
9 | * Michael Fromberger but has been written from scratch with | |
10 | * additional optimizations in place. | |
11 | * | |
12 | * SPDX-License-Identifier: Unlicense | |
13 | */ | |
14 | ||
15 | /* | |
16 | Kronecker symbol (a|p) | |
17 | Straightforward implementation of algorithm 1.4.10 in | |
18 | Henri Cohen: "A Course in Computational Algebraic Number Theory" | |
19 | ||
20 | @book{cohen2013course, | |
21 | title={A course in computational algebraic number theory}, | |
22 | author={Cohen, Henri}, | |
23 | volume={138}, | |
24 | year={2013}, | |
25 | publisher={Springer Science \& Business Media} | |
26 | } | |
27 | */ | |
28 | int mp_kronecker(const mp_int *a, const mp_int *p, int *c) | |
29 | { | |
30 | mp_int a1, p1, r; | |
31 | ||
32 | int e = MP_OKAY; | |
33 | int v, k; | |
34 | ||
35 | static const int table[8] = {0, 1, 0, -1, 0, -1, 0, 1}; | |
36 | ||
37 | if (mp_iszero(p) != MP_NO) { | |
38 | if ((a->used == 1) && (a->dp[0] == 1u)) { | |
39 | *c = 1; | |
40 | return e; | |
41 | } else { | |
42 | *c = 0; | |
43 | return e; | |
44 | } | |
45 | } | |
46 | ||
47 | if ((mp_iseven(a) != MP_NO) && (mp_iseven(p) != MP_NO)) { | |
48 | *c = 0; | |
49 | return e; | |
50 | } | |
51 | ||
52 | if ((e = mp_init_copy(&a1, a)) != MP_OKAY) { | |
53 | return e; | |
54 | } | |
55 | if ((e = mp_init_copy(&p1, p)) != MP_OKAY) { | |
56 | goto LBL_KRON_0; | |
57 | } | |
58 | ||
59 | v = mp_cnt_lsb(&p1); | |
60 | if ((e = mp_div_2d(&p1, v, &p1, NULL)) != MP_OKAY) { | |
61 | goto LBL_KRON_1; | |
62 | } | |
63 | ||
64 | if ((v & 0x1) == 0) { | |
65 | k = 1; | |
66 | } else { | |
67 | k = table[a->dp[0] & 7u]; | |
68 | } | |
69 | ||
70 | if (p1.sign == MP_NEG) { | |
71 | p1.sign = MP_ZPOS; | |
72 | if (a1.sign == MP_NEG) { | |
73 | k = -k; | |
74 | } | |
75 | } | |
76 | ||
77 | if ((e = mp_init(&r)) != MP_OKAY) { | |
78 | goto LBL_KRON_1; | |
79 | } | |
80 | ||
81 | for (;;) { | |
82 | if (mp_iszero(&a1) != MP_NO) { | |
83 | if (mp_cmp_d(&p1, 1uL) == MP_EQ) { | |
84 | *c = k; | |
85 | goto LBL_KRON; | |
86 | } else { | |
87 | *c = 0; | |
88 | goto LBL_KRON; | |
89 | } | |
90 | } | |
91 | ||
92 | v = mp_cnt_lsb(&a1); | |
93 | if ((e = mp_div_2d(&a1, v, &a1, NULL)) != MP_OKAY) { | |
94 | goto LBL_KRON; | |
95 | } | |
96 | ||
97 | if ((v & 0x1) == 1) { | |
98 | k = k * table[p1.dp[0] & 7u]; | |
99 | } | |
100 | ||
101 | if (a1.sign == MP_NEG) { | |
102 | /* | |
103 | * Compute k = (-1)^((a1)*(p1-1)/4) * k | |
104 | * a1.dp[0] + 1 cannot overflow because the MSB | |
105 | * of the type mp_digit is not set by definition | |
106 | */ | |
107 | if (((a1.dp[0] + 1u) & p1.dp[0] & 2u) != 0u) { | |
108 | k = -k; | |
109 | } | |
110 | } else { | |
111 | /* compute k = (-1)^((a1-1)*(p1-1)/4) * k */ | |
112 | if ((a1.dp[0] & p1.dp[0] & 2u) != 0u) { | |
113 | k = -k; | |
114 | } | |
115 | } | |
116 | ||
117 | if ((e = mp_copy(&a1, &r)) != MP_OKAY) { | |
118 | goto LBL_KRON; | |
119 | } | |
120 | r.sign = MP_ZPOS; | |
121 | if ((e = mp_mod(&p1, &r, &a1)) != MP_OKAY) { | |
122 | goto LBL_KRON; | |
123 | } | |
124 | if ((e = mp_copy(&r, &p1)) != MP_OKAY) { | |
125 | goto LBL_KRON; | |
126 | } | |
127 | } | |
128 | ||
129 | LBL_KRON: | |
130 | mp_clear(&r); | |
131 | LBL_KRON_1: | |
132 | mp_clear(&p1); | |
133 | LBL_KRON_0: | |
134 | mp_clear(&a1); | |
135 | ||
136 | return e; | |
137 | } | |
138 | ||
139 | #endif | |
140 | ||
141 | /* ref: $Format:%D$ */ | |
142 | /* git commit: $Format:%H$ */ | |
143 | /* commit time: $Format:%ai$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes least common multiple as |a*b|/(a, b) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* shift left a certain amount of digits */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* calc a value mod 2**b */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c) |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes xR**-1 == x (mod N) via Montgomery Reduction */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* setups the montgomery reduction stuff */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* high level multiplication (handles sign) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* b = a*2 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* shift left by a certain bit count */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* multiply by a digit */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* d = a * b (mod c) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* wrapper function for mp_n_root_ex() |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* find the n'th root of an integer |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* b = -a */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* OR two ints together */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* performs one Fermat test. |
0 | #include "tommath_private.h" | |
1 | #ifdef BN_MP_PRIME_FROBENIUS_UNDERWOOD_C | |
2 | ||
3 | /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
4 | * | |
5 | * LibTomMath is a library that provides multiple-precision | |
6 | * integer arithmetic as well as number theoretic functionality. | |
7 | * | |
8 | * The library was designed directly after the MPI library by | |
9 | * Michael Fromberger but has been written from scratch with | |
10 | * additional optimizations in place. | |
11 | * | |
12 | * SPDX-License-Identifier: Unlicense | |
13 | */ | |
14 | ||
15 | /* | |
16 | * See file bn_mp_prime_is_prime.c or the documentation in doc/bn.tex for the details | |
17 | */ | |
18 | #ifndef LTM_USE_FIPS_ONLY | |
19 | ||
20 | #ifdef MP_8BIT | |
21 | /* | |
22 | * floor of positive solution of | |
23 | * (2^16)-1 = (a+4)*(2*a+5) | |
24 | * TODO: Both values are smaller than N^(1/4), would have to use a bigint | |
25 | * for a instead but any a biger than about 120 are already so rare that | |
26 | * it is possible to ignore them and still get enough pseudoprimes. | |
27 | * But it is still a restriction of the set of available pseudoprimes | |
28 | * which makes this implementation less secure if used stand-alone. | |
29 | */ | |
30 | #define LTM_FROBENIUS_UNDERWOOD_A 177 | |
31 | #else | |
32 | #define LTM_FROBENIUS_UNDERWOOD_A 32764 | |
33 | #endif | |
34 | int mp_prime_frobenius_underwood(const mp_int *N, int *result) | |
35 | { | |
36 | mp_int T1z, T2z, Np1z, sz, tz; | |
37 | ||
38 | int a, ap2, length, i, j, isset; | |
39 | int e; | |
40 | ||
41 | *result = MP_NO; | |
42 | ||
43 | if ((e = mp_init_multi(&T1z, &T2z, &Np1z, &sz, &tz, NULL)) != MP_OKAY) { | |
44 | return e; | |
45 | } | |
46 | ||
47 | for (a = 0; a < LTM_FROBENIUS_UNDERWOOD_A; a++) { | |
48 | /* TODO: That's ugly! No, really, it is! */ | |
49 | if ((a==2) || (a==4) || (a==7) || (a==8) || (a==10) || | |
50 | (a==14) || (a==18) || (a==23) || (a==26) || (a==28)) { | |
51 | continue; | |
52 | } | |
53 | /* (32764^2 - 4) < 2^31, no bigint for >MP_8BIT needed) */ | |
54 | if ((e = mp_set_long(&T1z, (unsigned long)a)) != MP_OKAY) { | |
55 | goto LBL_FU_ERR; | |
56 | } | |
57 | ||
58 | if ((e = mp_sqr(&T1z, &T1z)) != MP_OKAY) { | |
59 | goto LBL_FU_ERR; | |
60 | } | |
61 | ||
62 | if ((e = mp_sub_d(&T1z, 4uL, &T1z)) != MP_OKAY) { | |
63 | goto LBL_FU_ERR; | |
64 | } | |
65 | ||
66 | if ((e = mp_kronecker(&T1z, N, &j)) != MP_OKAY) { | |
67 | goto LBL_FU_ERR; | |
68 | } | |
69 | ||
70 | if (j == -1) { | |
71 | break; | |
72 | } | |
73 | ||
74 | if (j == 0) { | |
75 | /* composite */ | |
76 | goto LBL_FU_ERR; | |
77 | } | |
78 | } | |
79 | /* Tell it a composite and set return value accordingly */ | |
80 | if (a >= LTM_FROBENIUS_UNDERWOOD_A) { | |
81 | e = MP_ITER; | |
82 | goto LBL_FU_ERR; | |
83 | } | |
84 | /* Composite if N and (a+4)*(2*a+5) are not coprime */ | |
85 | if ((e = mp_set_long(&T1z, (unsigned long)((a+4)*((2*a)+5)))) != MP_OKAY) { | |
86 | goto LBL_FU_ERR; | |
87 | } | |
88 | ||
89 | if ((e = mp_gcd(N, &T1z, &T1z)) != MP_OKAY) { | |
90 | goto LBL_FU_ERR; | |
91 | } | |
92 | ||
93 | if (!((T1z.used == 1) && (T1z.dp[0] == 1u))) { | |
94 | goto LBL_FU_ERR; | |
95 | } | |
96 | ||
97 | ap2 = a + 2; | |
98 | if ((e = mp_add_d(N, 1uL, &Np1z)) != MP_OKAY) { | |
99 | goto LBL_FU_ERR; | |
100 | } | |
101 | ||
102 | mp_set(&sz, 1uL); | |
103 | mp_set(&tz, 2uL); | |
104 | length = mp_count_bits(&Np1z); | |
105 | ||
106 | for (i = length - 2; i >= 0; i--) { | |
107 | /* | |
108 | * temp = (sz*(a*sz+2*tz))%N; | |
109 | * tz = ((tz-sz)*(tz+sz))%N; | |
110 | * sz = temp; | |
111 | */ | |
112 | if ((e = mp_mul_2(&tz, &T2z)) != MP_OKAY) { | |
113 | goto LBL_FU_ERR; | |
114 | } | |
115 | ||
116 | /* a = 0 at about 50% of the cases (non-square and odd input) */ | |
117 | if (a != 0) { | |
118 | if ((e = mp_mul_d(&sz, (mp_digit)a, &T1z)) != MP_OKAY) { | |
119 | goto LBL_FU_ERR; | |
120 | } | |
121 | if ((e = mp_add(&T1z, &T2z, &T2z)) != MP_OKAY) { | |
122 | goto LBL_FU_ERR; | |
123 | } | |
124 | } | |
125 | ||
126 | if ((e = mp_mul(&T2z, &sz, &T1z)) != MP_OKAY) { | |
127 | goto LBL_FU_ERR; | |
128 | } | |
129 | if ((e = mp_sub(&tz, &sz, &T2z)) != MP_OKAY) { | |
130 | goto LBL_FU_ERR; | |
131 | } | |
132 | if ((e = mp_add(&sz, &tz, &sz)) != MP_OKAY) { | |
133 | goto LBL_FU_ERR; | |
134 | } | |
135 | if ((e = mp_mul(&sz, &T2z, &tz)) != MP_OKAY) { | |
136 | goto LBL_FU_ERR; | |
137 | } | |
138 | if ((e = mp_mod(&tz, N, &tz)) != MP_OKAY) { | |
139 | goto LBL_FU_ERR; | |
140 | } | |
141 | if ((e = mp_mod(&T1z, N, &sz)) != MP_OKAY) { | |
142 | goto LBL_FU_ERR; | |
143 | } | |
144 | if ((isset = mp_get_bit(&Np1z, i)) == MP_VAL) { | |
145 | e = isset; | |
146 | goto LBL_FU_ERR; | |
147 | } | |
148 | if (isset == MP_YES) { | |
149 | /* | |
150 | * temp = (a+2) * sz + tz | |
151 | * tz = 2 * tz - sz | |
152 | * sz = temp | |
153 | */ | |
154 | if (a == 0) { | |
155 | if ((e = mp_mul_2(&sz, &T1z)) != MP_OKAY) { | |
156 | goto LBL_FU_ERR; | |
157 | } | |
158 | } else { | |
159 | if ((e = mp_mul_d(&sz, (mp_digit)ap2, &T1z)) != MP_OKAY) { | |
160 | goto LBL_FU_ERR; | |
161 | } | |
162 | } | |
163 | if ((e = mp_add(&T1z, &tz, &T1z)) != MP_OKAY) { | |
164 | goto LBL_FU_ERR; | |
165 | } | |
166 | if ((e = mp_mul_2(&tz, &T2z)) != MP_OKAY) { | |
167 | goto LBL_FU_ERR; | |
168 | } | |
169 | if ((e = mp_sub(&T2z, &sz, &tz)) != MP_OKAY) { | |
170 | goto LBL_FU_ERR; | |
171 | } | |
172 | mp_exch(&sz, &T1z); | |
173 | } | |
174 | } | |
175 | ||
176 | if ((e = mp_set_long(&T1z, (unsigned long)((2 * a) + 5))) != MP_OKAY) { | |
177 | goto LBL_FU_ERR; | |
178 | } | |
179 | if ((e = mp_mod(&T1z, N, &T1z)) != MP_OKAY) { | |
180 | goto LBL_FU_ERR; | |
181 | } | |
182 | if ((mp_iszero(&sz) != MP_NO) && (mp_cmp(&tz, &T1z) == MP_EQ)) { | |
183 | *result = MP_YES; | |
184 | goto LBL_FU_ERR; | |
185 | } | |
186 | ||
187 | LBL_FU_ERR: | |
188 | mp_clear_multi(&tz, &sz, &Np1z, &T2z, &T1z, NULL); | |
189 | return e; | |
190 | } | |
191 | ||
192 | #endif | |
193 | #endif | |
194 | ||
195 | /* ref: $Format:%D$ */ | |
196 | /* git commit: $Format:%H$ */ | |
197 | /* commit time: $Format:%ai$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines if an integers is divisible by one |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | /* performs a variable number of rounds of Miller-Rabin | |
16 | * | |
17 | * Probability of error after t rounds is no more than | |
18 | ||
19 | * | |
20 | * Sets result to 1 if probably prime, 0 otherwise | |
21 | */ | |
14 | /* portable integer log of two with small footprint */ | |
15 | static unsigned int s_floor_ilog2(int value) | |
16 | { | |
17 | unsigned int r = 0; | |
18 | while ((value >>= 1) != 0) { | |
19 | r++; | |
20 | } | |
21 | return r; | |
22 | } | |
23 | ||
24 | ||
22 | 25 | int mp_prime_is_prime(const mp_int *a, int t, int *result) |
23 | 26 | { |
24 | 27 | mp_int b; |
25 | int ix, err, res; | |
28 | int ix, err, res, p_max = 0, size_a, len; | |
29 | unsigned int fips_rand, mask; | |
26 | 30 | |
27 | 31 | /* default to no */ |
28 | 32 | *result = MP_NO; |
29 | 33 | |
30 | 34 | /* valid value of t? */ |
31 | if ((t <= 0) || (t > PRIME_SIZE)) { | |
35 | if (t > PRIME_SIZE) { | |
32 | 36 | return MP_VAL; |
37 | } | |
38 | ||
39 | /* Some shortcuts */ | |
40 | /* N > 3 */ | |
41 | if (a->used == 1) { | |
42 | if ((a->dp[0] == 0u) || (a->dp[0] == 1u)) { | |
43 | *result = 0; | |
44 | return MP_OKAY; | |
45 | } | |
46 | if (a->dp[0] == 2u) { | |
47 | *result = 1; | |
48 | return MP_OKAY; | |
49 | } | |
50 | } | |
51 | ||
52 | /* N must be odd */ | |
53 | if (mp_iseven(a) == MP_YES) { | |
54 | return MP_OKAY; | |
55 | } | |
56 | /* N is not a perfect square: floor(sqrt(N))^2 != N */ | |
57 | if ((err = mp_is_square(a, &res)) != MP_OKAY) { | |
58 | return err; | |
59 | } | |
60 | if (res != 0) { | |
61 | return MP_OKAY; | |
33 | 62 | } |
34 | 63 | |
35 | 64 | /* is the input equal to one of the primes in the table? */ |
36 | 65 | for (ix = 0; ix < PRIME_SIZE; ix++) { |
37 | 66 | if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) { |
38 | *result = 1; | |
67 | *result = MP_YES; | |
39 | 68 | return MP_OKAY; |
40 | 69 | } |
41 | 70 | } |
71 | #ifdef MP_8BIT | |
72 | /* The search in the loop above was exhaustive in this case */ | |
73 | if (a->used == 1 && PRIME_SIZE >= 31) { | |
74 | return MP_OKAY; | |
75 | } | |
76 | #endif | |
42 | 77 | |
43 | 78 | /* first perform trial division */ |
44 | 79 | if ((err = mp_prime_is_divisible(a, &res)) != MP_OKAY) { |
50 | 85 | return MP_OKAY; |
51 | 86 | } |
52 | 87 | |
53 | /* now perform the miller-rabin rounds */ | |
54 | if ((err = mp_init(&b)) != MP_OKAY) { | |
88 | /* | |
89 | Run the Miller-Rabin test with base 2 for the BPSW test. | |
90 | */ | |
91 | if ((err = mp_init_set(&b, 2uL)) != MP_OKAY) { | |
55 | 92 | return err; |
56 | 93 | } |
57 | 94 | |
58 | for (ix = 0; ix < t; ix++) { | |
59 | /* set the prime */ | |
60 | mp_set(&b, ltm_prime_tab[ix]); | |
61 | ||
62 | if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { | |
63 | goto LBL_B; | |
64 | } | |
65 | ||
95 | if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { | |
96 | goto LBL_B; | |
97 | } | |
98 | if (res == MP_NO) { | |
99 | goto LBL_B; | |
100 | } | |
101 | /* | |
102 | Rumours have it that Mathematica does a second M-R test with base 3. | |
103 | Other rumours have it that their strong L-S test is slightly different. | |
104 | It does not hurt, though, beside a bit of extra runtime. | |
105 | */ | |
106 | b.dp[0]++; | |
107 | if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { | |
108 | goto LBL_B; | |
109 | } | |
110 | if (res == MP_NO) { | |
111 | goto LBL_B; | |
112 | } | |
113 | ||
114 | /* | |
115 | * Both, the Frobenius-Underwood test and the the Lucas-Selfridge test are quite | |
116 | * slow so if speed is an issue, define LTM_USE_FIPS_ONLY to use M-R tests with | |
117 | * bases 2, 3 and t random bases. | |
118 | */ | |
119 | #ifndef LTM_USE_FIPS_ONLY | |
120 | if (t >= 0) { | |
121 | /* | |
122 | * Use a Frobenius-Underwood test instead of the Lucas-Selfridge test for | |
123 | * MP_8BIT (It is unknown if the Lucas-Selfridge test works with 16-bit | |
124 | * integers but the necesssary analysis is on the todo-list). | |
125 | */ | |
126 | #if defined (MP_8BIT) || defined (LTM_USE_FROBENIUS_TEST) | |
127 | err = mp_prime_frobenius_underwood(a, &res); | |
128 | if (err != MP_OKAY && err != MP_ITER) { | |
129 | goto LBL_B; | |
130 | } | |
66 | 131 | if (res == MP_NO) { |
67 | 132 | goto LBL_B; |
133 | } | |
134 | #else | |
135 | if ((err = mp_prime_strong_lucas_selfridge(a, &res)) != MP_OKAY) { | |
136 | goto LBL_B; | |
137 | } | |
138 | if (res == MP_NO) { | |
139 | goto LBL_B; | |
140 | } | |
141 | #endif | |
142 | } | |
143 | #endif | |
144 | ||
145 | /* run at least one Miller-Rabin test with a random base */ | |
146 | if (t == 0) { | |
147 | t = 1; | |
148 | } | |
149 | ||
150 | /* | |
151 | abs(t) extra rounds of M-R to extend the range of primes it can find if t < 0. | |
152 | Only recommended if the input range is known to be < 3317044064679887385961981 | |
153 | ||
154 | It uses the bases for a deterministic M-R test if input < 3317044064679887385961981 | |
155 | The caller has to check the size. | |
156 | ||
157 | Not for cryptographic use because with known bases strong M-R pseudoprimes can | |
158 | be constructed. Use at least one M-R test with a random base (t >= 1). | |
159 | ||
160 | The 1119 bit large number | |
161 | ||
162 | 80383745745363949125707961434194210813883768828755814583748891752229742737653\ | |
163 | 33652186502336163960045457915042023603208766569966760987284043965408232928738\ | |
164 | 79185086916685732826776177102938969773947016708230428687109997439976544144845\ | |
165 | 34115587245063340927902227529622941498423068816854043264575340183297861112989\ | |
166 | 60644845216191652872597534901 | |
167 | ||
168 | has been constructed by F. Arnault (F. Arnault, "Rabin-Miller primality test: | |
169 | composite numbers which pass it.", Mathematics of Computation, 1995, 64. Jg., | |
170 | Nr. 209, S. 355-361), is a semiprime with the two factors | |
171 | ||
172 | 40095821663949960541830645208454685300518816604113250877450620473800321707011\ | |
173 | 96242716223191597219733582163165085358166969145233813917169287527980445796800\ | |
174 | 452592031836601 | |
175 | ||
176 | 20047910831974980270915322604227342650259408302056625438725310236900160853505\ | |
177 | 98121358111595798609866791081582542679083484572616906958584643763990222898400\ | |
178 | 226296015918301 | |
179 | ||
180 | and it is a strong pseudoprime to all forty-six prime M-R bases up to 200 | |
181 | ||
182 | It does not fail the strong Bailley-PSP test as implemented here, it is just | |
183 | given as an example, if not the reason to use the BPSW-test instead of M-R-tests | |
184 | with a sequence of primes 2...n. | |
185 | ||
186 | */ | |
187 | if (t < 0) { | |
188 | t = -t; | |
189 | /* | |
190 | Sorenson, Jonathan; Webster, Jonathan (2015). | |
191 | "Strong Pseudoprimes to Twelve Prime Bases". | |
192 | */ | |
193 | /* 0x437ae92817f9fc85b7e5 = 318665857834031151167461 */ | |
194 | if ((err = mp_read_radix(&b, "437ae92817f9fc85b7e5", 16)) != MP_OKAY) { | |
195 | goto LBL_B; | |
196 | } | |
197 | ||
198 | if (mp_cmp(a, &b) == MP_LT) { | |
199 | p_max = 12; | |
200 | } else { | |
201 | /* 0x2be6951adc5b22410a5fd = 3317044064679887385961981 */ | |
202 | if ((err = mp_read_radix(&b, "2be6951adc5b22410a5fd", 16)) != MP_OKAY) { | |
203 | goto LBL_B; | |
204 | } | |
205 | ||
206 | if (mp_cmp(a, &b) == MP_LT) { | |
207 | p_max = 13; | |
208 | } else { | |
209 | err = MP_VAL; | |
210 | goto LBL_B; | |
211 | } | |
212 | } | |
213 | ||
214 | /* for compatibility with the current API (well, compatible within a sign's width) */ | |
215 | if (p_max < t) { | |
216 | p_max = t; | |
217 | } | |
218 | ||
219 | if (p_max > PRIME_SIZE) { | |
220 | err = MP_VAL; | |
221 | goto LBL_B; | |
222 | } | |
223 | /* we did bases 2 and 3 already, skip them */ | |
224 | for (ix = 2; ix < p_max; ix++) { | |
225 | mp_set(&b, ltm_prime_tab[ix]); | |
226 | if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { | |
227 | goto LBL_B; | |
228 | } | |
229 | if (res == MP_NO) { | |
230 | goto LBL_B; | |
231 | } | |
232 | } | |
233 | } | |
234 | /* | |
235 | Do "t" M-R tests with random bases between 3 and "a". | |
236 | See Fips 186.4 p. 126ff | |
237 | */ | |
238 | else if (t > 0) { | |
239 | /* | |
240 | * The mp_digit's have a defined bit-size but the size of the | |
241 | * array a.dp is a simple 'int' and this library can not assume full | |
242 | * compliance to the current C-standard (ISO/IEC 9899:2011) because | |
243 | * it gets used for small embeded processors, too. Some of those MCUs | |
244 | * have compilers that one cannot call standard compliant by any means. | |
245 | * Hence the ugly type-fiddling in the following code. | |
246 | */ | |
247 | size_a = mp_count_bits(a); | |
248 | mask = (1u << s_floor_ilog2(size_a)) - 1u; | |
249 | /* | |
250 | Assuming the General Rieman hypothesis (never thought to write that in a | |
251 | comment) the upper bound can be lowered to 2*(log a)^2. | |
252 | E. Bach, "Explicit bounds for primality testing and related problems," | |
253 | Math. Comp. 55 (1990), 355-380. | |
254 | ||
255 | size_a = (size_a/10) * 7; | |
256 | len = 2 * (size_a * size_a); | |
257 | ||
258 | E.g.: a number of size 2^2048 would be reduced to the upper limit | |
259 | ||
260 | floor(2048/10)*7 = 1428 | |
261 | 2 * 1428^2 = 4078368 | |
262 | ||
263 | (would have been ~4030331.9962 with floats and natural log instead) | |
264 | That number is smaller than 2^28, the default bit-size of mp_digit. | |
265 | */ | |
266 | ||
267 | /* | |
268 | How many tests, you might ask? Dana Jacobsen of Math::Prime::Util fame | |
269 | does exactly 1. In words: one. Look at the end of _GMP_is_prime() in | |
270 | Math-Prime-Util-GMP-0.50/primality.c if you do not believe it. | |
271 | ||
272 | The function mp_rand() goes to some length to use a cryptographically | |
273 | good PRNG. That also means that the chance to always get the same base | |
274 | in the loop is non-zero, although very low. | |
275 | If the BPSW test and/or the addtional Frobenious test have been | |
276 | performed instead of just the Miller-Rabin test with the bases 2 and 3, | |
277 | a single extra test should suffice, so such a very unlikely event | |
278 | will not do much harm. | |
279 | ||
280 | To preemptivly answer the dangling question: no, a witness does not | |
281 | need to be prime. | |
282 | */ | |
283 | for (ix = 0; ix < t; ix++) { | |
284 | /* mp_rand() guarantees the first digit to be non-zero */ | |
285 | if ((err = mp_rand(&b, 1)) != MP_OKAY) { | |
286 | goto LBL_B; | |
287 | } | |
288 | /* | |
289 | * Reduce digit before casting because mp_digit might be bigger than | |
290 | * an unsigned int and "mask" on the other side is most probably not. | |
291 | */ | |
292 | fips_rand = (unsigned int)(b.dp[0] & (mp_digit) mask); | |
293 | #ifdef MP_8BIT | |
294 | /* | |
295 | * One 8-bit digit is too small, so concatenate two if the size of | |
296 | * unsigned int allows for it. | |
297 | */ | |
298 | if ((sizeof(unsigned int) * CHAR_BIT)/2 >= (sizeof(mp_digit) * CHAR_BIT)) { | |
299 | if ((err = mp_rand(&b, 1)) != MP_OKAY) { | |
300 | goto LBL_B; | |
301 | } | |
302 | fips_rand <<= sizeof(mp_digit) * CHAR_BIT; | |
303 | fips_rand |= (unsigned int) b.dp[0]; | |
304 | fips_rand &= mask; | |
305 | } | |
306 | #endif | |
307 | /* Ceil, because small numbers have a right to live, too, */ | |
308 | len = (((int)fips_rand + DIGIT_BIT) / DIGIT_BIT); | |
309 | /* Unlikely. */ | |
310 | if (len < 0) { | |
311 | ix--; | |
312 | continue; | |
313 | } | |
314 | /* | |
315 | * As mentioned above, one 8-bit digit is too small and | |
316 | * although it can only happen in the unlikely case that | |
317 | * an "unsigned int" is smaller than 16 bit a simple test | |
318 | * is cheap and the correction even cheaper. | |
319 | */ | |
320 | #ifdef MP_8BIT | |
321 | /* All "a" < 2^8 have been caught before */ | |
322 | if (len == 1) { | |
323 | len++; | |
324 | } | |
325 | #endif | |
326 | if ((err = mp_rand(&b, len)) != MP_OKAY) { | |
327 | goto LBL_B; | |
328 | } | |
329 | /* | |
330 | * That number might got too big and the witness has to be | |
331 | * smaller than or equal to "a" | |
332 | */ | |
333 | len = mp_count_bits(&b); | |
334 | if (len > size_a) { | |
335 | len = len - size_a; | |
336 | if ((err = mp_div_2d(&b, len, &b, NULL)) != MP_OKAY) { | |
337 | goto LBL_B; | |
338 | } | |
339 | } | |
340 | ||
341 | /* Although the chance for b <= 3 is miniscule, try again. */ | |
342 | if (mp_cmp_d(&b, 3uL) != MP_GT) { | |
343 | ix--; | |
344 | continue; | |
345 | } | |
346 | if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { | |
347 | goto LBL_B; | |
348 | } | |
349 | if (res == MP_NO) { | |
350 | goto LBL_B; | |
351 | } | |
68 | 352 | } |
69 | 353 | } |
70 | 354 | |
74 | 358 | mp_clear(&b); |
75 | 359 | return err; |
76 | 360 | } |
361 | ||
77 | 362 | #endif |
78 | 363 | |
79 | 364 | /* ref: $Format:%D$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Miller-Rabin test of "a" to the base of "b" as described in |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* finds the next prime after the number "a" using "t" trials |
22 | 21 | int err, res = MP_NO, x, y; |
23 | 22 | mp_digit res_tab[PRIME_SIZE], step, kstep; |
24 | 23 | mp_int b; |
25 | ||
26 | /* ensure t is valid */ | |
27 | if ((t <= 0) || (t > PRIME_SIZE)) { | |
28 | return MP_VAL; | |
29 | } | |
30 | 24 | |
31 | 25 | /* force positive */ |
32 | 26 | a->sign = MP_ZPOS; |
140 | 134 | continue; |
141 | 135 | } |
142 | 136 | |
143 | /* is this prime? */ | |
144 | for (x = 0; x < t; x++) { | |
145 | mp_set(&b, ltm_prime_tab[x]); | |
146 | if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { | |
147 | goto LBL_ERR; | |
148 | } | |
149 | if (res == MP_NO) { | |
150 | break; | |
151 | } | |
137 | if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { | |
138 | goto LBL_ERR; | |
152 | 139 | } |
153 | ||
154 | 140 | if (res == MP_YES) { |
155 | 141 | break; |
156 | 142 | } |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | |
16 | 15 | static const struct { |
17 | 16 | int k, t; |
18 | 17 | } sizes[] = { |
19 | { 128, 28 }, | |
18 | { 80, -1 }, /* Use deterministic algorithm for size <= 80 bits */ | |
19 | { 81, 39 }, | |
20 | { 96, 37 }, | |
21 | { 128, 32 }, | |
22 | { 160, 27 }, | |
23 | { 192, 21 }, | |
20 | 24 | { 256, 16 }, |
21 | 25 | { 384, 10 }, |
22 | 26 | { 512, 7 }, |
23 | 27 | { 640, 6 }, |
24 | 28 | { 768, 5 }, |
25 | 29 | { 896, 4 }, |
26 | { 1024, 4 } | |
30 | { 1024, 4 }, | |
31 | { 2048, 2 }, | |
32 | { 4096, 1 }, | |
27 | 33 | }; |
28 | 34 | |
29 | /* returns # of RM trials required for a given bit size */ | |
35 | /* returns # of RM trials required for a given bit size and max. error of 2^(-96)*/ | |
30 | 36 | int mp_prime_rabin_miller_trials(int size) |
31 | 37 | { |
32 | 38 | int x; |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* makes a truly random prime of a given size (bits), |
0 | #include "tommath_private.h" | |
1 | #ifdef BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C | |
2 | ||
3 | /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
4 | * | |
5 | * LibTomMath is a library that provides multiple-precision | |
6 | * integer arithmetic as well as number theoretic functionality. | |
7 | * | |
8 | * The library was designed directly after the MPI library by | |
9 | * Michael Fromberger but has been written from scratch with | |
10 | * additional optimizations in place. | |
11 | * | |
12 | * SPDX-License-Identifier: Unlicense | |
13 | */ | |
14 | ||
15 | /* | |
16 | * See file bn_mp_prime_is_prime.c or the documentation in doc/bn.tex for the details | |
17 | */ | |
18 | #ifndef LTM_USE_FIPS_ONLY | |
19 | ||
20 | /* | |
21 | * 8-bit is just too small. You can try the Frobenius test | |
22 | * but that frobenius test can fail, too, for the same reason. | |
23 | */ | |
24 | #ifndef MP_8BIT | |
25 | ||
26 | /* | |
27 | * multiply bigint a with int d and put the result in c | |
28 | * Like mp_mul_d() but with a signed long as the small input | |
29 | */ | |
30 | static int s_mp_mul_si(const mp_int *a, long d, mp_int *c) | |
31 | { | |
32 | mp_int t; | |
33 | int err, neg = 0; | |
34 | ||
35 | if ((err = mp_init(&t)) != MP_OKAY) { | |
36 | return err; | |
37 | } | |
38 | if (d < 0) { | |
39 | neg = 1; | |
40 | d = -d; | |
41 | } | |
42 | ||
43 | /* | |
44 | * mp_digit might be smaller than a long, which excludes | |
45 | * the use of mp_mul_d() here. | |
46 | */ | |
47 | if ((err = mp_set_long(&t, (unsigned long) d)) != MP_OKAY) { | |
48 | goto LBL_MPMULSI_ERR; | |
49 | } | |
50 | if ((err = mp_mul(a, &t, c)) != MP_OKAY) { | |
51 | goto LBL_MPMULSI_ERR; | |
52 | } | |
53 | if (neg == 1) { | |
54 | c->sign = (a->sign == MP_NEG) ? MP_ZPOS: MP_NEG; | |
55 | } | |
56 | LBL_MPMULSI_ERR: | |
57 | mp_clear(&t); | |
58 | return err; | |
59 | } | |
60 | ||
61 | ||
62 | ||
63 | /* | |
64 | Strong Lucas-Selfridge test. | |
65 | returns MP_YES if it is a strong L-S prime, MP_NO if it is composite | |
66 | ||
67 | Code ported from Thomas Ray Nicely's implementation of the BPSW test | |
68 | at http://www.trnicely.net/misc/bpsw.html | |
69 | ||
70 | Freeware copyright (C) 2016 Thomas R. Nicely <http://www.trnicely.net>. | |
71 | Released into the public domain by the author, who disclaims any legal | |
72 | liability arising from its use | |
73 | ||
74 | The multi-line comments are made by Thomas R. Nicely and are copied verbatim. | |
75 | Additional comments marked "CZ" (without the quotes) are by the code-portist. | |
76 | ||
77 | (If that name sounds familiar, he is the guy who found the fdiv bug in the | |
78 | Pentium (P5x, I think) Intel processor) | |
79 | */ | |
80 | int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result) | |
81 | { | |
82 | /* CZ TODO: choose better variable names! */ | |
83 | mp_int Dz, gcd, Np1, Uz, Vz, U2mz, V2mz, Qmz, Q2mz, Qkdz, T1z, T2z, T3z, T4z, Q2kdz; | |
84 | /* CZ TODO: Some of them need the full 32 bit, hence the (temporary) exclusion of MP_8BIT */ | |
85 | int D, Ds, J, sign, P, Q, r, s, u, Nbits; | |
86 | int e; | |
87 | int isset; | |
88 | ||
89 | *result = MP_NO; | |
90 | ||
91 | /* | |
92 | Find the first element D in the sequence {5, -7, 9, -11, 13, ...} | |
93 | such that Jacobi(D,N) = -1 (Selfridge's algorithm). Theory | |
94 | indicates that, if N is not a perfect square, D will "nearly | |
95 | always" be "small." Just in case, an overflow trap for D is | |
96 | included. | |
97 | */ | |
98 | ||
99 | if ((e = mp_init_multi(&Dz, &gcd, &Np1, &Uz, &Vz, &U2mz, &V2mz, &Qmz, &Q2mz, &Qkdz, &T1z, &T2z, &T3z, &T4z, &Q2kdz, | |
100 | NULL)) != MP_OKAY) { | |
101 | return e; | |
102 | } | |
103 | ||
104 | D = 5; | |
105 | sign = 1; | |
106 | ||
107 | for (;;) { | |
108 | Ds = sign * D; | |
109 | sign = -sign; | |
110 | if ((e = mp_set_long(&Dz, (unsigned long)D)) != MP_OKAY) { | |
111 | goto LBL_LS_ERR; | |
112 | } | |
113 | if ((e = mp_gcd(a, &Dz, &gcd)) != MP_OKAY) { | |
114 | goto LBL_LS_ERR; | |
115 | } | |
116 | /* if 1 < GCD < N then N is composite with factor "D", and | |
117 | Jacobi(D,N) is technically undefined (but often returned | |
118 | as zero). */ | |
119 | if ((mp_cmp_d(&gcd, 1uL) == MP_GT) && (mp_cmp(&gcd, a) == MP_LT)) { | |
120 | goto LBL_LS_ERR; | |
121 | } | |
122 | if (Ds < 0) { | |
123 | Dz.sign = MP_NEG; | |
124 | } | |
125 | if ((e = mp_kronecker(&Dz, a, &J)) != MP_OKAY) { | |
126 | goto LBL_LS_ERR; | |
127 | } | |
128 | ||
129 | if (J == -1) { | |
130 | break; | |
131 | } | |
132 | D += 2; | |
133 | ||
134 | if (D > (INT_MAX - 2)) { | |
135 | e = MP_VAL; | |
136 | goto LBL_LS_ERR; | |
137 | } | |
138 | } | |
139 | ||
140 | P = 1; /* Selfridge's choice */ | |
141 | Q = (1 - Ds) / 4; /* Required so D = P*P - 4*Q */ | |
142 | ||
143 | /* NOTE: The conditions (a) N does not divide Q, and | |
144 | (b) D is square-free or not a perfect square, are included by | |
145 | some authors; e.g., "Prime numbers and computer methods for | |
146 | factorization," Hans Riesel (2nd ed., 1994, Birkhauser, Boston), | |
147 | p. 130. For this particular application of Lucas sequences, | |
148 | these conditions were found to be immaterial. */ | |
149 | ||
150 | /* Now calculate N - Jacobi(D,N) = N + 1 (even), and calculate the | |
151 | odd positive integer d and positive integer s for which | |
152 | N + 1 = 2^s*d (similar to the step for N - 1 in Miller's test). | |
153 | The strong Lucas-Selfridge test then returns N as a strong | |
154 | Lucas probable prime (slprp) if any of the following | |
155 | conditions is met: U_d=0, V_d=0, V_2d=0, V_4d=0, V_8d=0, | |
156 | V_16d=0, ..., etc., ending with V_{2^(s-1)*d}=V_{(N+1)/2}=0 | |
157 | (all equalities mod N). Thus d is the highest index of U that | |
158 | must be computed (since V_2m is independent of U), compared | |
159 | to U_{N+1} for the standard Lucas-Selfridge test; and no | |
160 | index of V beyond (N+1)/2 is required, just as in the | |
161 | standard Lucas-Selfridge test. However, the quantity Q^d must | |
162 | be computed for use (if necessary) in the latter stages of | |
163 | the test. The result is that the strong Lucas-Selfridge test | |
164 | has a running time only slightly greater (order of 10 %) than | |
165 | that of the standard Lucas-Selfridge test, while producing | |
166 | only (roughly) 30 % as many pseudoprimes (and every strong | |
167 | Lucas pseudoprime is also a standard Lucas pseudoprime). Thus | |
168 | the evidence indicates that the strong Lucas-Selfridge test is | |
169 | more effective than the standard Lucas-Selfridge test, and a | |
170 | Baillie-PSW test based on the strong Lucas-Selfridge test | |
171 | should be more reliable. */ | |
172 | ||
173 | if ((e = mp_add_d(a, 1uL, &Np1)) != MP_OKAY) { | |
174 | goto LBL_LS_ERR; | |
175 | } | |
176 | s = mp_cnt_lsb(&Np1); | |
177 | ||
178 | /* CZ | |
179 | * This should round towards zero because | |
180 | * Thomas R. Nicely used GMP's mpz_tdiv_q_2exp() | |
181 | * and mp_div_2d() is equivalent. Additionally: | |
182 | * dividing an even number by two does not produce | |
183 | * any leftovers. | |
184 | */ | |
185 | if ((e = mp_div_2d(&Np1, s, &Dz, NULL)) != MP_OKAY) { | |
186 | goto LBL_LS_ERR; | |
187 | } | |
188 | /* We must now compute U_d and V_d. Since d is odd, the accumulated | |
189 | values U and V are initialized to U_1 and V_1 (if the target | |
190 | index were even, U and V would be initialized instead to U_0=0 | |
191 | and V_0=2). The values of U_2m and V_2m are also initialized to | |
192 | U_1 and V_1; the FOR loop calculates in succession U_2 and V_2, | |
193 | U_4 and V_4, U_8 and V_8, etc. If the corresponding bits | |
194 | (1, 2, 3, ...) of t are on (the zero bit having been accounted | |
195 | for in the initialization of U and V), these values are then | |
196 | combined with the previous totals for U and V, using the | |
197 | composition formulas for addition of indices. */ | |
198 | ||
199 | mp_set(&Uz, 1uL); /* U=U_1 */ | |
200 | mp_set(&Vz, (mp_digit)P); /* V=V_1 */ | |
201 | mp_set(&U2mz, 1uL); /* U_1 */ | |
202 | mp_set(&V2mz, (mp_digit)P); /* V_1 */ | |
203 | ||
204 | if (Q < 0) { | |
205 | Q = -Q; | |
206 | if ((e = mp_set_long(&Qmz, (unsigned long)Q)) != MP_OKAY) { | |
207 | goto LBL_LS_ERR; | |
208 | } | |
209 | if ((e = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) { | |
210 | goto LBL_LS_ERR; | |
211 | } | |
212 | /* Initializes calculation of Q^d */ | |
213 | if ((e = mp_set_long(&Qkdz, (unsigned long)Q)) != MP_OKAY) { | |
214 | goto LBL_LS_ERR; | |
215 | } | |
216 | Qmz.sign = MP_NEG; | |
217 | Q2mz.sign = MP_NEG; | |
218 | Qkdz.sign = MP_NEG; | |
219 | Q = -Q; | |
220 | } else { | |
221 | if ((e = mp_set_long(&Qmz, (unsigned long)Q)) != MP_OKAY) { | |
222 | goto LBL_LS_ERR; | |
223 | } | |
224 | if ((e = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) { | |
225 | goto LBL_LS_ERR; | |
226 | } | |
227 | /* Initializes calculation of Q^d */ | |
228 | if ((e = mp_set_long(&Qkdz, (unsigned long)Q)) != MP_OKAY) { | |
229 | goto LBL_LS_ERR; | |
230 | } | |
231 | } | |
232 | ||
233 | Nbits = mp_count_bits(&Dz); | |
234 | for (u = 1; u < Nbits; u++) { /* zero bit off, already accounted for */ | |
235 | /* Formulas for doubling of indices (carried out mod N). Note that | |
236 | * the indices denoted as "2m" are actually powers of 2, specifically | |
237 | * 2^(ul-1) beginning each loop and 2^ul ending each loop. | |
238 | * | |
239 | * U_2m = U_m*V_m | |
240 | * V_2m = V_m*V_m - 2*Q^m | |
241 | */ | |
242 | ||
243 | if ((e = mp_mul(&U2mz, &V2mz, &U2mz)) != MP_OKAY) { | |
244 | goto LBL_LS_ERR; | |
245 | } | |
246 | if ((e = mp_mod(&U2mz, a, &U2mz)) != MP_OKAY) { | |
247 | goto LBL_LS_ERR; | |
248 | } | |
249 | if ((e = mp_sqr(&V2mz, &V2mz)) != MP_OKAY) { | |
250 | goto LBL_LS_ERR; | |
251 | } | |
252 | if ((e = mp_sub(&V2mz, &Q2mz, &V2mz)) != MP_OKAY) { | |
253 | goto LBL_LS_ERR; | |
254 | } | |
255 | if ((e = mp_mod(&V2mz, a, &V2mz)) != MP_OKAY) { | |
256 | goto LBL_LS_ERR; | |
257 | } | |
258 | /* Must calculate powers of Q for use in V_2m, also for Q^d later */ | |
259 | if ((e = mp_sqr(&Qmz, &Qmz)) != MP_OKAY) { | |
260 | goto LBL_LS_ERR; | |
261 | } | |
262 | /* prevents overflow */ /* CZ still necessary without a fixed prealloc'd mem.? */ | |
263 | if ((e = mp_mod(&Qmz, a, &Qmz)) != MP_OKAY) { | |
264 | goto LBL_LS_ERR; | |
265 | } | |
266 | if ((e = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) { | |
267 | goto LBL_LS_ERR; | |
268 | } | |
269 | ||
270 | if ((isset = mp_get_bit(&Dz, u)) == MP_VAL) { | |
271 | e = isset; | |
272 | goto LBL_LS_ERR; | |
273 | } | |
274 | if (isset == MP_YES) { | |
275 | /* Formulas for addition of indices (carried out mod N); | |
276 | * | |
277 | * U_(m+n) = (U_m*V_n + U_n*V_m)/2 | |
278 | * V_(m+n) = (V_m*V_n + D*U_m*U_n)/2 | |
279 | * | |
280 | * Be careful with division by 2 (mod N)! | |
281 | */ | |
282 | ||
283 | if ((e = mp_mul(&U2mz, &Vz, &T1z)) != MP_OKAY) { | |
284 | goto LBL_LS_ERR; | |
285 | } | |
286 | if ((e = mp_mul(&Uz, &V2mz, &T2z)) != MP_OKAY) { | |
287 | goto LBL_LS_ERR; | |
288 | } | |
289 | if ((e = mp_mul(&V2mz, &Vz, &T3z)) != MP_OKAY) { | |
290 | goto LBL_LS_ERR; | |
291 | } | |
292 | if ((e = mp_mul(&U2mz, &Uz, &T4z)) != MP_OKAY) { | |
293 | goto LBL_LS_ERR; | |
294 | } | |
295 | if ((e = s_mp_mul_si(&T4z, (long)Ds, &T4z)) != MP_OKAY) { | |
296 | goto LBL_LS_ERR; | |
297 | } | |
298 | if ((e = mp_add(&T1z, &T2z, &Uz)) != MP_OKAY) { | |
299 | goto LBL_LS_ERR; | |
300 | } | |
301 | if (mp_isodd(&Uz) != MP_NO) { | |
302 | if ((e = mp_add(&Uz, a, &Uz)) != MP_OKAY) { | |
303 | goto LBL_LS_ERR; | |
304 | } | |
305 | } | |
306 | /* CZ | |
307 | * This should round towards negative infinity because | |
308 | * Thomas R. Nicely used GMP's mpz_fdiv_q_2exp(). | |
309 | * But mp_div_2() does not do so, it is truncating instead. | |
310 | */ | |
311 | if ((e = mp_div_2(&Uz, &Uz)) != MP_OKAY) { | |
312 | goto LBL_LS_ERR; | |
313 | } | |
314 | if ((Uz.sign == MP_NEG) && (mp_isodd(&Uz) != MP_NO)) { | |
315 | if ((e = mp_sub_d(&Uz, 1uL, &Uz)) != MP_OKAY) { | |
316 | goto LBL_LS_ERR; | |
317 | } | |
318 | } | |
319 | if ((e = mp_add(&T3z, &T4z, &Vz)) != MP_OKAY) { | |
320 | goto LBL_LS_ERR; | |
321 | } | |
322 | if (mp_isodd(&Vz) != MP_NO) { | |
323 | if ((e = mp_add(&Vz, a, &Vz)) != MP_OKAY) { | |
324 | goto LBL_LS_ERR; | |
325 | } | |
326 | } | |
327 | if ((e = mp_div_2(&Vz, &Vz)) != MP_OKAY) { | |
328 | goto LBL_LS_ERR; | |
329 | } | |
330 | if ((Vz.sign == MP_NEG) && (mp_isodd(&Vz) != MP_NO)) { | |
331 | if ((e = mp_sub_d(&Vz, 1uL, &Vz)) != MP_OKAY) { | |
332 | goto LBL_LS_ERR; | |
333 | } | |
334 | } | |
335 | if ((e = mp_mod(&Uz, a, &Uz)) != MP_OKAY) { | |
336 | goto LBL_LS_ERR; | |
337 | } | |
338 | if ((e = mp_mod(&Vz, a, &Vz)) != MP_OKAY) { | |
339 | goto LBL_LS_ERR; | |
340 | } | |
341 | /* Calculating Q^d for later use */ | |
342 | if ((e = mp_mul(&Qkdz, &Qmz, &Qkdz)) != MP_OKAY) { | |
343 | goto LBL_LS_ERR; | |
344 | } | |
345 | if ((e = mp_mod(&Qkdz, a, &Qkdz)) != MP_OKAY) { | |
346 | goto LBL_LS_ERR; | |
347 | } | |
348 | } | |
349 | } | |
350 | ||
351 | /* If U_d or V_d is congruent to 0 mod N, then N is a prime or a | |
352 | strong Lucas pseudoprime. */ | |
353 | if ((mp_iszero(&Uz) != MP_NO) || (mp_iszero(&Vz) != MP_NO)) { | |
354 | *result = MP_YES; | |
355 | goto LBL_LS_ERR; | |
356 | } | |
357 | ||
358 | /* NOTE: Ribenboim ("The new book of prime number records," 3rd ed., | |
359 | 1995/6) omits the condition V0 on p.142, but includes it on | |
360 | p. 130. The condition is NECESSARY; otherwise the test will | |
361 | return false negatives---e.g., the primes 29 and 2000029 will be | |
362 | returned as composite. */ | |
363 | ||
364 | /* Otherwise, we must compute V_2d, V_4d, V_8d, ..., V_{2^(s-1)*d} | |
365 | by repeated use of the formula V_2m = V_m*V_m - 2*Q^m. If any of | |
366 | these are congruent to 0 mod N, then N is a prime or a strong | |
367 | Lucas pseudoprime. */ | |
368 | ||
369 | /* Initialize 2*Q^(d*2^r) for V_2m */ | |
370 | if ((e = mp_mul_2(&Qkdz, &Q2kdz)) != MP_OKAY) { | |
371 | goto LBL_LS_ERR; | |
372 | } | |
373 | ||
374 | for (r = 1; r < s; r++) { | |
375 | if ((e = mp_sqr(&Vz, &Vz)) != MP_OKAY) { | |
376 | goto LBL_LS_ERR; | |
377 | } | |
378 | if ((e = mp_sub(&Vz, &Q2kdz, &Vz)) != MP_OKAY) { | |
379 | goto LBL_LS_ERR; | |
380 | } | |
381 | if ((e = mp_mod(&Vz, a, &Vz)) != MP_OKAY) { | |
382 | goto LBL_LS_ERR; | |
383 | } | |
384 | if (mp_iszero(&Vz) != MP_NO) { | |
385 | *result = MP_YES; | |
386 | goto LBL_LS_ERR; | |
387 | } | |
388 | /* Calculate Q^{d*2^r} for next r (final iteration irrelevant). */ | |
389 | if (r < (s - 1)) { | |
390 | if ((e = mp_sqr(&Qkdz, &Qkdz)) != MP_OKAY) { | |
391 | goto LBL_LS_ERR; | |
392 | } | |
393 | if ((e = mp_mod(&Qkdz, a, &Qkdz)) != MP_OKAY) { | |
394 | goto LBL_LS_ERR; | |
395 | } | |
396 | if ((e = mp_mul_2(&Qkdz, &Q2kdz)) != MP_OKAY) { | |
397 | goto LBL_LS_ERR; | |
398 | } | |
399 | } | |
400 | } | |
401 | LBL_LS_ERR: | |
402 | mp_clear_multi(&Q2kdz, &T4z, &T3z, &T2z, &T1z, &Qkdz, &Q2mz, &Qmz, &V2mz, &U2mz, &Vz, &Uz, &Np1, &gcd, &Dz, NULL); | |
403 | return e; | |
404 | } | |
405 | #endif | |
406 | #endif | |
407 | #endif | |
408 | ||
409 | /* ref: $Format:%D$ */ | |
410 | /* git commit: $Format:%H$ */ | |
411 | /* commit time: $Format:%ai$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* returns size of ASCII reprensentation */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* chars used in radix conversions */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* First the OS-specific special cases |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* read a string [ASCII] in a given radix */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* read signed bin, big endian, first byte is 0==positive or 1==negative */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* reads a unsigned char array, assumes the msb is stored first [big endian] */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* reduces x mod m, assumes 0 < x < m**2, mu is |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* reduces a modulo n where n is of the form 2**p - d */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* reduces a modulo n where n is of the form 2**p - d |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines the setup value */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines the setup value */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines if mp_reduce_2k can be used */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* determines if reduce_2k_l can be used */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* pre-calculate the value required for Barrett reduction |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* shift right a certain amount of digits */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* set to a digit */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* set a 32-bit const */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* set a platform dependent unsigned long int */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* shrink a bignum */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* get the size for an signed equivalent */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* computes b = a*a */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* c = a * a (mod b) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* this function is less generic than mp_n_root, simpler and faster */ |
4 | 4 | * LibTomMath is a library that provides multiple-precision |
5 | 5 | * integer arithmetic as well as number theoretic functionality. |
6 | 6 | * |
7 | * The library is free for all purposes without any express | |
8 | * guarantee it works. | |
7 | * The library was designed directly after the MPI library by | |
8 | * Michael Fromberger but has been written from scratch with | |
9 | * additional optimizations in place. | |
10 | * | |
11 | * SPDX-License-Identifier: Unlicense | |
9 | 12 | */ |
10 | 13 | |
11 | 14 | /* Tonelli-Shanks algorithm |
121 | 124 | } |
122 | 125 | |
123 | 126 | #endif |
127 | ||
128 | /* ref: $Format:%D$ */ | |
129 | /* git commit: $Format:%H$ */ | |
130 | /* commit time: $Format:%ai$ */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* high level subtraction (handles signs) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* single digit subtraction */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* d = a - b (mod c) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* two complement and */ |
16 | 15 | int mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c) |
17 | 16 | { |
18 | int res = MP_OKAY, bits; | |
17 | int res = MP_OKAY, bits, abits, bbits; | |
19 | 18 | int as = mp_isneg(a), bs = mp_isneg(b); |
20 | 19 | mp_int *mx = NULL, _mx, acpy, bcpy; |
21 | 20 | |
22 | 21 | if ((as != MP_NO) || (bs != MP_NO)) { |
23 | bits = MAX(mp_count_bits(a), mp_count_bits(b)); | |
22 | abits = mp_count_bits(a); | |
23 | bbits = mp_count_bits(b); | |
24 | bits = MAX(abits, bbits); | |
24 | 25 | res = mp_init_set_int(&_mx, 1uL); |
25 | 26 | if (res != MP_OKAY) { |
26 | 27 | goto end; |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* two complement right shift */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* two complement or */ |
16 | 15 | int mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c) |
17 | 16 | { |
18 | int res = MP_OKAY, bits; | |
17 | int res = MP_OKAY, bits, abits, bbits; | |
19 | 18 | int as = mp_isneg(a), bs = mp_isneg(b); |
20 | 19 | mp_int *mx = NULL, _mx, acpy, bcpy; |
21 | 20 | |
22 | 21 | if ((as != MP_NO) || (bs != MP_NO)) { |
23 | bits = MAX(mp_count_bits(a), mp_count_bits(b)); | |
22 | abits = mp_count_bits(a); | |
23 | bbits = mp_count_bits(b); | |
24 | bits = MAX(abits, bbits); | |
24 | 25 | res = mp_init_set_int(&_mx, 1uL); |
25 | 26 | if (res != MP_OKAY) { |
26 | 27 | goto end; |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* two complement xor */ |
16 | 15 | int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c) |
17 | 16 | { |
18 | int res = MP_OKAY, bits; | |
17 | int res = MP_OKAY, bits, abits, bbits; | |
19 | 18 | int as = mp_isneg(a), bs = mp_isneg(b); |
20 | 19 | mp_int *mx = NULL, _mx, acpy, bcpy; |
21 | 20 | |
22 | 21 | if ((as != MP_NO) || (bs != MP_NO)) { |
23 | bits = MAX(mp_count_bits(a), mp_count_bits(b)); | |
22 | abits = mp_count_bits(a); | |
23 | bbits = mp_count_bits(b); | |
24 | bits = MAX(abits, bbits); | |
24 | 25 | res = mp_init_set_int(&_mx, 1uL); |
25 | 26 | if (res != MP_OKAY) { |
26 | 27 | goto end; |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* store in signed [big endian] format */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* store in signed [big endian] format */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* store in unsigned [big endian] format */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* store in unsigned [big endian] format */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* multiplication using the Toom-Cook 3-way algorithm |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* squaring using Toom-Cook 3-way algorithm */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* stores a bignum as a ASCII string in a given radix (2..64) */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* stores a bignum as a ASCII string in a given radix (2..64) |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* get the size for an unsigned equivalent */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* XOR two ints together */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* set to zero */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | const mp_digit ltm_prime_tab[] = { |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* reverse an array, used for radix code */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* low level addition, based on HAC pp.594, Algorithm 14.7 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | #ifdef MP_LOW_MEM |
98 | 97 | /* compute the value at M[1<<(winsize-1)] by squaring |
99 | 98 | * M[1] (winsize-1) times |
100 | 99 | */ |
101 | if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) { | |
100 | if ((err = mp_copy(&M[1], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) { | |
102 | 101 | goto LBL_MU; |
103 | 102 | } |
104 | 103 | |
105 | 104 | for (x = 0; x < (winsize - 1); x++) { |
106 | 105 | /* square it */ |
107 | if ((err = mp_sqr(&M[1 << (winsize - 1)], | |
108 | &M[1 << (winsize - 1)])) != MP_OKAY) { | |
106 | if ((err = mp_sqr(&M[(size_t)1 << (winsize - 1)], | |
107 | &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) { | |
109 | 108 | goto LBL_MU; |
110 | 109 | } |
111 | 110 | |
112 | 111 | /* reduce modulo P */ |
113 | if ((err = redux(&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) { | |
112 | if ((err = redux(&M[(size_t)1 << (winsize - 1)], P, &mu)) != MP_OKAY) { | |
114 | 113 | goto LBL_MU; |
115 | 114 | } |
116 | 115 | } |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* multiplies |a| * |b| and only computes upto digs digits of result |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* multiplies |a| * |b| and does not compute the lower digs digits |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */ |
8 | 8 | * Michael Fromberger but has been written from scratch with |
9 | 9 | * additional optimizations in place. |
10 | 10 | * |
11 | * The library is free for all purposes without any express | |
12 | * guarantee it works. | |
11 | * SPDX-License-Identifier: Unlicense | |
13 | 12 | */ |
14 | 13 | |
15 | 14 | /* Known optimal configurations |
6 | 6 | * Michael Fromberger but has been written from scratch with |
7 | 7 | * additional optimizations in place. |
8 | 8 | * |
9 | * The library is free for all purposes without any express | |
10 | * guarantee it works. | |
9 | * SPDX-License-Identifier: Unlicense | |
11 | 10 | */ |
12 | 11 | #ifndef BN_H_ |
13 | 12 | #define BN_H_ |
16 | 15 | #include <stdlib.h> |
17 | 16 | #include <limits.h> |
18 | 17 | |
19 | #include <tommath_class.h> | |
18 | #include "tommath_class.h" | |
20 | 19 | |
21 | 20 | #ifdef __cplusplus |
22 | 21 | extern "C" { |
35 | 34 | defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \ |
36 | 35 | defined(__LP64__) || defined(_LP64) || defined(__64BIT__) |
37 | 36 | # if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) |
38 | # if defined(__GNUC__) | |
37 | # if defined(__GNUC__) && !defined(__hppa) | |
39 | 38 | /* we support 128bit integers only via: __attribute__((mode(TI))) */ |
40 | 39 | # define MP_64BIT |
41 | 40 | # else |
117 | 116 | #define MP_MEM -2 /* out of mem */ |
118 | 117 | #define MP_VAL -3 /* invalid input */ |
119 | 118 | #define MP_RANGE MP_VAL |
119 | #define MP_ITER -4 /* Max. iterations reached */ | |
120 | 120 | |
121 | 121 | #define MP_YES 1 /* yes response */ |
122 | 122 | #define MP_NO 0 /* no response */ |
203 | 203 | /* set to a digit */ |
204 | 204 | void mp_set(mp_int *a, mp_digit b); |
205 | 205 | |
206 | /* set a double */ | |
207 | int mp_set_double(mp_int *a, double b); | |
208 | ||
206 | 209 | /* set a 32-bit const */ |
207 | 210 | int mp_set_int(mp_int *a, unsigned long b); |
208 | 211 | |
211 | 214 | |
212 | 215 | /* set a platform dependent unsigned long long value */ |
213 | 216 | /* int mp_set_long_long(mp_int *a, unsigned long long b); */ |
217 | ||
218 | /* get a double */ | |
219 | double mp_get_double(const mp_int *a); | |
214 | 220 | |
215 | 221 | /* get a 32-bit value */ |
216 | 222 | unsigned long mp_get_int(const mp_int *a); |
294 | 300 | /* c = a AND b */ |
295 | 301 | int mp_and(const mp_int *a, const mp_int *b, mp_int *c); |
296 | 302 | |
303 | /* Checks the bit at position b and returns MP_YES | |
304 | if the bit is 1, MP_NO if it is 0 and MP_VAL | |
305 | in case of error */ | |
306 | int mp_get_bit(const mp_int *a, int b); | |
307 | ||
297 | 308 | /* c = a XOR b (two complement) */ |
298 | 309 | int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c); |
299 | 310 | |
412 | 423 | |
413 | 424 | /* computes the jacobi c = (a | n) (or Legendre if b is prime) */ |
414 | 425 | int mp_jacobi(const mp_int *a, const mp_int *n, int *c); |
426 | ||
427 | /* computes the Kronecker symbol c = (a | p) (like jacobi() but with {a,p} in Z */ | |
428 | int mp_kronecker(const mp_int *a, const mp_int *p, int *c); | |
415 | 429 | |
416 | 430 | /* used to setup the Barrett reduction for a given modulus b */ |
417 | 431 | int mp_reduce_setup(mp_int *a, const mp_int *b); |
494 | 508 | */ |
495 | 509 | int mp_prime_rabin_miller_trials(int size); |
496 | 510 | |
497 | /* performs t rounds of Miller-Rabin on "a" using the first | |
498 | * t prime bases. Also performs an initial sieve of trial | |
511 | /* performs one strong Lucas-Selfridge test of "a". | |
512 | * Sets result to 0 if composite or 1 if probable prime | |
513 | */ | |
514 | int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result); | |
515 | ||
516 | /* performs one Frobenius test of "a" as described by Paul Underwood. | |
517 | * Sets result to 0 if composite or 1 if probable prime | |
518 | */ | |
519 | int mp_prime_frobenius_underwood(const mp_int *N, int *result); | |
520 | ||
521 | /* performs t random rounds of Miller-Rabin on "a" additional to | |
522 | * bases 2 and 3. Also performs an initial sieve of trial | |
499 | 523 | * division. Determines if "a" is prime with probability |
500 | 524 | * of error no more than (1/4)**t. |
525 | * Both a strong Lucas-Selfridge to complete the BPSW test | |
526 | * and a separate Frobenius test are available at compile time. | |
527 | * With t<0 a deterministic test is run for primes up to | |
528 | * 318665857834031151167461. With t<13 (abs(t)-13) additional | |
529 | * tests with sequential small primes are run starting at 43. | |
530 | * Is Fips 186.4 compliant if called with t as computed by | |
531 | * mp_prime_rabin_miller_trials(); | |
501 | 532 | * |
502 | 533 | * Sets result to 1 if probably prime, 0 otherwise |
503 | 534 | */ |
0 | /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
1 | * | |
2 | * LibTomMath is a library that provides multiple-precision | |
3 | * integer arithmetic as well as number theoretic functionality. | |
4 | * | |
5 | * The library was designed directly after the MPI library by | |
6 | * Michael Fromberger but has been written from scratch with | |
7 | * additional optimizations in place. | |
8 | * | |
9 | * SPDX-License-Identifier: Unlicense | |
10 | */ | |
11 | ||
0 | 12 | #if !(defined(LTM1) && defined(LTM2) && defined(LTM3)) |
1 | 13 | #if defined(LTM2) |
2 | 14 | # define LTM3 |
47 | 59 | # define BN_MP_FREAD_C |
48 | 60 | # define BN_MP_FWRITE_C |
49 | 61 | # define BN_MP_GCD_C |
62 | # define BN_MP_GET_BIT_C | |
63 | # define BN_MP_GET_DOUBLE_C | |
50 | 64 | # define BN_MP_GET_INT_C |
51 | 65 | # define BN_MP_GET_LONG_C |
52 | 66 | # define BN_MP_GET_LONG_LONG_C |
64 | 78 | # define BN_MP_JACOBI_C |
65 | 79 | # define BN_MP_KARATSUBA_MUL_C |
66 | 80 | # define BN_MP_KARATSUBA_SQR_C |
81 | # define BN_MP_KRONECKER_C | |
67 | 82 | # define BN_MP_LCM_C |
68 | 83 | # define BN_MP_LSHD_C |
69 | 84 | # define BN_MP_MOD_C |
82 | 97 | # define BN_MP_NEG_C |
83 | 98 | # define BN_MP_OR_C |
84 | 99 | # define BN_MP_PRIME_FERMAT_C |
100 | # define BN_MP_PRIME_FROBENIUS_UNDERWOOD_C | |
85 | 101 | # define BN_MP_PRIME_IS_DIVISIBLE_C |
86 | 102 | # define BN_MP_PRIME_IS_PRIME_C |
87 | 103 | # define BN_MP_PRIME_MILLER_RABIN_C |
88 | 104 | # define BN_MP_PRIME_NEXT_PRIME_C |
89 | 105 | # define BN_MP_PRIME_RABIN_MILLER_TRIALS_C |
90 | 106 | # define BN_MP_PRIME_RANDOM_EX_C |
107 | # define BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C | |
91 | 108 | # define BN_MP_RADIX_SIZE_C |
92 | 109 | # define BN_MP_RADIX_SMAP_C |
93 | 110 | # define BN_MP_RAND_C |
104 | 121 | # define BN_MP_REDUCE_SETUP_C |
105 | 122 | # define BN_MP_RSHD_C |
106 | 123 | # define BN_MP_SET_C |
124 | # define BN_MP_SET_DOUBLE_C | |
107 | 125 | # define BN_MP_SET_INT_C |
108 | 126 | # define BN_MP_SET_LONG_C |
109 | 127 | # define BN_MP_SET_LONG_LONG_C |
159 | 177 | # define BN_MP_CMP_C |
160 | 178 | # define BN_MP_CMP_D_C |
161 | 179 | # define BN_MP_ADD_C |
180 | # define BN_MP_CMP_MAG_C | |
162 | 181 | # define BN_MP_EXCH_C |
163 | 182 | # define BN_MP_CLEAR_MULTI_C |
164 | 183 | #endif |
424 | 443 | # define BN_MP_CLEAR_C |
425 | 444 | #endif |
426 | 445 | |
446 | #if defined(BN_MP_GET_BIT_C) | |
447 | # define BN_MP_ISZERO_C | |
448 | #endif | |
449 | ||
450 | #if defined(BN_MP_GET_DOUBLE_C) | |
451 | # define BN_MP_ISNEG_C | |
452 | #endif | |
453 | ||
427 | 454 | #if defined(BN_MP_GET_INT_C) |
428 | 455 | #endif |
429 | 456 | |
508 | 535 | #endif |
509 | 536 | |
510 | 537 | #if defined(BN_MP_JACOBI_C) |
538 | # define BN_MP_KRONECKER_C | |
511 | 539 | # define BN_MP_ISNEG_C |
512 | 540 | # define BN_MP_CMP_D_C |
513 | # define BN_MP_ISZERO_C | |
514 | # define BN_MP_INIT_COPY_C | |
515 | # define BN_MP_CNT_LSB_C | |
516 | # define BN_MP_DIV_2D_C | |
517 | # define BN_MP_MOD_C | |
518 | # define BN_MP_CLEAR_C | |
519 | 541 | #endif |
520 | 542 | |
521 | 543 | #if defined(BN_MP_KARATSUBA_MUL_C) |
537 | 559 | # define BN_S_MP_SUB_C |
538 | 560 | # define BN_MP_LSHD_C |
539 | 561 | # define BN_MP_ADD_C |
562 | # define BN_MP_CLEAR_C | |
563 | #endif | |
564 | ||
565 | #if defined(BN_MP_KRONECKER_C) | |
566 | # define BN_MP_ISZERO_C | |
567 | # define BN_MP_ISEVEN_C | |
568 | # define BN_MP_INIT_COPY_C | |
569 | # define BN_MP_CNT_LSB_C | |
570 | # define BN_MP_DIV_2D_C | |
571 | # define BN_MP_CMP_D_C | |
572 | # define BN_MP_COPY_C | |
573 | # define BN_MP_MOD_C | |
540 | 574 | # define BN_MP_CLEAR_C |
541 | 575 | #endif |
542 | 576 | |
665 | 699 | # define BN_MP_CLEAR_C |
666 | 700 | #endif |
667 | 701 | |
702 | #if defined(BN_MP_PRIME_FROBENIUS_UNDERWOOD_C) | |
703 | # define BN_MP_PRIME_IS_PRIME_C | |
704 | # define BN_MP_INIT_MULTI_C | |
705 | # define BN_MP_SET_LONG_C | |
706 | # define BN_MP_SQR_C | |
707 | # define BN_MP_SUB_D_C | |
708 | # define BN_MP_KRONECKER_C | |
709 | # define BN_MP_GCD_C | |
710 | # define BN_MP_ADD_D_C | |
711 | # define BN_MP_SET_C | |
712 | # define BN_MP_COUNT_BITS_C | |
713 | # define BN_MP_MUL_2_C | |
714 | # define BN_MP_MUL_D_C | |
715 | # define BN_MP_ADD_C | |
716 | # define BN_MP_MUL_C | |
717 | # define BN_MP_SUB_C | |
718 | # define BN_MP_MOD_C | |
719 | # define BN_MP_GET_BIT_C | |
720 | # define BN_MP_EXCH_C | |
721 | # define BN_MP_ISZERO_C | |
722 | # define BN_MP_CMP_C | |
723 | # define BN_MP_CLEAR_MULTI_C | |
724 | #endif | |
725 | ||
668 | 726 | #if defined(BN_MP_PRIME_IS_DIVISIBLE_C) |
669 | 727 | # define BN_MP_MOD_D_C |
670 | 728 | #endif |
671 | 729 | |
672 | 730 | #if defined(BN_MP_PRIME_IS_PRIME_C) |
731 | # define BN_MP_ISEVEN_C | |
732 | # define BN_MP_IS_SQUARE_C | |
673 | 733 | # define BN_MP_CMP_D_C |
674 | 734 | # define BN_MP_PRIME_IS_DIVISIBLE_C |
675 | # define BN_MP_INIT_C | |
676 | # define BN_MP_SET_C | |
735 | # define BN_MP_INIT_SET_C | |
677 | 736 | # define BN_MP_PRIME_MILLER_RABIN_C |
737 | # define BN_MP_PRIME_FROBENIUS_UNDERWOOD_C | |
738 | # define BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C | |
739 | # define BN_MP_READ_RADIX_C | |
740 | # define BN_MP_CMP_C | |
741 | # define BN_MP_SET_C | |
742 | # define BN_MP_COUNT_BITS_C | |
743 | # define BN_MP_RAND_C | |
744 | # define BN_MP_DIV_2D_C | |
678 | 745 | # define BN_MP_CLEAR_C |
679 | 746 | #endif |
680 | 747 | |
698 | 765 | # define BN_MP_MOD_D_C |
699 | 766 | # define BN_MP_INIT_C |
700 | 767 | # define BN_MP_ADD_D_C |
701 | # define BN_MP_PRIME_MILLER_RABIN_C | |
768 | # define BN_MP_PRIME_IS_PRIME_C | |
702 | 769 | # define BN_MP_CLEAR_C |
703 | 770 | #endif |
704 | 771 | |
714 | 781 | # define BN_MP_ADD_D_C |
715 | 782 | #endif |
716 | 783 | |
784 | #if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C) | |
785 | # define BN_MP_PRIME_IS_PRIME_C | |
786 | # define BN_MP_MUL_D_C | |
787 | # define BN_MP_MUL_SI_C | |
788 | # define BN_MP_INIT_C | |
789 | # define BN_MP_SET_LONG_C | |
790 | # define BN_MP_MUL_C | |
791 | # define BN_MP_CLEAR_C | |
792 | # define BN_MP_INIT_MULTI_C | |
793 | # define BN_MP_GCD_C | |
794 | # define BN_MP_CMP_D_C | |
795 | # define BN_MP_CMP_C | |
796 | # define BN_MP_KRONECKER_C | |
797 | # define BN_MP_ADD_D_C | |
798 | # define BN_MP_CNT_LSB_C | |
799 | # define BN_MP_DIV_2D_C | |
800 | # define BN_MP_SET_C | |
801 | # define BN_MP_MUL_2_C | |
802 | # define BN_MP_COUNT_BITS_C | |
803 | # define BN_MP_MOD_C | |
804 | # define BN_MP_SQR_C | |
805 | # define BN_MP_SUB_C | |
806 | # define BN_MP_GET_BIT_C | |
807 | # define BN_MP_ADD_C | |
808 | # define BN_MP_ISODD_C | |
809 | # define BN_MP_DIV_2_C | |
810 | # define BN_MP_SUB_D_C | |
811 | # define BN_MP_ISZERO_C | |
812 | # define BN_MP_CLEAR_MULTI_C | |
813 | #endif | |
814 | ||
717 | 815 | #if defined(BN_MP_RADIX_SIZE_C) |
718 | 816 | # define BN_MP_ISZERO_C |
719 | 817 | # define BN_MP_COUNT_BITS_C |
830 | 928 | |
831 | 929 | #if defined(BN_MP_SET_C) |
832 | 930 | # define BN_MP_ZERO_C |
931 | #endif | |
932 | ||
933 | #if defined(BN_MP_SET_DOUBLE_C) | |
934 | # define BN_MP_SET_LONG_LONG_C | |
935 | # define BN_MP_DIV_2D_C | |
936 | # define BN_MP_MUL_2D_C | |
937 | # define BN_MP_ISZERO_C | |
833 | 938 | #endif |
834 | 939 | |
835 | 940 | #if defined(BN_MP_SET_INT_C) |
1112 | 1217 | #else |
1113 | 1218 | # define LTM_LAST |
1114 | 1219 | #endif |
1220 | ||
1221 | /* ref: $Format:%D$ */ | |
1222 | /* git commit: $Format:%H$ */ | |
1223 | /* commit time: $Format:%ai$ */ |
6 | 6 | * Michael Fromberger but has been written from scratch with |
7 | 7 | * additional optimizations in place. |
8 | 8 | * |
9 | * The library is free for all purposes without any express | |
10 | * guarantee it works. | |
9 | * SPDX-License-Identifier: Unlicense | |
11 | 10 | */ |
12 | 11 | #ifndef TOMMATH_PRIV_H_ |
13 | 12 | #define TOMMATH_PRIV_H_ |
0 | /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
1 | * | |
2 | * LibTomMath is a library that provides multiple-precision | |
3 | * integer arithmetic as well as number theoretic functionality. | |
4 | * | |
5 | * The library was designed directly after the MPI library by | |
6 | * Michael Fromberger but has been written from scratch with | |
7 | * additional optimizations in place. | |
8 | * | |
9 | * SPDX-License-Identifier: Unlicense | |
10 | */ | |
11 | ||
0 | 12 | /* super class file for PK algos */ |
1 | 13 | |
2 | 14 | /* default ... include all MPI */ |