chachapoly: force correct mode for integrated API
Allowing DECRYPT with crypt_and_tag is a risk as people might fail to check
the tag correctly (or at all). So force them to use auth_decrypt() instead.
See also https://github.com/ARMmbed/mbedtls/pull/1668
diff --git a/tests/suites/test_suite_chachapoly.function b/tests/suites/test_suite_chachapoly.function
index 7baa229..95dfd8a 100644
--- a/tests/suites/test_suite_chachapoly.function
+++ b/tests/suites/test_suite_chachapoly.function
@@ -48,8 +48,7 @@
TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str ) == 0 );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
input_len, nonce_str,
aad_str, aad_len,
input_str, output, mac ) == 0 );
@@ -149,38 +148,32 @@
TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, NULL )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( NULL,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( NULL,
0, nonce,
aad, 0,
input, output, mac )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
0, NULL,
aad, 0,
input, output, mac )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
0, nonce,
NULL, aad_len,
input, output, mac )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
input_len, nonce,
aad, 0,
NULL, output, mac )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
input_len, nonce,
aad, 0,
input, NULL, mac )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
0, nonce,
aad, 0,
input, output, NULL )
@@ -217,8 +210,7 @@
mac, input, NULL )
== MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
0, nonce,
aad, aad_len,
NULL, NULL, mac )
@@ -229,8 +221,7 @@
mac, NULL, NULL )
== 0 );
- TEST_ASSERT( mbedtls_chachapoly_crypt_and_tag( &ctx,
- MBEDTLS_CHACHAPOLY_ENCRYPT,
+ TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
input_len, nonce,
NULL, 0,
input, output, mac )