Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tommath-refactor Excluding Merge-Ins
This is equivalent to a diff from 515a22d41d to cd427db76c
2019-03-17
| ||
22:16 | For Tcl >= 8.7, always compile-in the extended Unicode tables, no matter the value of TCL_UTF_MAX. D... check-in: 82477e9d3a user: jan.nijtmans tags: core-8-branch | |
2019-03-16
| ||
21:16 | Merge 8.7 Closed-Leaf check-in: cd427db76c user: jan.nijtmans tags: tommath-refactor | |
21:10 | Merge 8.7 Move up some stub entries related to Tcl_UniChar Use TCL_UTF_MAX=4 for full Unicode in ste... check-in: 81502a66ed user: jan.nijtmans tags: utf-max | |
2019-03-15
| ||
21:17 | Merge 8.7 check-in: 3dcb7571f5 user: jan.nijtmans tags: trunk | |
20:52 | Eliminate usage of mp_isneg(), just check bignum->sign directly (as libtommath itself does) Make Tcl... check-in: 515a22d41d user: jan.nijtmans tags: core-8-branch | |
2019-03-14
| ||
20:01 | merge-mark check-in: 4990c65285 user: jan.nijtmans tags: tommath-refactor | |
19:52 | Make internal libtommath stub entries deprecated: Those are not supposed to be called in extensions check-in: 99c1ed4d8a user: jan.nijtmans tags: core-8-branch | |
Changes to generic/tclStubInit.c.
︙ | |||
444 445 446 447 448 449 450 451 452 453 454 455 456 457 | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | + + + + + + + + + + + | # define TclFindNamespace Tcl_FindNamespace # define TclFindCommand Tcl_FindCommand # define TclGetCommandFromObj Tcl_GetCommandFromObj # define TclGetCommandFullName Tcl_GetCommandFullName # define TclpLocaltime_unix TclpLocaltime # define TclpGmtime_unix TclpGmtime # define TclOldFreeObj TclFreeObj # define TclBN_reverse bn_reverse # define TclBN_fast_s_mp_mul_digs fast_s_mp_mul_digs # define TclBN_fast_s_mp_sqr fast_s_mp_sqr # define TclBN_mp_karatsuba_mul mp_karatsuba_mul # define TclBN_mp_karatsuba_sqr mp_karatsuba_sqr # define TclBN_mp_toom_mul mp_toom_mul # define TclBN_mp_toom_sqr mp_toom_sqr # define TclBN_s_mp_add s_mp_add # define TclBN_s_mp_mul_digs s_mp_mul_digs # define TclBN_s_mp_sqr s_mp_sqr # define TclBN_s_mp_sub s_mp_sub static int seekOld( Tcl_Channel chan, /* The channel on which to seek. */ int offset, /* Offset to seek to. */ int mode) /* Relative to which location to seek? */ { |
︙ |
Changes to generic/tclTomMath.decls.
︙ | |||
235 236 237 238 239 240 241 | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - + - + | # Added in libtommath 1.0 declare 67 { int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) } # Added in libtommath 1.0.1 declare 68 { |
︙ |
Changes to generic/tclTomMath.h.
1 2 3 4 5 6 7 8 9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - + - - + | /* LibTomMath, multiple-precision integer library -- Tom St Denis * * LibTomMath is a library that provides multiple-precision * integer arithmetic as well as number theoretic functionality. * * The library was designed directly after the MPI library by * Michael Fromberger but has been written from scratch with * additional optimizations in place. * |
︙ | |||
106 107 108 109 110 111 112 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | - - - + | # define MP_28BIT # endif #endif /* otherwise the bits per digit is calculated automatically from the size of a mp_digit */ #ifndef DIGIT_BIT # define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */ |
︙ | |||
174 175 176 177 178 179 180 | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | - - - - - | int used, alloc, sign; mp_digit *dp; }; /* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */ typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat); |
︙ | |||
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | + + + + + + + + + + | void mp_zero(mp_int *a); */ /* set to a digit */ /* void mp_set(mp_int *a, mp_digit b); */ /* set a double */ /* int mp_set_double(mp_int *a, double b); */ /* set a 32-bit const */ /* int mp_set_int(mp_int *a, unsigned long b); */ /* set a platform dependent unsigned long value */ /* int mp_set_long(mp_int *a, unsigned long b); */ /* set a platform dependent unsigned long long value */ /* int mp_set_long_long(mp_int *a, unsigned long long b); */ /* get a double */ /* double mp_get_double(const mp_int *a); */ /* get a 32-bit value */ /* unsigned long mp_get_int(const mp_int *a); */ /* get a platform dependent unsigned long value */ |
︙ | |||
353 354 355 356 357 358 359 | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | - + + + + + - - + + + - + + + + + + + + | /* Counts the number of lsbs which are zero before the first zero bit */ /* int mp_cnt_lsb(const mp_int *a); */ /* I Love Earth! */ |
︙ | |||
576 577 578 579 580 581 582 583 584 585 586 587 588 589 | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | + + + + + | int mp_is_square(const mp_int *arg, int *ret); */ /* computes the jacobi c = (a | n) (or Legendre if b is prime) */ /* int mp_jacobi(const mp_int *a, const mp_int *n, int *c); */ /* computes the Kronecker symbol c = (a | p) (like jacobi() but with {a,p} in Z */ /* int mp_kronecker(const mp_int *a, const mp_int *p, int *c); */ /* used to setup the Barrett reduction for a given modulus b */ /* int mp_reduce_setup(mp_int *a, const mp_int *b); */ /* Barrett Reduction, computes a (mod b) with a precomputed value c |
︙ | |||
698 699 700 701 702 703 704 | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | + + + + + + + + + + + + + + - - + + + + + + + + + | /* This gives [for a given bit size] the number of trials required * such that Miller-Rabin gives a prob of failure lower than 2^-96 */ /* int mp_prime_rabin_miller_trials(int size); */ /* performs one strong Lucas-Selfridge test of "a". * Sets result to 0 if composite or 1 if probable prime */ /* int mp_prime_strong_lucas_selfridge(const mp_int *a, int *result); */ /* performs one Frobenius test of "a" as described by Paul Underwood. * Sets result to 0 if composite or 1 if probable prime */ /* int mp_prime_frobenius_underwood(const mp_int *N, int *result); */ |
︙ |
Changes to generic/tclTomMathDecls.h.
︙ | |||
40 41 42 43 44 45 46 | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - - - | /* Rename the global symbols in libtommath to avoid linkage conflicts */ #define KARATSUBA_MUL_CUTOFF TclBNKaratsubaMulCutoff #define KARATSUBA_SQR_CUTOFF TclBNKaratsubaSqrCutoff #define TOOM_MUL_CUTOFF TclBNToomMulCutoff #define TOOM_SQR_CUTOFF TclBNToomSqrCutoff |
︙ | |||
74 75 76 77 78 79 80 | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | - - | #define mp_grow TclBN_mp_grow #define mp_init TclBN_mp_init #define mp_init_copy TclBN_mp_init_copy #define mp_init_multi TclBN_mp_init_multi #define mp_init_set TclBN_mp_init_set #define mp_init_set_int TclBN_mp_init_set_int #define mp_init_size TclBN_mp_init_size |
︙ | |||
103 104 105 106 107 108 109 | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | - - - - - - + + + + + + + + + + + + | #define mp_sub_d TclBN_mp_sub_d #define mp_tc_and TclBN_mp_tc_and #define mp_tc_div_2d TclBN_mp_tc_div_2d #define mp_tc_or TclBN_mp_tc_or #define mp_tc_xor TclBN_mp_tc_xor #define mp_to_unsigned_bin TclBN_mp_to_unsigned_bin #define mp_to_unsigned_bin_n TclBN_mp_to_unsigned_bin_n |
︙ | |||
603 604 605 606 607 608 609 610 611 | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | + + + + + + + + + + + | #endif /* defined(USE_TCL_STUBS) */ /* !END!: Do not edit above this line. */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT #undef TclBNInitBignumFromLong #define TclBNInitBignumFromLong(value) TclBNInitBignumFromWideInt((long) value) #ifdef USE_TCL_STUBS # undef TclBN_mp_set_long # ifdef TCL_WIDE_INT_IS_LONG # define TclBN_mp_set_long(a, b) TclBN_mp_set_long_long(a, (unsigned long)b) # else # define TclBN_mp_set_long(a, b) TclBN_mp_set_int(a, b) # endif #endif #endif /* _TCLINTDECLS */ |
Changes to generic/tclTomMathInterface.c.
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - + | * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tclInt.h" |
︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | + + + + + - + - + | * * Side effects: * The 'bignum' is constructed. * *---------------------------------------------------------------------- */ #ifdef TCL_WIDE_INT_IS_LONG # define TclBN_mp_set_long_long TclBN_mp_set_long #endif void TclInitBignumFromWideInt( mp_int *a, /* Bignum to initialize */ Tcl_WideInt v) /* Initial value */ { if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { Tcl_Panic("initialization failure in TclInitBignumFromWideInt"); } if (v < 0) { |
︙ | |||
142 143 144 145 146 147 148 | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | - + | TclInitBignumFromWideUInt( mp_int *a, /* Bignum to initialize */ Tcl_WideUInt v) /* Initial value */ { if (mp_init_size(a, (CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT) != MP_OKAY) { Tcl_Panic("initialization failure in TclInitBignumFromWideUInt"); } |
Changes to libtommath/bn_fast_s_mp_sqr.c.
︙ | |||
75 76 77 78 79 80 81 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | - + | /* even columns have the square term in them */ if (((unsigned)ix & 1u) == 0u) { _W += (mp_word)a->dp[ix>>1] * (mp_word)a->dp[ix>>1]; } /* store it */ |
︙ |
Changes to libtommath/bn_mp_get_bit.c.
︙ | |||
23 24 25 26 27 28 29 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - - - - - - - - - - - + | if (b < 0) { return MP_VAL; } limb = b / DIGIT_BIT; |
︙ |
Changes to libtommath/bn_mp_get_double.c.
︙ | |||
15 16 17 18 19 20 21 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | - - + + | double mp_get_double(const mp_int *a) { int i; double d = 0.0, fac = 1.0; for (i = 0; i < DIGIT_BIT; ++i) { fac *= 2.0; } |
︙ |
Changes to libtommath/bn_mp_get_int.c.
︙ | |||
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | - - - - - - - - - - - - - - - - - - + | * * SPDX-License-Identifier: Unlicense */ /* get the lower 32-bits of an mp_int */ unsigned long mp_get_int(const mp_int *a) { |
Changes to libtommath/bn_mp_get_long.c.
︙ | |||
22 23 24 25 26 27 28 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + - + - + | return 0; } /* get number of digits of the lsb we have to read */ i = MIN(a->used, ((((int)sizeof(unsigned long) * CHAR_BIT) + DIGIT_BIT - 1) / DIGIT_BIT)) - 1; /* get most significant digit of result */ |
︙ |
Changes to libtommath/bn_mp_get_long_long.c.
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + - + - + - + - + | * Michael Fromberger but has been written from scratch with * additional optimizations in place. * * SPDX-License-Identifier: Unlicense */ /* get the lower unsigned long long of an mp_int, platform dependent */ |
︙ |
Changes to libtommath/bn_mp_is_square.c.
︙ | |||
51 52 53 54 55 56 57 | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | - + | /* digits used? (TSD) */ if (arg->used == 0) { return MP_OKAY; } /* First check mod 128 (suppose that DIGIT_BIT is at least 7) */ |
︙ |
Changes to libtommath/bn_mp_rand.c.
︙ | |||
14 15 16 17 18 19 20 | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - + | /* First the OS-specific special cases * - *BSD * - Windows */ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) #define MP_ARC4RANDOM |
︙ |
Changes to libtommath/bn_mp_set_double.c.
︙ | |||
38 39 40 41 42 43 44 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | - + | res = (exp < 0) ? mp_div_2d(a, -exp, a, NULL) : mp_mul_2d(a, exp, a); if (res != MP_OKAY) { return res; } if (((cast.bits >> 63) != 0ULL) && (mp_iszero(a) == MP_NO)) { |
︙ |
Changes to libtommath/bn_mp_set_int.c.
︙ | |||
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | - - - - - - - - - + - - - - - - - - - - - - - | * * SPDX-License-Identifier: Unlicense */ /* set a 32-bit const */ int mp_set_int(mp_int *a, unsigned long b) { |
Changes to libtommath/bn_mp_set_long_long.c.
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | * Michael Fromberger but has been written from scratch with * additional optimizations in place. * * SPDX-License-Identifier: Unlicense */ /* set a platform dependent unsigned long long int */ |
Changes to libtommath/tommath.h.
︙ | |||
19 20 21 22 23 24 25 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | - + | #include "tommath_class.h" #ifdef __cplusplus extern "C" { #endif /* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */ |
︙ | |||
41 42 43 44 45 46 47 | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | - - + + + + + + | # else /* otherwise we fall back to MP_32BIT even on 64bit platforms */ # define MP_32BIT # endif # endif #endif |
︙ | |||
145 146 147 148 149 150 151 | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | + + - + + + - + | # endif #endif /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */ #define MP_WARRAY (1u << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) + 1)) /* the infamous mp_int structure */ #ifndef MP_INT_DECLARED #define MP_INT_DECLARED |
︙ | |||
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | + + + + + + + + | /* set a 32-bit const */ int mp_set_int(mp_int *a, unsigned long b); /* set a platform dependent unsigned long value */ int mp_set_long(mp_int *a, unsigned long b); /* set a platform dependent unsigned long long value */ #ifdef _WIN32 int mp_set_long_long(mp_int *a, unsigned __int64 b); #else int mp_set_long_long(mp_int *a, unsigned long long b); #endif /* get a double */ double mp_get_double(const mp_int *a); /* get a 32-bit value */ unsigned long mp_get_int(const mp_int *a); /* get a platform dependent unsigned long value */ unsigned long mp_get_long(const mp_int *a); /* get a platform dependent unsigned long long value */ #ifdef _WIN32 unsigned __int64 mp_get_long_long(const mp_int *a); #else unsigned long long mp_get_long_long(const mp_int *a); #endif /* initialize and set a digit */ int mp_init_set(mp_int *a, mp_digit b); /* initialize and set 32-bit value */ int mp_init_set_int(mp_int *a, unsigned long b); |
︙ |
Changes to libtommath/tommath_private.h.
︙ | |||
81 82 83 84 85 86 87 | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | - + - - - - - - + - - - - + + + + - - - - - - + - - - - - + + + - | * x is the counter and unsigned * a is the pointer to the MPI * b is the original value that should be set in the MPI. */ #define MP_SET_XLONG(func_name, type) \ int func_name (mp_int * a, type b) \ { \ |
︙ |