Mercurial > dropbear
comparison libtommath/bn_mp_prime_rabin_miller_trials.c @ 1692:1051e4eea25a
Update LibTomMath to 1.2.0 (#84)
* update C files
* update other files
* update headers
* update makefiles
* remove mp_set/get_double()
* use ltm 1.2.0 API
* update ltm_desc
* use bundled tommath if system-tommath is too old
* XMALLOC etc. were changed to MP_MALLOC etc.
author | Steffen Jaeckel <s@jaeckel.eu> |
---|---|
date | Tue, 26 May 2020 17:36:47 +0200 |
parents | a36e545fb43d |
children |
comparison
equal
deleted
inserted
replaced
1691:2d3745d58843 | 1692:1051e4eea25a |
---|---|
1 #include "tommath_private.h" | 1 #include "tommath_private.h" |
2 #ifdef BN_MP_PRIME_RABIN_MILLER_TRIALS_C | 2 #ifdef BN_MP_PRIME_RABIN_MILLER_TRIALS_C |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis | 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ |
4 * | 4 /* SPDX-License-Identifier: Unlicense */ |
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 | 5 |
16 static const struct { | 6 static const struct { |
17 int k, t; | 7 int k, t; |
18 } sizes[] = { | 8 } sizes[] = { |
19 { 80, -1 }, /* Use deterministic algorithm for size <= 80 bits */ | 9 { 80, -1 }, /* Use deterministic algorithm for size <= 80 bits */ |
20 { 81, 39 }, | 10 { 81, 37 }, /* max. error = 2^(-96)*/ |
21 { 96, 37 }, | 11 { 96, 32 }, /* max. error = 2^(-96)*/ |
22 { 128, 32 }, | 12 { 128, 40 }, /* max. error = 2^(-112)*/ |
23 { 160, 27 }, | 13 { 160, 35 }, /* max. error = 2^(-112)*/ |
24 { 192, 21 }, | 14 { 256, 27 }, /* max. error = 2^(-128)*/ |
25 { 256, 16 }, | 15 { 384, 16 }, /* max. error = 2^(-128)*/ |
26 { 384, 10 }, | 16 { 512, 18 }, /* max. error = 2^(-160)*/ |
27 { 512, 7 }, | 17 { 768, 11 }, /* max. error = 2^(-160)*/ |
28 { 640, 6 }, | 18 { 896, 10 }, /* max. error = 2^(-160)*/ |
29 { 768, 5 }, | 19 { 1024, 12 }, /* max. error = 2^(-192)*/ |
30 { 896, 4 }, | 20 { 1536, 8 }, /* max. error = 2^(-192)*/ |
31 { 1024, 4 }, | 21 { 2048, 6 }, /* max. error = 2^(-192)*/ |
32 { 2048, 2 } /* For bigger keysizes use always at least 2 Rounds */ | 22 { 3072, 4 }, /* max. error = 2^(-192)*/ |
23 { 4096, 5 }, /* max. error = 2^(-256)*/ | |
24 { 5120, 4 }, /* max. error = 2^(-256)*/ | |
25 { 6144, 4 }, /* max. error = 2^(-256)*/ | |
26 { 8192, 3 }, /* max. error = 2^(-256)*/ | |
27 { 9216, 3 }, /* max. error = 2^(-256)*/ | |
28 { 10240, 2 } /* For bigger keysizes use always at least 2 Rounds */ | |
33 }; | 29 }; |
34 | 30 |
35 /* returns # of RM trials required for a given bit size and max. error of 2^(-96)*/ | 31 /* returns # of RM trials required for a given bit size */ |
36 int mp_prime_rabin_miller_trials(int size) | 32 int mp_prime_rabin_miller_trials(int size) |
37 { | 33 { |
38 int x; | 34 int x; |
39 | 35 |
40 for (x = 0; x < (int)(sizeof(sizes)/(sizeof(sizes[0]))); x++) { | 36 for (x = 0; x < (int)(sizeof(sizes)/(sizeof(sizes[0]))); x++) { |
47 return sizes[x-1].t; | 43 return sizes[x-1].t; |
48 } | 44 } |
49 | 45 |
50 | 46 |
51 #endif | 47 #endif |
52 | |
53 /* ref: HEAD -> master, tag: v1.1.0 */ | |
54 /* git commit: 08549ad6bc8b0cede0b357a9c341c5c6473a9c55 */ | |
55 /* commit time: 2019-01-28 20:32:32 +0100 */ |