diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/dh/dhtest.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/lib/libcrypto/dh/dhtest.c b/src/lib/libcrypto/dh/dhtest.c index f0151253d7..34894ced73 100644 --- a/src/lib/libcrypto/dh/dhtest.c +++ b/src/lib/libcrypto/dh/dhtest.c | |||
| @@ -59,15 +59,16 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 61 | #include <string.h> | 61 | #include <string.h> |
| 62 | #ifdef WINDOWS | 62 | #ifdef OPENSSL_SYS_WINDOWS |
| 63 | #include "../bio/bss_file.c" | 63 | #include "../bio/bss_file.c" |
| 64 | #endif | 64 | #endif |
| 65 | #include <openssl/crypto.h> | 65 | #include <openssl/crypto.h> |
| 66 | #include <openssl/bio.h> | 66 | #include <openssl/bio.h> |
| 67 | #include <openssl/bn.h> | 67 | #include <openssl/bn.h> |
| 68 | #include <openssl/rand.h> | 68 | #include <openssl/rand.h> |
| 69 | #include <openssl/err.h> | ||
| 69 | 70 | ||
| 70 | #ifdef NO_DH | 71 | #ifdef OPENSSL_NO_DH |
| 71 | int main(int argc, char *argv[]) | 72 | int main(int argc, char *argv[]) |
| 72 | { | 73 | { |
| 73 | printf("No DH support\n"); | 74 | printf("No DH support\n"); |
| @@ -76,14 +77,14 @@ int main(int argc, char *argv[]) | |||
| 76 | #else | 77 | #else |
| 77 | #include <openssl/dh.h> | 78 | #include <openssl/dh.h> |
| 78 | 79 | ||
| 79 | #ifdef WIN16 | 80 | #ifdef OPENSSL_SYS_WIN16 |
| 80 | #define MS_CALLBACK _far _loadds | 81 | #define MS_CALLBACK _far _loadds |
| 81 | #else | 82 | #else |
| 82 | #define MS_CALLBACK | 83 | #define MS_CALLBACK |
| 83 | #endif | 84 | #endif |
| 84 | 85 | ||
| 85 | static void MS_CALLBACK cb(int p, int n, void *arg); | 86 | static void MS_CALLBACK cb(int p, int n, void *arg); |
| 86 | #ifdef NO_STDIO | 87 | #ifdef OPENSSL_NO_STDIO |
| 87 | #define APPS_WIN16 | 88 | #define APPS_WIN16 |
| 88 | #include "bss_file.c" | 89 | #include "bss_file.c" |
| 89 | #endif | 90 | #endif |
| @@ -99,7 +100,11 @@ int main(int argc, char *argv[]) | |||
| 99 | int i,alen,blen,aout,bout,ret=1; | 100 | int i,alen,blen,aout,bout,ret=1; |
| 100 | BIO *out; | 101 | BIO *out; |
| 101 | 102 | ||
| 102 | #ifdef WIN32 | 103 | CRYPTO_malloc_debug_init(); |
| 104 | CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); | ||
| 105 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | ||
| 106 | |||
| 107 | #ifdef OPENSSL_SYS_WIN32 | ||
| 103 | CRYPTO_malloc_init(); | 108 | CRYPTO_malloc_init(); |
| 104 | #endif | 109 | #endif |
| 105 | 110 | ||
| @@ -112,6 +117,16 @@ int main(int argc, char *argv[]) | |||
| 112 | a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out); | 117 | a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out); |
| 113 | if (a == NULL) goto err; | 118 | if (a == NULL) goto err; |
| 114 | 119 | ||
| 120 | if (!DH_check(a, &i)) goto err; | ||
| 121 | if (i & DH_CHECK_P_NOT_PRIME) | ||
| 122 | BIO_puts(out, "p value is not prime\n"); | ||
| 123 | if (i & DH_CHECK_P_NOT_SAFE_PRIME) | ||
| 124 | BIO_puts(out, "p value is not a safe prime\n"); | ||
| 125 | if (i & DH_UNABLE_TO_CHECK_GENERATOR) | ||
| 126 | BIO_puts(out, "unable to check the generator value\n"); | ||
| 127 | if (i & DH_NOT_SUITABLE_GENERATOR) | ||
| 128 | BIO_puts(out, "the g value is not a generator\n"); | ||
| 129 | |||
| 115 | BIO_puts(out,"\np ="); | 130 | BIO_puts(out,"\np ="); |
| 116 | BN_print(out,a->p); | 131 | BN_print(out,a->p); |
| 117 | BIO_puts(out,"\ng ="); | 132 | BIO_puts(out,"\ng ="); |
| @@ -170,11 +185,16 @@ int main(int argc, char *argv[]) | |||
| 170 | else | 185 | else |
| 171 | ret=0; | 186 | ret=0; |
| 172 | err: | 187 | err: |
| 188 | ERR_print_errors_fp(stderr); | ||
| 189 | |||
| 173 | if (abuf != NULL) OPENSSL_free(abuf); | 190 | if (abuf != NULL) OPENSSL_free(abuf); |
| 174 | if (bbuf != NULL) OPENSSL_free(bbuf); | 191 | if (bbuf != NULL) OPENSSL_free(bbuf); |
| 175 | if(b != NULL) DH_free(b); | 192 | if(b != NULL) DH_free(b); |
| 176 | if(a != NULL) DH_free(a); | 193 | if(a != NULL) DH_free(a); |
| 177 | BIO_free(out); | 194 | BIO_free(out); |
| 195 | CRYPTO_cleanup_all_ex_data(); | ||
| 196 | ERR_remove_state(0); | ||
| 197 | CRYPTO_mem_leaks_fp(stderr); | ||
| 178 | exit(ret); | 198 | exit(ret); |
| 179 | return(ret); | 199 | return(ret); |
| 180 | } | 200 | } |
