From 88717d995b811aa49e8c4d2fc7ed7c2a3b0e766c Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 12 Sep 2019 20:28:54 +0200 Subject: [PATCH] Indent --- test/default/aead_aegis256.c | 152 +++++++++++++++-------------------- 1 file changed, 67 insertions(+), 85 deletions(-) diff --git a/test/default/aead_aegis256.c b/test/default/aead_aegis256.c index d26e931d..582a2dc1 100644 --- a/test/default/aead_aegis256.c +++ b/test/default/aead_aegis256.c @@ -2054,130 +2054,112 @@ static struct { static int tv(void) { - unsigned char *ad; - unsigned char *ciphertext; - unsigned char *decrypted; - unsigned char *detached_ciphertext; - unsigned char *expected_ciphertext; - unsigned char *key; - unsigned char *message; - unsigned char *mac; - unsigned char *nonce; - char *hex; - unsigned long long found_ciphertext_len; - unsigned long long found_mac_len; - unsigned long long found_message_len; - size_t ad_len; - size_t ciphertext_len; - size_t detached_ciphertext_len; - size_t i = 0U; - size_t message_len; + unsigned char *ad; + unsigned char *ciphertext; + unsigned char *decrypted; + unsigned char *detached_ciphertext; + unsigned char *expected_ciphertext; + unsigned char *key; + unsigned char *message; + unsigned char *mac; + unsigned char *nonce; + char *hex; + unsigned long long found_ciphertext_len; + unsigned long long found_mac_len; + unsigned long long found_message_len; + size_t ad_len; + size_t ciphertext_len; + size_t detached_ciphertext_len; + size_t i = 0U; + size_t message_len; - key = (unsigned char *)sodium_malloc(crypto_aead_aegis256_KEYBYTES); - nonce = (unsigned char *)sodium_malloc(crypto_aead_aegis256_NPUBBYTES); - mac = (unsigned char *)sodium_malloc(crypto_aead_aegis256_ABYTES); + key = (unsigned char *) sodium_malloc(crypto_aead_aegis256_KEYBYTES); + nonce = (unsigned char *) sodium_malloc(crypto_aead_aegis256_NPUBBYTES); + mac = (unsigned char *) sodium_malloc(crypto_aead_aegis256_ABYTES); do { assert(strlen(tests[i].key_hex) == 2 * crypto_aead_aegis256_KEYBYTES); - sodium_hex2bin(key, crypto_aead_aegis256_KEYBYTES, - tests[i].key_hex, strlen(tests[i].key_hex), - NULL, NULL, NULL); + sodium_hex2bin(key, crypto_aead_aegis256_KEYBYTES, tests[i].key_hex, + strlen(tests[i].key_hex), NULL, NULL, NULL); assert(strlen(tests[i].nonce_hex) == 2 * crypto_aead_aegis256_NPUBBYTES); - sodium_hex2bin(nonce, crypto_aead_aegis256_NPUBBYTES, - tests[i].nonce_hex, strlen(tests[i].nonce_hex), - NULL, NULL, NULL); + sodium_hex2bin(nonce, crypto_aead_aegis256_NPUBBYTES, tests[i].nonce_hex, + strlen(tests[i].nonce_hex), NULL, NULL, NULL); message_len = strlen(tests[i].message_hex) / 2; - message = (unsigned char *)sodium_malloc(message_len); - sodium_hex2bin(message, message_len, - tests[i].message_hex, strlen(tests[i].message_hex), + message = (unsigned char *) sodium_malloc(message_len); + sodium_hex2bin(message, message_len, tests[i].message_hex, strlen(tests[i].message_hex), NULL, NULL, NULL); ad_len = strlen(tests[i].ad_hex) / 2; - ad = (unsigned char *)sodium_malloc(ad_len); - sodium_hex2bin(ad, ad_len, - tests[i].ad_hex, strlen(tests[i].ad_hex), - NULL, NULL, NULL); + ad = (unsigned char *) sodium_malloc(ad_len); + sodium_hex2bin(ad, ad_len, tests[i].ad_hex, strlen(tests[i].ad_hex), NULL, NULL, NULL); ciphertext_len = message_len + crypto_aead_aegis256_ABYTES; detached_ciphertext_len = message_len; - expected_ciphertext = (unsigned char *)sodium_malloc(ciphertext_len); + expected_ciphertext = (unsigned char *) sodium_malloc(ciphertext_len); assert(strlen(tests[i].ciphertext_hex) == 2 * message_len); - sodium_hex2bin(expected_ciphertext, message_len, - tests[i].ciphertext_hex, strlen(tests[i].ciphertext_hex), - NULL, NULL, NULL); + sodium_hex2bin(expected_ciphertext, message_len, tests[i].ciphertext_hex, + strlen(tests[i].ciphertext_hex), NULL, NULL, NULL); assert(strlen(tests[i].mac_hex) == 2 * crypto_aead_aegis256_ABYTES); sodium_hex2bin(expected_ciphertext + message_len, crypto_aead_aegis256_ABYTES, - tests[i].mac_hex, strlen(tests[i].mac_hex), - NULL, NULL, NULL); - ciphertext = (unsigned char *)sodium_malloc(ciphertext_len); - detached_ciphertext = (unsigned char *)sodium_malloc(detached_ciphertext_len); + tests[i].mac_hex, strlen(tests[i].mac_hex), NULL, NULL, NULL); + ciphertext = (unsigned char *) sodium_malloc(ciphertext_len); + detached_ciphertext = (unsigned char *) sodium_malloc(detached_ciphertext_len); - crypto_aead_aegis256_encrypt_detached(detached_ciphertext, mac, - &found_mac_len, - message, message_len, - ad, ad_len, NULL, nonce, key); + crypto_aead_aegis256_encrypt_detached(detached_ciphertext, mac, &found_mac_len, message, + message_len, ad, ad_len, NULL, nonce, key); assert(found_mac_len == crypto_aead_aegis256_ABYTES); - if (memcmp(detached_ciphertext, expected_ciphertext, - detached_ciphertext_len) != 0 || - memcmp(mac, expected_ciphertext + message_len, - crypto_aead_aegis256_ABYTES) != 0) { - printf("Detached encryption of test vector #%u failed\n", (unsigned int)i); - hex = (char *)sodium_malloc((size_t)ciphertext_len * 2 + 1); - sodium_bin2hex(hex, (size_t)ciphertext_len * 2 + 1, - ciphertext, ciphertext_len); + if (memcmp(detached_ciphertext, expected_ciphertext, detached_ciphertext_len) != 0 || + memcmp(mac, expected_ciphertext + message_len, crypto_aead_aegis256_ABYTES) != 0) { + printf("Detached encryption of test vector #%u failed\n", (unsigned int) i); + hex = (char *) sodium_malloc((size_t) ciphertext_len * 2 + 1); + sodium_bin2hex(hex, (size_t) ciphertext_len * 2 + 1, ciphertext, ciphertext_len); printf("Computed: [%s]\n", hex); sodium_free(hex); } - crypto_aead_aegis256_encrypt(ciphertext, &found_ciphertext_len, - message, message_len, - ad, ad_len, NULL, nonce, key); + crypto_aead_aegis256_encrypt(ciphertext, &found_ciphertext_len, message, message_len, ad, + ad_len, NULL, nonce, key); - assert((size_t)found_ciphertext_len == ciphertext_len); + assert((size_t) found_ciphertext_len == ciphertext_len); if (memcmp(ciphertext, expected_ciphertext, ciphertext_len) != 0) { - printf("Encryption of test vector #%u failed\n", (unsigned int)i); - hex = (char *)sodium_malloc((size_t)found_ciphertext_len * 2 + 1); - sodium_bin2hex(hex, (size_t)found_ciphertext_len * 2 + 1, - ciphertext, ciphertext_len); + printf("Encryption of test vector #%u failed\n", (unsigned int) i); + hex = (char *) sodium_malloc((size_t) found_ciphertext_len * 2 + 1); + sodium_bin2hex(hex, (size_t) found_ciphertext_len * 2 + 1, ciphertext, ciphertext_len); printf("Computed: [%s]\n", hex); sodium_free(hex); } - decrypted = (unsigned char *)sodium_malloc(message_len); + decrypted = (unsigned char *) sodium_malloc(message_len); found_message_len = 1; - if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, - NULL, ciphertext, - randombytes_uniform((uint32_t)ciphertext_len), - ad, ad_len, nonce, key) != -1) { + if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, NULL, ciphertext, + randombytes_uniform((uint32_t) ciphertext_len), ad, ad_len, + nonce, key) != -1) { printf("Verification of test vector #%u after truncation succeeded\n", - (unsigned int)i); + (unsigned int) i); } if (found_message_len != 0) { printf("Message length should have been set to zero after a failure\n"); } - if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, - NULL, guard_page, - randombytes_uniform(crypto_aead_aegis256_ABYTES), - ad, ad_len, nonce, key) != -1) { + if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, NULL, guard_page, + randombytes_uniform(crypto_aead_aegis256_ABYTES), ad, + ad_len, nonce, key) != -1) { printf("Verification of test vector #%u with a truncated tag failed\n", - (unsigned int)i); + (unsigned int) i); } - if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, - NULL, ciphertext, ciphertext_len, - ad, ad_len, nonce, key) != 0) { - printf("Verification of test vector #%u failed\n", (unsigned int)i); + if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, NULL, ciphertext, + ciphertext_len, ad, ad_len, nonce, key) != 0) { + printf("Verification of test vector #%u failed\n", (unsigned int) i); } - assert((size_t)found_message_len == message_len); + assert((size_t) found_message_len == message_len); if (memcmp(decrypted, message, message_len) != 0) { - printf("Incorrect decryption of test vector #%u\n", (unsigned int)i); + printf("Incorrect decryption of test vector #%u\n", (unsigned int) i); } memset(decrypted, 0xd0, message_len); - if (crypto_aead_aegis256_decrypt_detached(decrypted, - NULL, detached_ciphertext, - detached_ciphertext_len, - mac, ad, ad_len, nonce, key) != 0) { - printf("Detached verification of test vector #%u failed\n", (unsigned int)i); + if (crypto_aead_aegis256_decrypt_detached(decrypted, NULL, detached_ciphertext, + detached_ciphertext_len, mac, ad, ad_len, nonce, + key) != 0) { + printf("Detached verification of test vector #%u failed\n", (unsigned int) i); } if (memcmp(decrypted, message, message_len) != 0) { - printf("Incorrect decryption of test vector #%u\n", (unsigned int)i); + printf("Incorrect decryption of test vector #%u\n", (unsigned int) i); } sodium_free(message);