diff options
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libcrypto/evp/evptest.c | 71 | 
1 files changed, 45 insertions, 26 deletions
| diff --git a/src/regress/lib/libcrypto/evp/evptest.c b/src/regress/lib/libcrypto/evp/evptest.c index e6108de982..6f677dd959 100644 --- a/src/regress/lib/libcrypto/evp/evptest.c +++ b/src/regress/lib/libcrypto/evp/evptest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evptest.c,v 1.11 2021/11/18 21:18:28 tb Exp $ */ | 1 | /* $OpenBSD: evptest.c,v 1.12 2023/03/02 20:24:51 tb Exp $ */ | 
| 2 | /* Written by Ben Laurie, 2001 */ | 2 | /* Written by Ben Laurie, 2001 */ | 
| 3 | /* | 3 | /* | 
| 4 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 4 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 
| @@ -59,6 +59,8 @@ | |||
| 59 | #include <openssl/err.h> | 59 | #include <openssl/err.h> | 
| 60 | #include <openssl/conf.h> | 60 | #include <openssl/conf.h> | 
| 61 | 61 | ||
| 62 | int verbose; | ||
| 63 | |||
| 62 | static void | 64 | static void | 
| 63 | hexdump(FILE *f, const char *title, const unsigned char *s, int l) | 65 | hexdump(FILE *f, const char *title, const unsigned char *s, int l) | 
| 64 | { | 66 | { | 
| @@ -147,13 +149,15 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, | |||
| 147 | const unsigned char *eiv; | 149 | const unsigned char *eiv; | 
| 148 | int outl, outl2; | 150 | int outl, outl2; | 
| 149 | 151 | ||
| 150 | printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), | 152 | if (verbose) { | 
| 151 | (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)"))); | 153 | printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), | 
| 152 | hexdump(stdout, "Key",key,kn); | 154 | (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)"))); | 
| 153 | if (in) | 155 | hexdump(stdout, "Key",key,kn); | 
| 154 | hexdump(stdout, "IV",iv,in); | 156 | if (in) | 
| 155 | hexdump(stdout, "Plaintext",plaintext,pn); | 157 | hexdump(stdout, "IV",iv,in); | 
| 156 | hexdump(stdout, "Ciphertext",ciphertext,cn); | 158 | hexdump(stdout, "Plaintext",plaintext,pn); | 
| 159 | hexdump(stdout, "Ciphertext",ciphertext,cn); | ||
| 160 | } | ||
| 157 | 161 | ||
| 158 | if (kn != EVP_CIPHER_key_length(c)) { | 162 | if (kn != EVP_CIPHER_key_length(c)) { | 
| 159 | fprintf(stderr, "Key length doesn't match, got %d expected %lu\n",kn, | 163 | fprintf(stderr, "Key length doesn't match, got %d expected %lu\n",kn, | 
| @@ -240,7 +244,8 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, | |||
| 240 | 244 | ||
| 241 | EVP_CIPHER_CTX_free(ctx); | 245 | EVP_CIPHER_CTX_free(ctx); | 
| 242 | 246 | ||
| 243 | printf("\n"); | 247 | if (verbose) | 
| 248 | printf("\n"); | ||
| 244 | } | 249 | } | 
| 245 | 250 | ||
| 246 | static int | 251 | static int | 
| @@ -272,9 +277,11 @@ test_digest(const char *digest, const unsigned char *plaintext, int pn, | |||
| 272 | if (!d) | 277 | if (!d) | 
| 273 | return 0; | 278 | return 0; | 
| 274 | 279 | ||
| 275 | printf("Testing digest %s\n",EVP_MD_name(d)); | 280 | if (verbose) { | 
| 276 | hexdump(stdout, "Plaintext",plaintext,pn); | 281 | printf("Testing digest %s\n",EVP_MD_name(d)); | 
| 277 | hexdump(stdout, "Digest",ciphertext,cn); | 282 | hexdump(stdout, "Plaintext",plaintext,pn); | 
| 283 | hexdump(stdout, "Digest",ciphertext,cn); | ||
| 284 | } | ||
| 278 | 285 | ||
| 279 | if ((ctx = EVP_MD_CTX_new()) == NULL) { | 286 | if ((ctx = EVP_MD_CTX_new()) == NULL) { | 
| 280 | fprintf(stderr, "EVP_CIPHER_CTX_new failed\n"); | 287 | fprintf(stderr, "EVP_CIPHER_CTX_new failed\n"); | 
| @@ -310,8 +317,8 @@ test_digest(const char *digest, const unsigned char *plaintext, int pn, | |||
| 310 | hexdump(stderr, "Expected",ciphertext,cn); | 317 | hexdump(stderr, "Expected",ciphertext,cn); | 
| 311 | exit(103); | 318 | exit(103); | 
| 312 | } | 319 | } | 
| 313 | 320 | if (verbose) | |
| 314 | printf("\n"); | 321 | printf("\n"); | 
| 315 | 322 | ||
| 316 | return 1; | 323 | return 1; | 
| 317 | } | 324 | } | 
| @@ -322,10 +329,15 @@ main(int argc, char **argv) | |||
| 322 | const char *szTestFile; | 329 | const char *szTestFile; | 
| 323 | FILE *f; | 330 | FILE *f; | 
| 324 | 331 | ||
| 325 | if (argc != 2) { | 332 | if (argc != 2 && argc != 3) { | 
| 326 | fprintf(stderr, "%s <test file>\n",argv[0]); | 333 | fprintf(stderr, "%s <test file>\n",argv[0]); | 
| 327 | exit(1); | 334 | exit(1); | 
| 328 | } | 335 | } | 
| 336 | if (argc == 3 && strcmp(argv[1], "-v") == 0) { | ||
| 337 | verbose = 1; | ||
| 338 | argv++; | ||
| 339 | argc--; | ||
| 340 | } | ||
| 329 | 341 | ||
| 330 | szTestFile = argv[1]; | 342 | szTestFile = argv[1]; | 
| 331 | 343 | ||
| @@ -390,45 +402,52 @@ main(int argc, char **argv) | |||
| 390 | if (!test_cipher(cipher, key, kn, iv, in, plaintext, pn, ciphertext, cn, encdec) && | 402 | if (!test_cipher(cipher, key, kn, iv, in, plaintext, pn, ciphertext, cn, encdec) && | 
| 391 | !test_digest(cipher, plaintext, pn, ciphertext, cn)) { | 403 | !test_digest(cipher, plaintext, pn, ciphertext, cn)) { | 
| 392 | #ifdef OPENSSL_NO_AES | 404 | #ifdef OPENSSL_NO_AES | 
| 393 | if (strstr(cipher, "AES") == cipher) { | 405 | if (strstr(cipher, "AES") == cipher && verbose) { | 
| 394 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 406 | if (verbose) | 
| 407 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 395 | continue; | 408 | continue; | 
| 396 | } | 409 | } | 
| 397 | #endif | 410 | #endif | 
| 398 | #ifdef OPENSSL_NO_DES | 411 | #ifdef OPENSSL_NO_DES | 
| 399 | if (strstr(cipher, "DES") == cipher) { | 412 | if (strstr(cipher, "DES") == cipher && verbose) { | 
| 400 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 413 | if (verbose) | 
| 414 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 401 | continue; | 415 | continue; | 
| 402 | } | 416 | } | 
| 403 | #endif | 417 | #endif | 
| 404 | #ifdef OPENSSL_NO_RC4 | 418 | #ifdef OPENSSL_NO_RC4 | 
| 405 | if (strstr(cipher, "RC4") == cipher) { | 419 | if (strstr(cipher, "RC4") == cipher && verbose) { | 
| 406 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 420 | if (verbose) | 
| 421 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 407 | continue; | 422 | continue; | 
| 408 | } | 423 | } | 
| 409 | #endif | 424 | #endif | 
| 410 | #ifdef OPENSSL_NO_CAMELLIA | 425 | #ifdef OPENSSL_NO_CAMELLIA | 
| 411 | if (strstr(cipher, "CAMELLIA") == cipher) { | 426 | if (strstr(cipher, "CAMELLIA") == cipher && verbose) { | 
| 412 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 427 | if (verbose) | 
| 428 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 413 | continue; | 429 | continue; | 
| 414 | } | 430 | } | 
| 415 | #endif | 431 | #endif | 
| 416 | #ifdef OPENSSL_NO_SEED | 432 | #ifdef OPENSSL_NO_SEED | 
| 417 | if (strstr(cipher, "SEED") == cipher) { | 433 | if (strstr(cipher, "SEED") == cipher) { | 
| 418 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 434 | if (verbose) | 
| 435 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 419 | continue; | 436 | continue; | 
| 420 | } | 437 | } | 
| 421 | #endif | 438 | #endif | 
| 422 | #ifdef OPENSSL_NO_CHACHA | 439 | #ifdef OPENSSL_NO_CHACHA | 
| 423 | if (strstr(cipher, "ChaCha") == cipher) { | 440 | if (strstr(cipher, "ChaCha") == cipher) { | 
| 424 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 441 | if (verbose) | 
| 442 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 425 | continue; | 443 | continue; | 
| 426 | } | 444 | } | 
| 427 | #endif | 445 | #endif | 
| 428 | #ifdef OPENSSL_NO_GOST | 446 | #ifdef OPENSSL_NO_GOST | 
| 429 | if (strstr(cipher, "md_gost") == cipher || | 447 | if (strstr(cipher, "md_gost") == cipher || | 
| 430 | strstr(cipher, "streebog") == cipher) { | 448 | strstr(cipher, "streebog") == cipher) { | 
| 431 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | 449 | if (verbose) | 
| 450 | fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); | ||
| 432 | continue; | 451 | continue; | 
| 433 | } | 452 | } | 
| 434 | #endif | 453 | #endif | 
