Update file headers
[skip ci]
This commit is contained in:
		
							parent
							
								
									c92761eb23
								
							
						
					
					
						commit
						18355de625
					
				| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| static const struct { | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes the modular inverse via binary extended euclidean algorithm,
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes xR**-1 == x (mod N) via Montgomery Reduction
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Fast (comba) multiplier
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* this is a modified version of fast_s_mul_digs that only produces
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* the jist of squaring...
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes a = 2**b
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* b = |a|
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* high level addition (handles signs) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* single digit addition */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* d = a + b (mod c) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* AND two ints together */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* trim unused digits
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* clear one (frees)  */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| #include <stdarg.h> | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* compare two ints (signed)*/ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* compare a digit */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* compare maginitude of two ints (unsigned) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| static const int lnz[16] = { | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* b = ~a */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* copy, b = a */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* returns the number of bits in an int */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| #ifdef BN_MP_DIV_SMALL | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* b = a/2 */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* shift right by a certain bit count (store quotient in c, optional remainder in d) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* divide by three (based on routine from MPI and the GMP manual) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| static int s_is_power_of_two(mp_digit b, int *p) | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines if a number is a valid DR modulus */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines the setup value */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* swap the elements of two integers, for cases where you can't simply swap the
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* based on gmp's mpz_export.
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* wrapper function for mp_expt_d_ex() */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* calculate c = a**b  using a square-multiply algorithm */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Extended euclidean algorithm of (a, b) produces
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| #ifndef LTM_NO_FILE | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| #ifndef LTM_NO_FILE | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Greatest Common Divisor using the binary method */ | ||||
|  | ||||
| @ -10,8 +10,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Checks the bit at position b and returns MP_YES
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| double mp_get_double(const mp_int *a) | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* get the lower 32-bits of an mp_int */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* get the lower unsigned long of an mp_int, platform dependent */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* get the lower unsigned long long of an mp_int, platform dependent */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* grow as required */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* based on gmp's mpz_import.
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* init a new mp_int */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* creates "a" then copies b into it */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| #include <stdarg.h> | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* initialize and set a digit */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* initialize and set a digit */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* init an mp_init for a given size */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* hac 14.61, pp608 */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* hac 14.61, pp608 */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Check if remainders are possible squares - fast exclude non-squares */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes the jacobi c = (a | n) (or Legendre if n is prime)
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* c = |a| * |b| using Karatsuba Multiplication using
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Karatsuba squaring, computes b = a*a using three
 | ||||
|  | ||||
| @ -10,8 +10,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes least common multiple as |a*b|/(a, b) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* shift left a certain amount of digits */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* c = a mod b, 0 <= c < b if b > 0, b < c <= 0 if b < 0 */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* calc a value mod 2**b */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| int mp_mod_d(const mp_int *a, mp_digit b, mp_digit *c) | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* computes xR**-1 == x (mod N) via Montgomery Reduction */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* setups the montgomery reduction stuff */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* high level multiplication (handles sign) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* b = a*2 */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* shift left by a certain bit count */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* multiply by a digit */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* d = a * b (mod c) */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* wrapper function for mp_n_root_ex()
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* find the n'th root of an integer
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* b = -a */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* OR two ints together */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* performs one Fermat test.
 | ||||
|  | ||||
| @ -10,8 +10,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines if an integers is divisible by one
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* portable integer log of two with small footprint */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* Miller-Rabin test of "a" to the base of "b" as described in
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* finds the next prime after the number "a" using "t" trials
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* makes a truly random prime of a given size (bits),
 | ||||
|  | ||||
| @ -10,8 +10,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* returns size of ASCII reprensentation */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* chars used in radix conversions */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* First the OS-specific special cases
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* read a string [ASCII] in a given radix */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* read signed bin, big endian, first byte is 0==positive or 1==negative */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* reads a unsigned char array, assumes the msb is stored first [big endian] */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* reduces x mod m, assumes 0 < x < m**2, mu is
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* reduces a modulo n where n is of the form 2**p - d */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* reduces a modulo n where n is of the form 2**p - d
 | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines the setup value */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines the setup value */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines if mp_reduce_2k can be used */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* determines if reduce_2k_l can be used */ | ||||
|  | ||||
| @ -9,8 +9,7 @@ | ||||
|  * Michael Fromberger but has been written from scratch with | ||||
|  * additional optimizations in place. | ||||
|  * | ||||
|  * The library is free for all purposes without any express | ||||
|  * guarantee it works. | ||||
|  * SPDX-License-Identifier: Unlicense | ||||
|  */ | ||||
| 
 | ||||
| /* pre-calculate the value required for Barrett reduction
 | ||||
|  | ||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user