diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /security/nss/lib/freebl/mpi/tests | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'security/nss/lib/freebl/mpi/tests')
19 files changed, 1474 insertions, 0 deletions
diff --git a/security/nss/lib/freebl/mpi/tests/LICENSE b/security/nss/lib/freebl/mpi/tests/LICENSE new file mode 100644 index 000000000..c2c5d0190 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/LICENSE @@ -0,0 +1,6 @@ +Within this directory, each of the file listed below is licensed under +the terms given in the file LICENSE-MPL, also in this directory. + +pi1k.txt +pi2k.txt +pi5k.txt diff --git a/security/nss/lib/freebl/mpi/tests/LICENSE-MPL b/security/nss/lib/freebl/mpi/tests/LICENSE-MPL new file mode 100644 index 000000000..41dc2327f --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/LICENSE-MPL @@ -0,0 +1,3 @@ +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. diff --git a/security/nss/lib/freebl/mpi/tests/mptest-1.c b/security/nss/lib/freebl/mpi/tests/mptest-1.c new file mode 100644 index 000000000..449134668 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-1.c @@ -0,0 +1,43 @@ +/* + * Simple test driver for MPI library + * + * Test 1: Simple input test (drives single-digit multiply and add, + * as well as I/O routines) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#ifdef MAC_CW_SIOUX +#include <console.h> +#endif + +#include "mpi.h" + +int +main(int argc, char *argv[]) +{ + int ix; + mp_int mp; + +#ifdef MAC_CW_SIOUX + argc = ccommand(&argv); +#endif + + mp_init(&mp); + + for (ix = 1; ix < argc; ix++) { + mp_read_radix(&mp, argv[ix], 10); + mp_print(&mp, stdout); + fputc('\n', stdout); + } + + mp_clear(&mp); + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-2.c b/security/nss/lib/freebl/mpi/tests/mptest-2.c new file mode 100644 index 000000000..1505e6afd --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-2.c @@ -0,0 +1,62 @@ +/* + * Simple test driver for MPI library + * + * Test 2: Basic addition and subtraction test + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include "mpi.h" + +int +main(int argc, char *argv[]) +{ + mp_int a, b, c; + + if (argc < 3) { + fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]); + return 1; + } + + printf("Test 2: Basic addition and subtraction\n\n"); + + mp_init(&a); + mp_init(&b); + + mp_read_radix(&a, argv[1], 10); + mp_read_radix(&b, argv[2], 10); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + + mp_init(&c); + printf("c = a + b\n"); + + mp_add(&a, &b, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("c = a - b\n"); + + mp_sub(&a, &b, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mp_clear(&c); + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-3.c b/security/nss/lib/freebl/mpi/tests/mptest-3.c new file mode 100644 index 000000000..86fb24654 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-3.c @@ -0,0 +1,105 @@ +/* + * Simple test driver for MPI library + * + * Test 3: Multiplication, division, and exponentiation test + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include <time.h> + +#include "mpi.h" + +#define EXPT 0 /* define nonzero to get exponentiate test */ + +int +main(int argc, char *argv[]) +{ + int ix; + mp_int a, b, c, d; + mp_digit r; + mp_err res; + + if (argc < 3) { + fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]); + return 1; + } + + printf("Test 3: Multiplication and division\n\n"); + srand(time(NULL)); + + mp_init(&a); + mp_init(&b); + + mp_read_variable_radix(&a, argv[1], 10); + mp_read_variable_radix(&b, argv[2], 10); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + + mp_init(&c); + printf("\nc = a * b\n"); + + mp_mul(&a, &b, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nc = b * 32523\n"); + + mp_mul_d(&b, 32523, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mp_init(&d); + printf("\nc = a / b, d = a mod b\n"); + + mp_div(&a, &b, &c, &d); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("d = "); + mp_print(&d, stdout); + fputc('\n', stdout); + + ix = rand() % 256; + printf("\nc = a / %d, r = a mod %d\n", ix, ix); + mp_div_d(&a, (mp_digit)ix, &c, &r); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("r = %04X\n", r); + +#if EXPT + printf("\nc = a ** b\n"); + mp_expt(&a, &b, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); +#endif + + ix = rand() % 256; + printf("\nc = 2^%d\n", ix); + mp_2expt(&c, ix); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mp_clear(&d); + mp_clear(&c); + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-3a.c b/security/nss/lib/freebl/mpi/tests/mptest-3a.c new file mode 100644 index 000000000..c6cea7046 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-3a.c @@ -0,0 +1,123 @@ +/* + * Simple test driver for MPI library + * + * Test 3a: Multiplication vs. squaring timing test + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include <time.h> + +#include "mpi.h" +#include "mpprime.h" + +int +main(int argc, char *argv[]) +{ + int ix, num, prec = 8; + double d1, d2; + clock_t start, finish; + time_t seed; + mp_int a, c, d; + + seed = time(NULL); + + if (argc < 2) { + fprintf(stderr, "Usage: %s <num-tests> [<precision>]\n", argv[0]); + return 1; + } + + if ((num = atoi(argv[1])) < 0) + num = -num; + + if (!num) { + fprintf(stderr, "%s: must perform at least 1 test\n", argv[0]); + return 1; + } + + if (argc > 2) { + if ((prec = atoi(argv[2])) <= 0) + prec = 8; + else + prec = (prec + (DIGIT_BIT - 1)) / DIGIT_BIT; + } + + printf("Test 3a: Multiplication vs squaring timing test\n" + "Precision: %d digits (%u bits)\n" + "# of tests: %d\n\n", + prec, prec * DIGIT_BIT, num); + + mp_init_size(&a, prec); + + mp_init(&c); + mp_init(&d); + + printf("Verifying accuracy ... \n"); + srand((unsigned int)seed); + for (ix = 0; ix < num; ix++) { + mpp_random_size(&a, prec); + mp_mul(&a, &a, &c); + mp_sqr(&a, &d); + + if (mp_cmp(&c, &d) != 0) { + printf("Error! Results not accurate:\n"); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("d = "); + mp_print(&d, stdout); + fputc('\n', stdout); + mp_sub(&c, &d, &d); + printf("dif "); + mp_print(&d, stdout); + fputc('\n', stdout); + mp_clear(&c); + mp_clear(&d); + mp_clear(&a); + return 1; + } + } + printf("Accuracy is confirmed for the %d test samples\n", num); + mp_clear(&d); + + printf("Testing squaring ... \n"); + srand((unsigned int)seed); + start = clock(); + for (ix = 0; ix < num; ix++) { + mpp_random_size(&a, prec); + mp_sqr(&a, &c); + } + finish = clock(); + + d2 = (double)(finish - start) / CLOCKS_PER_SEC; + + printf("Testing multiplication ... \n"); + srand((unsigned int)seed); + start = clock(); + for (ix = 0; ix < num; ix++) { + mpp_random(&a); + mp_mul(&a, &a, &c); + } + finish = clock(); + + d1 = (double)(finish - start) / CLOCKS_PER_SEC; + + printf("Multiplication time: %.3f sec (%.3f each)\n", d1, d1 / num); + printf("Squaring time: %.3f sec (%.3f each)\n", d2, d2 / num); + printf("Improvement: %.2f%%\n", (1.0 - (d2 / d1)) * 100.0); + + mp_clear(&c); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-4.c b/security/nss/lib/freebl/mpi/tests/mptest-4.c new file mode 100644 index 000000000..0f326ac2c --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-4.c @@ -0,0 +1,111 @@ +/* + * Simple test driver for MPI library + * + * Test 4: Modular arithmetic tests + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include "mpi.h" + +int +main(int argc, char *argv[]) +{ + int ix; + mp_int a, b, c, m; + mp_digit r; + + if (argc < 4) { + fprintf(stderr, "Usage: %s <a> <b> <m>\n", argv[0]); + return 1; + } + + printf("Test 4: Modular arithmetic\n\n"); + + mp_init(&a); + mp_init(&b); + mp_init(&m); + + mp_read_radix(&a, argv[1], 10); + mp_read_radix(&b, argv[2], 10); + mp_read_radix(&m, argv[3], 10); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("m = "); + mp_print(&m, stdout); + fputc('\n', stdout); + + mp_init(&c); + printf("\nc = a (mod m)\n"); + + mp_mod(&a, &m, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nc = b (mod m)\n"); + + mp_mod(&b, &m, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nc = b (mod 1853)\n"); + + mp_mod_d(&b, 1853, &r); + printf("c = %04X\n", r); + + printf("\nc = (a + b) mod m\n"); + + mp_addmod(&a, &b, &m, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nc = (a - b) mod m\n"); + + mp_submod(&a, &b, &m, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nc = (a * b) mod m\n"); + + mp_mulmod(&a, &b, &m, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nc = (a ** b) mod m\n"); + + mp_exptmod(&a, &b, &m, &c); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + printf("\nIn-place modular squaring test:\n"); + for (ix = 0; ix < 5; ix++) { + printf("a = (a * a) mod m a = "); + mp_sqrmod(&a, &m, &a); + mp_print(&a, stdout); + fputc('\n', stdout); + } + + mp_clear(&c); + mp_clear(&m); + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-4a.c b/security/nss/lib/freebl/mpi/tests/mptest-4a.c new file mode 100644 index 000000000..0c8e18872 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-4a.c @@ -0,0 +1,109 @@ +/* + * mptest4a - modular exponentiation speed test + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <time.h> + +#include <sys/time.h> + +#include "mpi.h" +#include "mpprime.h" + +typedef struct { + unsigned int sec; + unsigned int usec; +} instant_t; + +instant_t +now(void) +{ + struct timeval clk; + instant_t res; + + res.sec = res.usec = 0; + + if (gettimeofday(&clk, NULL) != 0) + return res; + + res.sec = clk.tv_sec; + res.usec = clk.tv_usec; + + return res; +} + +extern mp_err s_mp_pad(); + +int +main(int argc, char *argv[]) +{ + int ix, num, prec = 8; + unsigned int d; + instant_t start, finish; + time_t seed; + mp_int a, m, c; + + seed = time(NULL); + + if (argc < 2) { + fprintf(stderr, "Usage: %s <num-tests> [<precision>]\n", argv[0]); + return 1; + } + + if ((num = atoi(argv[1])) < 0) + num = -num; + + if (!num) { + fprintf(stderr, "%s: must perform at least 1 test\n", argv[0]); + return 1; + } + + if (argc > 2) { + if ((prec = atoi(argv[2])) <= 0) + prec = 8; + } + + printf("Test 3a: Modular exponentiation timing test\n" + "Precision: %d digits (%d bits)\n" + "# of tests: %d\n\n", + prec, prec * DIGIT_BIT, num); + + mp_init_size(&a, prec); + mp_init_size(&m, prec); + mp_init_size(&c, prec); + s_mp_pad(&a, prec); + s_mp_pad(&m, prec); + s_mp_pad(&c, prec); + + printf("Testing modular exponentiation ... \n"); + srand((unsigned int)seed); + + start = now(); + for (ix = 0; ix < num; ix++) { + mpp_random(&a); + mpp_random(&c); + mpp_random(&m); + mp_exptmod(&a, &c, &m, &c); + } + finish = now(); + + d = (finish.sec - start.sec) * 1000000; + d -= start.usec; + d += finish.usec; + + printf("Total time elapsed: %u usec\n", d); + printf("Time per exponentiation: %u usec (%.3f sec)\n", + (d / num), (double)(d / num) / 1000000); + + mp_clear(&c); + mp_clear(&a); + mp_clear(&m); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-4b.c b/security/nss/lib/freebl/mpi/tests/mptest-4b.c new file mode 100644 index 000000000..1bb2f911f --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-4b.c @@ -0,0 +1,107 @@ +/* + * mptest-4b.c + * + * Test speed of a large modular exponentiation of a primitive element + * modulo a prime. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <time.h> + +#include <sys/time.h> + +#include "mpi.h" +#include "mpprime.h" + +char *g_prime = + "34BD53C07350E817CCD49721020F1754527959C421C1533244769D4CF060A8B1C3DA" + "25094BE723FB1E2369B55FEEBBE0FAC16425161BF82684062B5EC5D7D47D1B23C117" + "0FA19745E44A55E148314E582EB813AC9EE5126295E2E380CACC2F6D206B293E5ED9" + "23B54EE961A8C69CD625CE4EC38B70C649D7F014432AEF3A1C93"; +char *g_gen = "5"; + +typedef struct { + unsigned int sec; + unsigned int usec; +} instant_t; + +instant_t +now(void) +{ + struct timeval clk; + instant_t res; + + res.sec = res.usec = 0; + + if (gettimeofday(&clk, NULL) != 0) + return res; + + res.sec = clk.tv_sec; + res.usec = clk.tv_usec; + + return res; +} + +extern mp_err s_mp_pad(); + +int +main(int argc, char *argv[]) +{ + instant_t start, finish; + mp_int prime, gen, expt, res; + unsigned int ix, diff; + int num; + + srand(time(NULL)); + + if (argc < 2) { + fprintf(stderr, "Usage: %s <num-tests>\n", argv[0]); + return 1; + } + + if ((num = atoi(argv[1])) < 0) + num = -num; + + if (num == 0) + ++num; + + mp_init(&prime); + mp_init(&gen); + mp_init(&res); + mp_read_radix(&prime, g_prime, 16); + mp_read_radix(&gen, g_gen, 16); + + mp_init_size(&expt, USED(&prime) - 1); + s_mp_pad(&expt, USED(&prime) - 1); + + printf("Testing %d modular exponentations ... \n", num); + + start = now(); + for (ix = 0; ix < num; ix++) { + mpp_random(&expt); + mp_exptmod(&gen, &expt, &prime, &res); + } + finish = now(); + + diff = (finish.sec - start.sec) * 1000000; + diff += finish.usec; + diff -= start.usec; + + printf("%d operations took %u usec (%.3f sec)\n", + num, diff, (double)diff / 1000000.0); + printf("That is %.3f sec per operation.\n", + ((double)diff / 1000000.0) / num); + + mp_clear(&expt); + mp_clear(&res); + mp_clear(&gen); + mp_clear(&prime); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-5.c b/security/nss/lib/freebl/mpi/tests/mptest-5.c new file mode 100644 index 000000000..dff3ed470 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-5.c @@ -0,0 +1,85 @@ +/* + * Simple test driver for MPI library + * + * Test 5: Other number theoretic functions + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include "mpi.h" + +int +main(int argc, char *argv[]) +{ + mp_int a, b, c, x, y; + + if (argc < 3) { + fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]); + return 1; + } + + printf("Test 5: Number theoretic functions\n\n"); + + mp_init(&a); + mp_init(&b); + + mp_read_radix(&a, argv[1], 10); + mp_read_radix(&b, argv[2], 10); + + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + + mp_init(&c); + printf("\nc = (a, b)\n"); + + mp_gcd(&a, &b, &c); + printf("Euclid: c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + /* + mp_bgcd(&a, &b, &c); + printf("Binary: c = "); mp_print(&c, stdout); fputc('\n', stdout); + */ + mp_init(&x); + mp_init(&y); + printf("\nc = (a, b) = ax + by\n"); + + mp_xgcd(&a, &b, &c, &x, &y); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("x = "); + mp_print(&x, stdout); + fputc('\n', stdout); + printf("y = "); + mp_print(&y, stdout); + fputc('\n', stdout); + + printf("\nc = a^-1 (mod b)\n"); + if (mp_invmod(&a, &b, &c) == MP_UNDEF) { + printf("a has no inverse mod b\n"); + } else { + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + } + + mp_clear(&y); + mp_clear(&x); + mp_clear(&c); + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-5a.c b/security/nss/lib/freebl/mpi/tests/mptest-5a.c new file mode 100644 index 000000000..c410a6a84 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-5a.c @@ -0,0 +1,147 @@ +/* + * Simple test driver for MPI library + * + * Test 5a: Greatest common divisor speed test, binary vs. Euclid + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <time.h> + +#include <sys/time.h> + +#include "mpi.h" +#include "mpprime.h" + +typedef struct { + unsigned int sec; + unsigned int usec; +} instant_t; + +instant_t +now(void) +{ + struct timeval clk; + instant_t res; + + res.sec = res.usec = 0; + + if (gettimeofday(&clk, NULL) != 0) + return res; + + res.sec = clk.tv_sec; + res.usec = clk.tv_usec; + + return res; +} + +#define PRECISION 16 + +int +main(int argc, char *argv[]) +{ + int ix, num, prec = PRECISION; + mp_int a, b, c, d; + instant_t start, finish; + time_t seed; + unsigned int d1, d2; + + seed = time(NULL); + + if (argc < 2) { + fprintf(stderr, "Usage: %s <num-tests>\n", argv[0]); + return 1; + } + + if ((num = atoi(argv[1])) < 0) + num = -num; + + printf("Test 5a: Euclid vs. Binary, a GCD speed test\n\n" + "Number of tests: %d\n" + "Precision: %d digits\n\n", + num, prec); + + mp_init_size(&a, prec); + mp_init_size(&b, prec); + mp_init(&c); + mp_init(&d); + + printf("Verifying accuracy ... \n"); + srand((unsigned int)seed); + for (ix = 0; ix < num; ix++) { + mpp_random_size(&a, prec); + mpp_random_size(&b, prec); + + mp_gcd(&a, &b, &c); + mp_bgcd(&a, &b, &d); + + if (mp_cmp(&c, &d) != 0) { + printf("Error! Results not accurate:\n"); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("d = "); + mp_print(&d, stdout); + fputc('\n', stdout); + + mp_clear(&a); + mp_clear(&b); + mp_clear(&c); + mp_clear(&d); + return 1; + } + } + mp_clear(&d); + printf("Accuracy confirmed for the %d test samples\n", num); + + printf("Testing Euclid ... \n"); + srand((unsigned int)seed); + start = now(); + for (ix = 0; ix < num; ix++) { + mpp_random_size(&a, prec); + mpp_random_size(&b, prec); + mp_gcd(&a, &b, &c); + } + finish = now(); + + d1 = (finish.sec - start.sec) * 1000000; + d1 -= start.usec; + d1 += finish.usec; + + printf("Testing binary ... \n"); + srand((unsigned int)seed); + start = now(); + for (ix = 0; ix < num; ix++) { + mpp_random_size(&a, prec); + mpp_random_size(&b, prec); + mp_bgcd(&a, &b, &c); + } + finish = now(); + + d2 = (finish.sec - start.sec) * 1000000; + d2 -= start.usec; + d2 += finish.usec; + + printf("Euclidean algorithm time: %u usec\n", d1); + printf("Binary algorithm time: %u usec\n", d2); + printf("Improvement: %.2f%%\n", + (1.0 - ((double)d2 / (double)d1)) * 100.0); + + mp_clear(&c); + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-6.c b/security/nss/lib/freebl/mpi/tests/mptest-6.c new file mode 100644 index 000000000..4febf39c5 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-6.c @@ -0,0 +1,78 @@ +/* + * Simple test driver for MPI library + * + * Test 6: Output functions + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include "mpi.h" + +void +print_buf(FILE *ofp, char *buf, int len) +{ + int ix, brk = 0; + + for (ix = 0; ix < len; ix++) { + fprintf(ofp, "%02X ", buf[ix]); + + brk = (brk + 1) & 0xF; + if (!brk) + fputc('\n', ofp); + } + + if (brk) + fputc('\n', ofp); +} + +int +main(int argc, char *argv[]) +{ + int ix, size; + mp_int a; + char *buf; + + if (argc < 2) { + fprintf(stderr, "Usage: %s <a>\n", argv[0]); + return 1; + } + + printf("Test 6: Output functions\n\n"); + + mp_init(&a); + + mp_read_radix(&a, argv[1], 10); + + printf("\nConverting to a string:\n"); + + printf("Rx Size Representation\n"); + for (ix = 2; ix <= MAX_RADIX; ix++) { + size = mp_radix_size(&a, ix); + + buf = calloc(size, sizeof(char)); + mp_toradix(&a, buf, ix); + printf("%2d: %3d: %s\n", ix, size, buf); + free(buf); + } + + printf("\nRaw output:\n"); + size = mp_raw_size(&a); + buf = calloc(size, sizeof(char)); + + printf("Size: %d bytes\n", size); + + mp_toraw(&a, buf); + print_buf(stdout, buf, size); + free(buf); + + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-7.c b/security/nss/lib/freebl/mpi/tests/mptest-7.c new file mode 100644 index 000000000..1e83fbf96 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-7.c @@ -0,0 +1,85 @@ +/* + * Simple test driver for MPI library + * + * Test 7: Random and divisibility tests + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <time.h> + +#define MP_IOFUNC 1 +#include "mpi.h" + +#include "mpprime.h" + +int +main(int argc, char *argv[]) +{ + mp_digit num; + mp_int a, b; + + srand(time(NULL)); + + if (argc < 3) { + fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]); + return 1; + } + + printf("Test 7: Random & divisibility tests\n\n"); + + mp_init(&a); + mp_init(&b); + + mp_read_radix(&a, argv[1], 10); + mp_read_radix(&b, argv[2], 10); + + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + + if (mpp_divis(&a, &b) == MP_YES) + printf("a is divisible by b\n"); + else + printf("a is not divisible by b\n"); + + if (mpp_divis(&b, &a) == MP_YES) + printf("b is divisible by a\n"); + else + printf("b is not divisible by a\n"); + + printf("\nb = mpp_random()\n"); + mpp_random(&b); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + mpp_random(&b); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + mpp_random(&b); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + + printf("\nTesting a for divisibility by first 170 primes\n"); + num = 170; + if (mpp_divis_primes(&a, &num) == MP_YES) + printf("It is divisible by at least one of them\n"); + else + printf("It is not divisible by any of them\n"); + + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-8.c b/security/nss/lib/freebl/mpi/tests/mptest-8.c new file mode 100644 index 000000000..a9d3afff9 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-8.c @@ -0,0 +1,68 @@ +/* + * Simple test driver for MPI library + * + * Test 8: Probabilistic primality tester + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <time.h> + +#define MP_IOFUNC 1 +#include "mpi.h" + +#include "mpprime.h" + +int +main(int argc, char *argv[]) +{ + int ix; + mp_digit num; + mp_int a; + + srand(time(NULL)); + + if (argc < 2) { + fprintf(stderr, "Usage: %s <a>\n", argv[0]); + return 1; + } + + printf("Test 8: Probabilistic primality testing\n\n"); + + mp_init(&a); + + mp_read_radix(&a, argv[1], 10); + + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + + printf("\nChecking for divisibility by small primes ... \n"); + num = 170; + if (mpp_divis_primes(&a, &num) == MP_YES) { + printf("it is not prime\n"); + goto CLEANUP; + } + printf("Passed that test (not divisible by any small primes).\n"); + + for (ix = 0; ix < 10; ix++) { + printf("\nPerforming Rabin-Miller test, iteration %d\n", ix + 1); + + if (mpp_pprime(&a, 5) == MP_NO) { + printf("it is not prime\n"); + goto CLEANUP; + } + } + printf("All tests passed; a is probably prime\n"); + +CLEANUP: + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-9.c b/security/nss/lib/freebl/mpi/tests/mptest-9.c new file mode 100644 index 000000000..133264e89 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-9.c @@ -0,0 +1,109 @@ +/* + * mptest-9.c + * + * Test logical functions + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> +#include <time.h> + +#include "mpi.h" +#include "mplogic.h" + +int +main(int argc, char *argv[]) +{ + mp_int a, b, c; + int pco; + mp_err res; + + printf("Test 9: Logical functions\n\n"); + + if (argc < 3) { + fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]); + return 1; + } + + mp_init(&a); + mp_init(&b); + mp_init(&c); + mp_read_radix(&a, argv[1], 16); + mp_read_radix(&b, argv[2], 16); + + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + + mpl_not(&a, &c); + printf("~a = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mpl_and(&a, &b, &c); + printf("a & b = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mpl_or(&a, &b, &c); + printf("a | b = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mpl_xor(&a, &b, &c); + printf("a ^ b = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mpl_rsh(&a, &c, 1); + printf("a >> 1 = "); + mp_print(&c, stdout); + fputc('\n', stdout); + mpl_rsh(&a, &c, 5); + printf("a >> 5 = "); + mp_print(&c, stdout); + fputc('\n', stdout); + mpl_rsh(&a, &c, 16); + printf("a >> 16 = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mpl_lsh(&a, &c, 1); + printf("a << 1 = "); + mp_print(&c, stdout); + fputc('\n', stdout); + mpl_lsh(&a, &c, 5); + printf("a << 5 = "); + mp_print(&c, stdout); + fputc('\n', stdout); + mpl_lsh(&a, &c, 16); + printf("a << 16 = "); + mp_print(&c, stdout); + fputc('\n', stdout); + + mpl_num_set(&a, &pco); + printf("population(a) = %d\n", pco); + mpl_num_set(&b, &pco); + printf("population(b) = %d\n", pco); + + res = mpl_parity(&a); + if (res == MP_EVEN) + printf("a has even parity\n"); + else + printf("a has odd parity\n"); + + mp_clear(&c); + mp_clear(&b); + mp_clear(&a); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/mptest-b.c b/security/nss/lib/freebl/mpi/tests/mptest-b.c new file mode 100644 index 000000000..07f30eaf8 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/mptest-b.c @@ -0,0 +1,230 @@ +/* + * Simple test driver for MPI library + * + * Test GF2m: Binary Polynomial Arithmetic + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <limits.h> + +#include "mp_gf2m.h" + +int +main(int argc, char *argv[]) +{ + int ix; + mp_int pp, a, b, x, y, order; + mp_int c, d, e; + mp_digit r; + mp_err res; + unsigned int p[] = { 163, 7, 6, 3, 0 }; + unsigned int ptemp[10]; + + printf("Test b: Binary Polynomial Arithmetic\n\n"); + + mp_init(&pp); + mp_init(&a); + mp_init(&b); + mp_init(&x); + mp_init(&y); + mp_init(&order); + + mp_read_radix(&pp, "0800000000000000000000000000000000000000C9", 16); + mp_read_radix(&a, "1", 16); + mp_read_radix(&b, "020A601907B8C953CA1481EB10512F78744A3205FD", 16); + mp_read_radix(&x, "03F0EBA16286A2D57EA0991168D4994637E8343E36", 16); + mp_read_radix(&y, "00D51FBC6C71A0094FA2CDD545B11C5C0C797324F1", 16); + mp_read_radix(&order, "040000000000000000000292FE77E70C12A4234C33", 16); + printf("pp = "); + mp_print(&pp, stdout); + fputc('\n', stdout); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("x = "); + mp_print(&x, stdout); + fputc('\n', stdout); + printf("y = "); + mp_print(&y, stdout); + fputc('\n', stdout); + printf("order = "); + mp_print(&order, stdout); + fputc('\n', stdout); + + mp_init(&c); + mp_init(&d); + mp_init(&e); + + /* Test polynomial conversion */ + ix = mp_bpoly2arr(&pp, ptemp, 10); + if ( + (ix != 5) || + (ptemp[0] != p[0]) || + (ptemp[1] != p[1]) || + (ptemp[2] != p[2]) || + (ptemp[3] != p[3]) || + (ptemp[4] != p[4])) { + printf("Polynomial to array conversion not correct\n"); + return -1; + } + + printf("Polynomial conversion test #1 successful.\n"); + MP_CHECKOK(mp_barr2poly(p, &c)); + if (mp_cmp(&pp, &c) != 0) { + printf("Array to polynomial conversion not correct\n"); + return -1; + } + printf("Polynomial conversion test #2 successful.\n"); + + /* Test addition */ + MP_CHECKOK(mp_badd(&a, &a, &c)); + if (mp_cmp_z(&c) != 0) { + printf("a+a should equal zero\n"); + return -1; + } + printf("Addition test #1 successful.\n"); + MP_CHECKOK(mp_badd(&a, &b, &c)); + MP_CHECKOK(mp_badd(&b, &c, &c)); + if (mp_cmp(&c, &a) != 0) { + printf("c = (a + b) + b should equal a\n"); + printf("a = "); + mp_print(&a, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Addition test #2 successful.\n"); + + /* Test multiplication */ + mp_set(&c, 2); + MP_CHECKOK(mp_bmul(&b, &c, &c)); + MP_CHECKOK(mp_badd(&b, &c, &c)); + mp_set(&d, 3); + MP_CHECKOK(mp_bmul(&b, &d, &d)); + if (mp_cmp(&c, &d) != 0) { + printf("c = (2 * b) + b should equal c = 3 * b\n"); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("d = "); + mp_print(&d, stdout); + fputc('\n', stdout); + return -1; + } + printf("Multiplication test #1 successful.\n"); + + /* Test modular reduction */ + MP_CHECKOK(mp_bmod(&b, p, &c)); + if (mp_cmp(&b, &c) != 0) { + printf("c = b mod p should equal b\n"); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular reduction test #1 successful.\n"); + MP_CHECKOK(mp_badd(&b, &pp, &c)); + MP_CHECKOK(mp_bmod(&c, p, &c)); + if (mp_cmp(&b, &c) != 0) { + printf("c = (b + p) mod p should equal b\n"); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular reduction test #2 successful.\n"); + MP_CHECKOK(mp_bmul(&b, &pp, &c)); + MP_CHECKOK(mp_bmod(&c, p, &c)); + if (mp_cmp_z(&c) != 0) { + printf("c = (b * p) mod p should equal 0\n"); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular reduction test #3 successful.\n"); + + /* Test modular multiplication */ + MP_CHECKOK(mp_bmulmod(&b, &pp, p, &c)); + if (mp_cmp_z(&c) != 0) { + printf("c = (b * p) mod p should equal 0\n"); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular multiplication test #1 successful.\n"); + mp_set(&c, 1); + MP_CHECKOK(mp_badd(&pp, &c, &c)); + MP_CHECKOK(mp_bmulmod(&b, &c, p, &c)); + if (mp_cmp(&b, &c) != 0) { + printf("c = (b * (p + 1)) mod p should equal b\n"); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular multiplication test #2 successful.\n"); + + /* Test modular squaring */ + MP_CHECKOK(mp_copy(&b, &c)); + MP_CHECKOK(mp_bmulmod(&b, &c, p, &c)); + MP_CHECKOK(mp_bsqrmod(&b, p, &d)); + if (mp_cmp(&c, &d) != 0) { + printf("c = (b * b) mod p should equal d = b^2 mod p\n"); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + printf("d = "); + mp_print(&d, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular squaring test #1 successful.\n"); + + /* Test modular division */ + MP_CHECKOK(mp_bdivmod(&b, &x, &pp, p, &c)); + MP_CHECKOK(mp_bmulmod(&c, &x, p, &c)); + if (mp_cmp(&b, &c) != 0) { + printf("c = (b / x) * x mod p should equal b\n"); + printf("b = "); + mp_print(&b, stdout); + fputc('\n', stdout); + printf("c = "); + mp_print(&c, stdout); + fputc('\n', stdout); + return -1; + } + printf("Modular division test #1 successful.\n"); + +CLEANUP: + + mp_clear(&order); + mp_clear(&y); + mp_clear(&x); + mp_clear(&b); + mp_clear(&a); + mp_clear(&pp); + + return 0; +} diff --git a/security/nss/lib/freebl/mpi/tests/pi1k.txt b/security/nss/lib/freebl/mpi/tests/pi1k.txt new file mode 100644 index 000000000..5ff6209ff --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/pi1k.txt @@ -0,0 +1 @@ +31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989 diff --git a/security/nss/lib/freebl/mpi/tests/pi2k.txt b/security/nss/lib/freebl/mpi/tests/pi2k.txt new file mode 100644 index 000000000..9ce82acd1 --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/pi2k.txt @@ -0,0 +1 @@ +314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759010 diff --git a/security/nss/lib/freebl/mpi/tests/pi5k.txt b/security/nss/lib/freebl/mpi/tests/pi5k.txt new file mode 100644 index 000000000..901fac2ea --- /dev/null +++ b/security/nss/lib/freebl/mpi/tests/pi5k.txt @@ -0,0 +1 @@ +314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635342207222582848864815845602850601684273945226746767889525213852254995466672782398645659611635488623057745649803559363456817432411251507606947945109659609402522887971089314566913686722874894056010150330861792868092087476091782493858900971490967598526136554978189312978482168299894872265880485756401427047755513237964145152374623436454285844479526586782105114135473573952311342716610213596953623144295248493718711014576540359027993440374200731057853906219838744780847848968332144571386875194350643021845319104848100537061468067491927819119793995206141966342875444064374512371819217999839101591956181467514269123974894090718649423196156794520809514655022523160388193014209376213785595663893778708303906979207734672218256259966150142150306803844773454920260541466592520149744285073251866600213243408819071048633173464965145390579626856100550810665879699816357473638405257145910289706414011097120628043903975951567715770042033786993600723055876317635942187312514712053292819182618612586732157919841484882916447060957527069572209175671167229109816909152801735067127485832228718352093539657251210835791513698820914442100675103346711031412671113699086585163983150197016515116851714376576183515565088490998985998238734552833163550764791853589322618548963213293308985706420467525907091548141654985946163718027098199430992448895757128289059232332609729971208443357326548938239119325974636673058360414281388303203824903758985243744170291327656180937734440307074692112019130203303801976211011004492932151608424448596376698389522868478312355265821314495768572624334418930396864262434107732269780280731891544110104468232527162010526522721116603966655730925471105578537634668206531098965269186205647693125705863566201855810072936065987648611791045334885034611365768675324944166803962657978771855608455296541266540853061434443185867697514566140680070023787765913440171274947042056223053899456131407112700040785473326993908145466464588079727082668306343285878569830523580893306575740679545716377525420211495576158140025012622859413021647155097925923099079654737612551765675135751782966645477917450112996148903046399471329621073404375189573596145890193897131117904297828564750320319869151402870808599048010941214722131794764777262241425485454033215718530614228813758504306332175182979866223717215916077166925474873898665494945011465406284336639379003976926567214638530673609657120918076383271664162748888007869256029022847210403172118608204190004229661711963779213375751149595015660496318629472654736425230817703675159067350235072835405670403867435136222247715891504953098444893330963408780769325993978054193414473774418426312986080998886874132604721 |