summaryrefslogtreecommitdiff
path: root/tests/slow/cipher-openssl-compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/slow/cipher-openssl-compat.c')
-rw-r--r--tests/slow/cipher-openssl-compat.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/tests/slow/cipher-openssl-compat.c b/tests/slow/cipher-openssl-compat.c
index 3d55131e52..663f73e0b1 100644
--- a/tests/slow/cipher-openssl-compat.c
+++ b/tests/slow/cipher-openssl-compat.c
@@ -43,7 +43,8 @@ static int cipher_test(const char *ocipher, gnutls_cipher_algorithm_t gcipher,
if (!evp_cipher) {
/* XXX: fix version check later when LibreSSL fixes support for aes-ccm and chacha20-poly1305 */
#ifdef LIBRESSL_VERSION_NUMBER
- fprintf(stderr, "EVP_get_cipherbyname failed for %s\n", ocipher);
+ fprintf(stderr, "EVP_get_cipherbyname failed for %s\n",
+ ocipher);
return -1;
#else
/* OpenSSL should always work! */
@@ -109,12 +110,14 @@ static int cipher_test(const char *ocipher, gnutls_cipher_algorithm_t gcipher,
assert(EVP_CipherInit_ex(ctx, evp_cipher, 0, 0, 0, 0) >
0);
- assert(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN, dnonce.size, 0)==1);
- assert(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, tag_size,
- enc_data + enc_data_size - tag_size) == 1);
+ assert(EVP_CIPHER_CTX_ctrl
+ (ctx, EVP_CTRL_CCM_SET_IVLEN, dnonce.size,
+ 0) == 1);
+ assert(EVP_CIPHER_CTX_ctrl
+ (ctx, EVP_CTRL_CCM_SET_TAG, tag_size,
+ enc_data + enc_data_size - tag_size) == 1);
- assert(EVP_CipherInit_ex(ctx, 0, 0, key, nonce, 0) >
- 0);
+ assert(EVP_CipherInit_ex(ctx, 0, 0, key, nonce, 0) > 0);
dec_data_size2 = sizeof(dec_data);
/* Add plain size */
@@ -138,16 +141,18 @@ static int cipher_test(const char *ocipher, gnutls_cipher_algorithm_t gcipher,
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);
+ fail("openssl decrypt failed for %s\n",
+ ocipher);
}
} else
#endif
{
- assert(EVP_CipherInit_ex(ctx, evp_cipher, NULL, key, nonce, 0) >
- 0);
+ 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);
+ enc_data + enc_data_size -
+ tag_size);
dec_data_size2 = sizeof(dec_data);
@@ -163,12 +168,14 @@ static int cipher_test(const char *ocipher, gnutls_cipher_algorithm_t gcipher,
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);
+ fail("openssl decrypt failed for %s\n",
+ ocipher);
}
}
@@ -199,7 +206,8 @@ void doit(void)
cipher_test("aes-256-gcm", GNUTLS_CIPHER_AES_256_GCM, 16);
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
if (!gnutls_fips140_mode_enabled()) {
- cipher_test("chacha20-poly1305", GNUTLS_CIPHER_CHACHA20_POLY1305, 16);
+ cipher_test("chacha20-poly1305",
+ GNUTLS_CIPHER_CHACHA20_POLY1305, 16);
}
cipher_test("aes-128-ccm", GNUTLS_CIPHER_AES_128_CCM, 16);
cipher_test("aes-256-ccm", GNUTLS_CIPHER_AES_256_CCM, 16);