]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Fix tests/slow/cipher-openssl-compat.c for OpenSSL 1.1.0
authorTim Rühsen <tim.ruehsen@gmx.de>
Tue, 19 Jul 2016 09:08:10 +0000 (11:08 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 19 Jul 2016 10:48:17 +0000 (12:48 +0200)
tests/slow/cipher-openssl-compat.c

index e2b9b28360c4868d19e6786c0f9cfd95c32f0c3d..cf8b86b25ea7c9a99bbeed9126c020c9f03034fc 100644 (file)
@@ -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;
 }