summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/evp/evptest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libcrypto/evp/evptest.c')
-rw-r--r--src/regress/lib/libcrypto/evp/evptest.c14
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);