diff options
| author | tb <> | 2019-03-17 18:33:01 +0000 |
|---|---|---|
| committer | tb <> | 2019-03-17 18:33:01 +0000 |
| commit | 696dbec343bbc1f2a951f94db4f0679e72d036d2 (patch) | |
| tree | 52355aa2d8c139bc0289da29c7c07080a7b22830 /src/regress/lib/libcrypto/evp/evptest.c | |
| parent | eac4591451eefd34ad7f5aa42943092c45da254e (diff) | |
| download | openbsd-696dbec343bbc1f2a951f94db4f0679e72d036d2.tar.gz openbsd-696dbec343bbc1f2a951f94db4f0679e72d036d2.tar.bz2 openbsd-696dbec343bbc1f2a951f94db4f0679e72d036d2.zip | |
Add regress tests for the EVP_aes_*_wrap() API. Based on the tests in
OpenSSL 1.0.2r which is still freely licenced with a tweak by jsing.
Diffstat (limited to 'src/regress/lib/libcrypto/evp/evptest.c')
| -rw-r--r-- | src/regress/lib/libcrypto/evp/evptest.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/evp/evptest.c b/src/regress/lib/libcrypto/evp/evptest.c index 1aa11d7b1e..ac15a55aaa 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.7 2018/07/17 17:06:49 tb Exp $ */ | 1 | /* $OpenBSD: evptest.c,v 1.8 2019/03/17 18:33:01 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. |
| @@ -144,6 +144,7 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, | |||
| 144 | { | 144 | { |
| 145 | EVP_CIPHER_CTX ctx; | 145 | EVP_CIPHER_CTX ctx; |
| 146 | unsigned char out[4096]; | 146 | unsigned char out[4096]; |
| 147 | const unsigned char *eiv; | ||
| 147 | int outl, outl2; | 148 | int outl, outl2; |
| 148 | 149 | ||
| 149 | printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), | 150 | printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), |
| @@ -160,8 +161,12 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, | |||
| 160 | test1_exit(5); | 161 | test1_exit(5); |
| 161 | } | 162 | } |
| 162 | EVP_CIPHER_CTX_init(&ctx); | 163 | EVP_CIPHER_CTX_init(&ctx); |
| 164 | EVP_CIPHER_CTX_set_flags(&ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW); | ||
| 163 | if (encdec != 0) { | 165 | if (encdec != 0) { |
| 164 | if (!EVP_EncryptInit_ex(&ctx, c,NULL, key, iv)) { | 166 | eiv = iv; |
| 167 | if (EVP_CIPHER_mode(c) == EVP_CIPH_WRAP_MODE && in == 0) | ||
| 168 | eiv = NULL; | ||
| 169 | if (!EVP_EncryptInit_ex(&ctx, c, NULL, key, eiv)) { | ||
| 165 | fprintf(stderr, "EncryptInit failed\n"); | 170 | fprintf(stderr, "EncryptInit failed\n"); |
| 166 | ERR_print_errors_fp(stderr); | 171 | ERR_print_errors_fp(stderr); |
| 167 | test1_exit(10); | 172 | test1_exit(10); |
| @@ -194,7 +199,10 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, | |||
| 194 | } | 199 | } |
| 195 | 200 | ||
| 196 | if (encdec <= 0) { | 201 | if (encdec <= 0) { |
| 197 | if (!EVP_DecryptInit_ex(&ctx, c,NULL, key, iv)) { | 202 | eiv = iv; |
| 203 | if (EVP_CIPHER_mode(c) == EVP_CIPH_WRAP_MODE && in == 0) | ||
| 204 | eiv = NULL; | ||
| 205 | if (!EVP_DecryptInit_ex(&ctx, c,NULL, key, eiv)) { | ||
| 198 | fprintf(stderr, "DecryptInit failed\n"); | 206 | fprintf(stderr, "DecryptInit failed\n"); |
| 199 | ERR_print_errors_fp(stderr); | 207 | ERR_print_errors_fp(stderr); |
| 200 | test1_exit(11); | 208 | test1_exit(11); |
