diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/bn/d.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/bn/d.c')
-rw-r--r-- | src/lib/libcrypto/bn/d.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/lib/libcrypto/bn/d.c b/src/lib/libcrypto/bn/d.c new file mode 100644 index 0000000000..ced2291b25 --- /dev/null +++ b/src/lib/libcrypto/bn/d.c | |||
@@ -0,0 +1,72 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <openssl/bio.h> | ||
3 | #include "bn_lcl.h" | ||
4 | |||
5 | #define SIZE_A (100*4+4) | ||
6 | #define SIZE_B (13*4) | ||
7 | |||
8 | main(argc,argv) | ||
9 | int argc; | ||
10 | char *argv[]; | ||
11 | { | ||
12 | BN_CTX ctx; | ||
13 | BN_RECP_CTX recp; | ||
14 | BIGNUM a,b,dd,d,r,rr,t,l; | ||
15 | int i; | ||
16 | |||
17 | MemCheck_start(); | ||
18 | MemCheck_on(); | ||
19 | BN_CTX_init(&ctx); | ||
20 | BN_RECP_CTX_init(&recp); | ||
21 | |||
22 | BN_init(&r); | ||
23 | BN_init(&rr); | ||
24 | BN_init(&d); | ||
25 | BN_init(&dd); | ||
26 | BN_init(&a); | ||
27 | BN_init(&b); | ||
28 | |||
29 | { | ||
30 | BN_rand(&a,SIZE_A,0,0); | ||
31 | BN_rand(&b,SIZE_B,0,0); | ||
32 | |||
33 | a.neg=1; | ||
34 | BN_RECP_CTX_set(&recp,&b,&ctx); | ||
35 | |||
36 | BN_print_fp(stdout,&a); printf(" a\n"); | ||
37 | BN_print_fp(stdout,&b); printf(" b\n"); | ||
38 | |||
39 | BN_print_fp(stdout,&recp.N); printf(" N\n"); | ||
40 | BN_print_fp(stdout,&recp.Nr); printf(" Nr num_bits=%d\n",recp.num_bits); | ||
41 | |||
42 | BN_div_recp(&r,&d,&a,&recp,&ctx); | ||
43 | |||
44 | for (i=0; i<300; i++) | ||
45 | BN_div(&rr,&dd,&a,&b,&ctx); | ||
46 | |||
47 | BN_print_fp(stdout,&r); printf(" div recp\n"); | ||
48 | BN_print_fp(stdout,&rr); printf(" div\n"); | ||
49 | BN_print_fp(stdout,&d); printf(" rem recp\n"); | ||
50 | BN_print_fp(stdout,&dd); printf(" rem\n"); | ||
51 | } | ||
52 | BN_CTX_free(&ctx); | ||
53 | BN_RECP_CTX_free(&recp); | ||
54 | |||
55 | BN_free(&r); | ||
56 | BN_free(&rr); | ||
57 | BN_free(&d); | ||
58 | BN_free(&dd); | ||
59 | BN_free(&a); | ||
60 | BN_free(&b); | ||
61 | |||
62 | { | ||
63 | BIO *out; | ||
64 | |||
65 | if ((out=BIO_new(BIO_s_file())) != NULL) | ||
66 | BIO_set_fp(out,stderr,BIO_NOCLOSE|BIO_FP_TEXT); | ||
67 | |||
68 | CRYPTO_mem_leaks(out); | ||
69 | BIO_free(out); | ||
70 | } | ||
71 | |||
72 | } | ||