summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/slow/cipher-openssl-compat.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/slow/cipher-openssl-compat.c b/tests/slow/cipher-openssl-compat.c
index e2b9b28360..cf8b86b25e 100644
--- a/tests/slow/cipher-openssl-compat.c
+++ b/tests/slow/cipher-openssl-compat.c
@@ -29,7 +29,7 @@ static int cipher_test(const char *ocipher, gnutls_cipher_algorithm_t gcipher, u
unsigned char nonce[32];
size_t enc_data_size, dec_data_size;
int dec_data_size2;
- EVP_CIPHER_CTX ctx;
+ EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *evp_cipher;
unsigned char tag[64];
@@ -72,24 +72,26 @@ static int cipher_test(const char *ocipher, gnutls_cipher_algorithm_t gcipher, u
if (!evp_cipher)
fail("EVP_get_cipherbyname failed for %s\n", ocipher);
- EVP_CIPHER_CTX_init(&ctx);
- assert(EVP_CipherInit_ex(&ctx, evp_cipher, NULL, key, nonce, 0) > 0);
+ ctx = EVP_CIPHER_CTX_new();
+ assert(EVP_CipherInit_ex(ctx, evp_cipher, NULL, key, nonce, 0) > 0);
- EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_TAG, tag_size, enc_data+enc_data_size-tag_size);
+ EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, tag_size, enc_data+enc_data_size-tag_size);
dec_data_size2 = sizeof(dec_data);
- assert(EVP_CipherUpdate(&ctx, NULL, &dec_data_size2, buffer_auth, sizeof(buffer_auth)) > 0);
+ assert(EVP_CipherUpdate(ctx, NULL, &dec_data_size2, buffer_auth, sizeof(buffer_auth)) > 0);
dec_data_size2 = sizeof(dec_data);
- assert(EVP_CipherUpdate(&ctx, dec_data, &dec_data_size2, enc_data, enc_data_size-tag_size) > 0);
+ assert(EVP_CipherUpdate(ctx, dec_data, &dec_data_size2, enc_data, enc_data_size-tag_size) > 0);
dec_data_size = dec_data_size2;
dec_data_size2 = tag_size;
- assert(EVP_CipherFinal_ex(&ctx, tag, &dec_data_size2) > 0);
+ assert(EVP_CipherFinal_ex(ctx, tag, &dec_data_size2) > 0);
if (dec_data_size != sizeof(orig_plain_data) || memcmp(dec_data, orig_plain_data, sizeof(orig_plain_data)) != 0) {
fail("openssl decrypt failed for %s\n", ocipher);
}
+ EVP_CIPHER_CTX_free(ctx);
+
return 0;
}