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/dsa/dsatest.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/dsa/dsatest.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsatest.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c index 39bb712c4a..fc25c9a1b7 100644 --- a/src/lib/libcrypto/dsa/dsatest.c +++ b/src/lib/libcrypto/dsa/dsatest.c | |||
| @@ -61,27 +61,30 @@ | |||
| 61 | #include <string.h> | 61 | #include <string.h> |
| 62 | #include <sys/types.h> | 62 | #include <sys/types.h> |
| 63 | #include <sys/stat.h> | 63 | #include <sys/stat.h> |
| 64 | #include "crypto.h" | 64 | #include <openssl/crypto.h> |
| 65 | #include "rand.h" | 65 | #include <openssl/rand.h> |
| 66 | #include "bio.h" | 66 | #include <openssl/bio.h> |
| 67 | #include "err.h" | 67 | #include <openssl/err.h> |
| 68 | #include "dsa.h" | ||
| 69 | #ifdef WINDOWS | 68 | #ifdef WINDOWS |
| 70 | #include "../bio/bss_file.c" | 69 | #include "../bio/bss_file.c" |
| 71 | #endif | 70 | #endif |
| 72 | 71 | ||
| 72 | #ifdef NO_DSA | ||
| 73 | int main(int argc, char *argv[]) | ||
| 74 | { | ||
| 75 | printf("No DSA support\n"); | ||
| 76 | return(0); | ||
| 77 | } | ||
| 78 | #else | ||
| 79 | #include <openssl/dsa.h> | ||
| 80 | |||
| 73 | #ifdef WIN16 | 81 | #ifdef WIN16 |
| 74 | #define MS_CALLBACK _far _loadds | 82 | #define MS_CALLBACK _far _loadds |
| 75 | #else | 83 | #else |
| 76 | #define MS_CALLBACK | 84 | #define MS_CALLBACK |
| 77 | #endif | 85 | #endif |
| 78 | 86 | ||
| 79 | #ifndef NOPROTO | ||
| 80 | static void MS_CALLBACK dsa_cb(int p, int n, char *arg); | 87 | static void MS_CALLBACK dsa_cb(int p, int n, char *arg); |
| 81 | #else | ||
| 82 | static void MS_CALLBACK dsa_cb(); | ||
| 83 | #endif | ||
| 84 | |||
| 85 | static unsigned char seed[20]={ | 88 | static unsigned char seed[20]={ |
| 86 | 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, | 89 | 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, |
| 87 | 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, | 90 | 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, |
| @@ -115,20 +118,24 @@ static unsigned char out_g[]={ | |||
| 115 | 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02, | 118 | 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02, |
| 116 | }; | 119 | }; |
| 117 | 120 | ||
| 121 | static const unsigned char str1[]="12345678901234567890"; | ||
| 122 | |||
| 118 | static BIO *bio_err=NULL; | 123 | static BIO *bio_err=NULL; |
| 119 | 124 | ||
| 120 | int main(argc, argv) | 125 | int main(int argc, char **argv) |
| 121 | int argc; | ||
| 122 | char **argv; | ||
| 123 | { | 126 | { |
| 124 | DSA *dsa=NULL; | 127 | DSA *dsa=NULL; |
| 125 | int counter,ret=0,i,j; | 128 | int counter,ret=0,i,j; |
| 126 | unsigned char buf[256]; | 129 | unsigned char buf[256]; |
| 127 | unsigned long h; | 130 | unsigned long h; |
| 131 | unsigned char sig[256]; | ||
| 132 | unsigned int siglen; | ||
| 128 | 133 | ||
| 129 | if (bio_err == NULL) | 134 | if (bio_err == NULL) |
| 130 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | 135 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); |
| 131 | 136 | ||
| 137 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | ||
| 138 | |||
| 132 | BIO_printf(bio_err,"test generation of DSA parameters\n"); | 139 | BIO_printf(bio_err,"test generation of DSA parameters\n"); |
| 133 | BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n"); | 140 | BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n"); |
| 134 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb, | 141 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb, |
| @@ -178,21 +185,21 @@ char **argv; | |||
| 178 | BIO_printf(bio_err,"g value is wrong\n"); | 185 | BIO_printf(bio_err,"g value is wrong\n"); |
| 179 | goto end; | 186 | goto end; |
| 180 | } | 187 | } |
| 181 | 188 | DSA_generate_key(dsa); | |
| 182 | ret=1; | 189 | DSA_sign(0, str1, 20, sig, &siglen, dsa); |
| 190 | if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1) | ||
| 191 | ret=1; | ||
| 183 | end: | 192 | end: |
| 184 | if (!ret) | 193 | if (!ret) |
| 185 | ERR_print_errors(bio_err); | 194 | ERR_print_errors(bio_err); |
| 186 | if (bio_err != NULL) BIO_free(bio_err); | ||
| 187 | if (dsa != NULL) DSA_free(dsa); | 195 | if (dsa != NULL) DSA_free(dsa); |
| 196 | CRYPTO_mem_leaks(bio_err); | ||
| 197 | if (bio_err != NULL) BIO_free(bio_err); | ||
| 188 | exit(!ret); | 198 | exit(!ret); |
| 189 | return(0); | 199 | return(0); |
| 190 | } | 200 | } |
| 191 | 201 | ||
| 192 | static void MS_CALLBACK dsa_cb(p, n, arg) | 202 | static void MS_CALLBACK dsa_cb(int p, int n, char *arg) |
| 193 | int p; | ||
| 194 | int n; | ||
| 195 | char *arg; | ||
| 196 | { | 203 | { |
| 197 | char c='*'; | 204 | char c='*'; |
| 198 | static int ok=0,num=0; | 205 | static int ok=0,num=0; |
| @@ -202,7 +209,7 @@ char *arg; | |||
| 202 | if (p == 2) { c='*'; ok++; } | 209 | if (p == 2) { c='*'; ok++; } |
| 203 | if (p == 3) c='\n'; | 210 | if (p == 3) c='\n'; |
| 204 | BIO_write((BIO *)arg,&c,1); | 211 | BIO_write((BIO *)arg,&c,1); |
| 205 | BIO_flush((BIO *)arg); | 212 | (void)BIO_flush((BIO *)arg); |
| 206 | 213 | ||
| 207 | if (!ok && (p == 0) && (num > 1)) | 214 | if (!ok && (p == 0) && (num > 1)) |
| 208 | { | 215 | { |
| @@ -210,5 +217,4 @@ char *arg; | |||
| 210 | exit(1); | 217 | exit(1); |
| 211 | } | 218 | } |
| 212 | } | 219 | } |
| 213 | 220 | #endif | |
| 214 | |||
