diff options
| author | cvs2svn <admin@example.com> | 2012-07-13 17:49:56 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2012-07-13 17:49:56 +0000 |
| commit | ee04221ea8063435416c7e6369e6eae76843aa71 (patch) | |
| tree | 821921a1dd0a5a3cece91121e121cc63c4b68128 /src/lib/libcrypto/bn/divtest.c | |
| parent | adf6731f6e1d04718aee00cb93435143046aee9a (diff) | |
| download | openbsd-eric_g2k12.tar.gz openbsd-eric_g2k12.tar.bz2 openbsd-eric_g2k12.zip | |
This commit was manufactured by cvs2git to create tag 'eric_g2k12'.eric_g2k12
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/bn/divtest.c | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/lib/libcrypto/bn/divtest.c b/src/lib/libcrypto/bn/divtest.c deleted file mode 100644 index d3fc688f33..0000000000 --- a/src/lib/libcrypto/bn/divtest.c +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | #include <openssl/bn.h> | ||
| 2 | #include <openssl/rand.h> | ||
| 3 | |||
| 4 | static int Rand(n) | ||
| 5 | { | ||
| 6 | unsigned char x[2]; | ||
| 7 | RAND_pseudo_bytes(x,2); | ||
| 8 | return (x[0] + 2*x[1]); | ||
| 9 | } | ||
| 10 | |||
| 11 | static void bug(char *m, BIGNUM *a, BIGNUM *b) | ||
| 12 | { | ||
| 13 | printf("%s!\na=",m); | ||
| 14 | BN_print_fp(stdout, a); | ||
| 15 | printf("\nb="); | ||
| 16 | BN_print_fp(stdout, b); | ||
| 17 | printf("\n"); | ||
| 18 | fflush(stdout); | ||
| 19 | } | ||
| 20 | |||
| 21 | main() | ||
| 22 | { | ||
| 23 | BIGNUM *a=BN_new(), *b=BN_new(), *c=BN_new(), *d=BN_new(), | ||
| 24 | *C=BN_new(), *D=BN_new(); | ||
| 25 | BN_RECP_CTX *recp=BN_RECP_CTX_new(); | ||
| 26 | BN_CTX *ctx=BN_CTX_new(); | ||
| 27 | |||
| 28 | for(;;) { | ||
| 29 | BN_pseudo_rand(a,Rand(),0,0); | ||
| 30 | BN_pseudo_rand(b,Rand(),0,0); | ||
| 31 | if (BN_is_zero(b)) continue; | ||
| 32 | |||
| 33 | BN_RECP_CTX_set(recp,b,ctx); | ||
| 34 | if (BN_div(C,D,a,b,ctx) != 1) | ||
| 35 | bug("BN_div failed",a,b); | ||
| 36 | if (BN_div_recp(c,d,a,recp,ctx) != 1) | ||
| 37 | bug("BN_div_recp failed",a,b); | ||
| 38 | else if (BN_cmp(c,C) != 0 || BN_cmp(c,C) != 0) | ||
| 39 | bug("mismatch",a,b); | ||
| 40 | } | ||
| 41 | } | ||
