diff options
author | djm <> | 2008-09-06 12:17:54 +0000 |
---|---|---|
committer | djm <> | 2008-09-06 12:17:54 +0000 |
commit | 38ce604e3cc97706b876b0525ddff0121115456d (patch) | |
tree | 7ccc28afe1789ea3dbedf72365f955d5b8e105b5 /src/lib/libcrypto/evp/evp_test.c | |
parent | 12867252827c8efaa8ddd1fa3b3d6e321e2bcdef (diff) | |
download | openbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.gz openbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.bz2 openbsd-38ce604e3cc97706b876b0525ddff0121115456d.zip |
resolve conflicts
Diffstat (limited to 'src/lib/libcrypto/evp/evp_test.c')
-rw-r--r-- | src/lib/libcrypto/evp/evp_test.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c index a624cfd248..bb6f02c2e9 100644 --- a/src/lib/libcrypto/evp/evp_test.c +++ b/src/lib/libcrypto/evp/evp_test.c | |||
@@ -52,6 +52,7 @@ | |||
52 | 52 | ||
53 | #include "../e_os.h" | 53 | #include "../e_os.h" |
54 | 54 | ||
55 | #include <openssl/opensslconf.h> | ||
55 | #include <openssl/evp.h> | 56 | #include <openssl/evp.h> |
56 | #ifndef OPENSSL_NO_ENGINE | 57 | #ifndef OPENSSL_NO_ENGINE |
57 | #include <openssl/engine.h> | 58 | #include <openssl/engine.h> |
@@ -136,7 +137,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
136 | const unsigned char *iv,int in, | 137 | const unsigned char *iv,int in, |
137 | const unsigned char *plaintext,int pn, | 138 | const unsigned char *plaintext,int pn, |
138 | const unsigned char *ciphertext,int cn, | 139 | const unsigned char *ciphertext,int cn, |
139 | int encdec,int multiplier) | 140 | int encdec) |
140 | { | 141 | { |
141 | EVP_CIPHER_CTX ctx; | 142 | EVP_CIPHER_CTX ctx; |
142 | unsigned char out[4096]; | 143 | unsigned char out[4096]; |
@@ -167,7 +168,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
167 | } | 168 | } |
168 | EVP_CIPHER_CTX_set_padding(&ctx,0); | 169 | EVP_CIPHER_CTX_set_padding(&ctx,0); |
169 | 170 | ||
170 | if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn*multiplier)) | 171 | if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) |
171 | { | 172 | { |
172 | fprintf(stderr,"Encrypt failed\n"); | 173 | fprintf(stderr,"Encrypt failed\n"); |
173 | ERR_print_errors_fp(stderr); | 174 | ERR_print_errors_fp(stderr); |
@@ -180,7 +181,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
180 | test1_exit(7); | 181 | test1_exit(7); |
181 | } | 182 | } |
182 | 183 | ||
183 | if(outl+outl2 != cn*multiplier) | 184 | if(outl+outl2 != cn) |
184 | { | 185 | { |
185 | fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", | 186 | fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", |
186 | outl+outl2,cn); | 187 | outl+outl2,cn); |
@@ -206,7 +207,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
206 | } | 207 | } |
207 | EVP_CIPHER_CTX_set_padding(&ctx,0); | 208 | EVP_CIPHER_CTX_set_padding(&ctx,0); |
208 | 209 | ||
209 | if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn*multiplier)) | 210 | if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn)) |
210 | { | 211 | { |
211 | fprintf(stderr,"Decrypt failed\n"); | 212 | fprintf(stderr,"Decrypt failed\n"); |
212 | ERR_print_errors_fp(stderr); | 213 | ERR_print_errors_fp(stderr); |
@@ -219,7 +220,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
219 | test1_exit(7); | 220 | test1_exit(7); |
220 | } | 221 | } |
221 | 222 | ||
222 | if(outl+outl2 != cn*multiplier) | 223 | if(outl+outl2 != cn) |
223 | { | 224 | { |
224 | fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", | 225 | fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", |
225 | outl+outl2,cn); | 226 | outl+outl2,cn); |
@@ -244,7 +245,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, | |||
244 | const unsigned char *iv,int in, | 245 | const unsigned char *iv,int in, |
245 | const unsigned char *plaintext,int pn, | 246 | const unsigned char *plaintext,int pn, |
246 | const unsigned char *ciphertext,int cn, | 247 | const unsigned char *ciphertext,int cn, |
247 | int encdec,int multiplier) | 248 | int encdec) |
248 | { | 249 | { |
249 | const EVP_CIPHER *c; | 250 | const EVP_CIPHER *c; |
250 | 251 | ||
@@ -252,7 +253,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, | |||
252 | if(!c) | 253 | if(!c) |
253 | return 0; | 254 | return 0; |
254 | 255 | ||
255 | test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec,multiplier); | 256 | test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec); |
256 | 257 | ||
257 | return 1; | 258 | return 1; |
258 | } | 259 | } |
@@ -368,7 +369,6 @@ int main(int argc,char **argv) | |||
368 | unsigned char *iv,*key,*plaintext,*ciphertext; | 369 | unsigned char *iv,*key,*plaintext,*ciphertext; |
369 | int encdec; | 370 | int encdec; |
370 | int kn,in,pn,cn; | 371 | int kn,in,pn,cn; |
371 | int multiplier=1; | ||
372 | 372 | ||
373 | if(!fgets((char *)line,sizeof line,f)) | 373 | if(!fgets((char *)line,sizeof line,f)) |
374 | break; | 374 | break; |
@@ -393,17 +393,44 @@ int main(int argc,char **argv) | |||
393 | pn=convert(plaintext); | 393 | pn=convert(plaintext); |
394 | cn=convert(ciphertext); | 394 | cn=convert(ciphertext); |
395 | 395 | ||
396 | if(strchr(cipher,'*')) | 396 | if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec) |
397 | { | ||
398 | p=cipher; | ||
399 | sstrsep(&p,"*"); | ||
400 | multiplier=atoi(sstrsep(&p,"*")); | ||
401 | } | ||
402 | |||
403 | if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec, | ||
404 | multiplier) | ||
405 | && !test_digest(cipher,plaintext,pn,ciphertext,cn)) | 397 | && !test_digest(cipher,plaintext,pn,ciphertext,cn)) |
406 | { | 398 | { |
399 | #ifdef OPENSSL_NO_AES | ||
400 | if (strstr(cipher, "AES") == cipher) | ||
401 | { | ||
402 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
403 | continue; | ||
404 | } | ||
405 | #endif | ||
406 | #ifdef OPENSSL_NO_DES | ||
407 | if (strstr(cipher, "DES") == cipher) | ||
408 | { | ||
409 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
410 | continue; | ||
411 | } | ||
412 | #endif | ||
413 | #ifdef OPENSSL_NO_RC4 | ||
414 | if (strstr(cipher, "RC4") == cipher) | ||
415 | { | ||
416 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
417 | continue; | ||
418 | } | ||
419 | #endif | ||
420 | #ifdef OPENSSL_NO_CAMELLIA | ||
421 | if (strstr(cipher, "CAMELLIA") == cipher) | ||
422 | { | ||
423 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
424 | continue; | ||
425 | } | ||
426 | #endif | ||
427 | #ifdef OPENSSL_NO_SEED | ||
428 | if (strstr(cipher, "SEED") == cipher) | ||
429 | { | ||
430 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
431 | continue; | ||
432 | } | ||
433 | #endif | ||
407 | fprintf(stderr,"Can't find %s\n",cipher); | 434 | fprintf(stderr,"Can't find %s\n",cipher); |
408 | EXIT(3); | 435 | EXIT(3); |
409 | } | 436 | } |