Squashed commit upgrading to mbedtls-3.4.0
Squash merging branch import/mbedtls-3.4.0
8225713449d3 ("libmbedtls: fix unrecognized compiler option")
f03730842d7b ("core: ltc: configure internal MD5")
2b0d0c50127c ("core: ltc: configure internal SHA-1 and SHA-224")
0e48a6e17630 ("libmedtls: core: update to mbedTLS 3.4.0 API")
049882b143af ("libutee: update to mbedTLS 3.4.0 API")
982307bf6169 ("core: LTC mpi_desc.c: update to mbedTLS 3.4.0 API")
33218e9eff7b ("ta: pkcs11: update to mbedTLS 3.4.0 API")
6956420cc064 ("libmbedtls: fix cipher_wrap.c for NIST AES Key Wrap mode")
ad67ef0b43fd ("libmbedtls: fix cipher_wrap.c for chacha20 and chachapoly")
7300f4d97bbf ("libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pkcs1_v15_verify()")
cec89b62a86d ("libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pss_verify_ext()")
e7e048796c44 ("libmbedtls: add SM2 curve")
096beff2cd31 ("libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage")
7108668efd3f ("libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage")
0ba4eb8d0572 ("libmbedtls: mbedtls_mpi_exp_mod() initialize W")
3fd6ecf00382 ("libmbedtls: fix no CRT issue")
d5ea7e9e9aa7 ("libmbedtls: add interfaces in mbedtls for context memory operation")
2b0fb3f1fa3d ("libmedtls: mpi_miller_rabin: increase count limit")
2c3301ab99bb ("libmbedtls: add mbedtls_mpi_init_mempool()")
9a111f0da04b ("libmbedtls: make mbedtls_mpi_mont*() available")
804fe3a374f5 ("mbedtls: configure mbedtls to reach for config")
b28a41531427 ("mbedtls: remove default include/mbedtls/config.h")
dfafe507bbef ("Import mbedtls-3.4.0")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
diff --git a/lib/libmbedtls/mbedtls/library/cipher_wrap.c b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
index f05fa15..fb36314 100644
--- a/lib/libmbedtls/mbedtls/library/cipher_wrap.c
+++ b/lib/libmbedtls/mbedtls/library/cipher_wrap.c
@@ -27,7 +27,7 @@
#if defined(MBEDTLS_CIPHER_C)
-#include "mbedtls/cipher_internal.h"
+#include "cipher_wrap.h"
#include "mbedtls/error.h"
#if defined(MBEDTLS_CHACHAPOLY_C)
@@ -38,10 +38,6 @@
#include "mbedtls/aes.h"
#endif
-#if defined(MBEDTLS_ARC4_C)
-#include "mbedtls/arc4.h"
-#endif
-
#if defined(MBEDTLS_CAMELLIA_C)
#include "mbedtls/camellia.h"
#endif
@@ -54,10 +50,6 @@
#include "mbedtls/des.h"
#endif
-#if defined(MBEDTLS_BLOWFISH_C)
-#include "mbedtls/blowfish.h"
-#endif
-
#if defined(MBEDTLS_CHACHA20_C)
#include "mbedtls/chacha20.h"
#endif
@@ -78,120 +70,115 @@
#include <string.h>
#endif
-#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
-#else
-#include <stdlib.h>
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif
#if defined(MBEDTLS_GCM_C)
/* shared by all GCM ciphers */
-static void *gcm_ctx_alloc( void )
+static void *gcm_ctx_alloc(void)
{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) );
+ void *ctx = mbedtls_calloc(1, sizeof(mbedtls_gcm_context));
- if( ctx != NULL )
- mbedtls_gcm_init( (mbedtls_gcm_context *) ctx );
+ if (ctx != NULL) {
+ mbedtls_gcm_init((mbedtls_gcm_context *) ctx);
+ }
- return( ctx );
+ return ctx;
}
-static void gcm_ctx_clone( void *dst, const void *src )
+static void gcm_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_gcm_context ) );
+ memcpy(dst, src, sizeof(mbedtls_gcm_context));
}
-static void gcm_ctx_free( void *ctx )
+static void gcm_ctx_free(void *ctx)
{
- mbedtls_gcm_free( ctx );
- mbedtls_free( ctx );
+ mbedtls_gcm_free(ctx);
+ mbedtls_free(ctx);
}
#endif /* MBEDTLS_GCM_C */
#if defined(MBEDTLS_CCM_C)
/* shared by all CCM ciphers */
-static void *ccm_ctx_alloc( void )
+static void *ccm_ctx_alloc(void)
{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) );
+ void *ctx = mbedtls_calloc(1, sizeof(mbedtls_ccm_context));
- if( ctx != NULL )
- mbedtls_ccm_init( (mbedtls_ccm_context *) ctx );
+ if (ctx != NULL) {
+ mbedtls_ccm_init((mbedtls_ccm_context *) ctx);
+ }
- return( ctx );
+ return ctx;
}
-static void ccm_ctx_clone( void *dst, const void *src )
+static void ccm_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_ccm_context ) );
+ memcpy(dst, src, sizeof(mbedtls_ccm_context));
}
-static void ccm_ctx_free( void *ctx )
+static void ccm_ctx_free(void *ctx)
{
- mbedtls_ccm_free( ctx );
- mbedtls_free( ctx );
+ mbedtls_ccm_free(ctx);
+ mbedtls_free(ctx);
}
#endif /* MBEDTLS_CCM_C */
#if defined(MBEDTLS_AES_C)
-static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
+static int aes_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_aes_crypt_ecb( (mbedtls_aes_context *) ctx, operation, input, output );
+ return mbedtls_aes_crypt_ecb((mbedtls_aes_context *) ctx, operation, input, output);
}
#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
+static int aes_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length,
+ unsigned char *iv, const unsigned char *input, unsigned char *output)
{
- return mbedtls_aes_crypt_cbc( (mbedtls_aes_context *) ctx, operation, length, iv, input,
- output );
+ return mbedtls_aes_crypt_cbc((mbedtls_aes_context *) ctx, operation, length, iv, input,
+ output);
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
#if defined(MBEDTLS_CIPHER_MODE_CFB)
-static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
+static int aes_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation,
+ size_t length, size_t *iv_off, unsigned char *iv,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_aes_crypt_cfb128( (mbedtls_aes_context *) ctx, operation, length, iv_off, iv,
- input, output );
+ return mbedtls_aes_crypt_cfb128((mbedtls_aes_context *) ctx, operation, length, iv_off, iv,
+ input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CFB */
#if defined(MBEDTLS_CIPHER_MODE_OFB)
-static int aes_crypt_ofb_wrap( void *ctx, size_t length, size_t *iv_off,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
+static int aes_crypt_ofb_wrap(void *ctx, size_t length, size_t *iv_off,
+ unsigned char *iv, const unsigned char *input, unsigned char *output)
{
- return mbedtls_aes_crypt_ofb( (mbedtls_aes_context *) ctx, length, iv_off,
- iv, input, output );
+ return mbedtls_aes_crypt_ofb((mbedtls_aes_context *) ctx, length, iv_off,
+ iv, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_OFB */
#if defined(MBEDTLS_CIPHER_MODE_CTR)
-static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
+static int aes_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off,
+ unsigned char *nonce_counter, unsigned char *stream_block,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter,
- stream_block, input, output );
+ return mbedtls_aes_crypt_ctr((mbedtls_aes_context *) ctx, length, nc_off, nonce_counter,
+ stream_block, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CTR */
#if defined(MBEDTLS_CIPHER_MODE_XTS)
-static int aes_crypt_xts_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length,
- const unsigned char data_unit[16],
- const unsigned char *input,
- unsigned char *output )
+static int aes_crypt_xts_wrap(void *ctx, mbedtls_operation_t operation,
+ size_t length,
+ const unsigned char data_unit[16],
+ const unsigned char *input,
+ unsigned char *output)
{
mbedtls_aes_xts_context *xts_ctx = ctx;
int mode;
- switch( operation )
- {
+ switch (operation) {
case MBEDTLS_ENCRYPT:
mode = MBEDTLS_AES_ENCRYPT;
break;
@@ -202,44 +189,45 @@
return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
}
- return mbedtls_aes_crypt_xts( xts_ctx, mode, length,
- data_unit, input, output );
+ return mbedtls_aes_crypt_xts(xts_ctx, mode, length,
+ data_unit, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_XTS */
-static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int aes_setkey_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_bitlen );
+ return mbedtls_aes_setkey_dec((mbedtls_aes_context *) ctx, key, key_bitlen);
}
-static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int aes_setkey_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen );
+ return mbedtls_aes_setkey_enc((mbedtls_aes_context *) ctx, key, key_bitlen);
}
-static void * aes_ctx_alloc( void )
+static void *aes_ctx_alloc(void)
{
- mbedtls_aes_context *aes = mbedtls_calloc( 1, sizeof( mbedtls_aes_context ) );
+ mbedtls_aes_context *aes = mbedtls_calloc(1, sizeof(mbedtls_aes_context));
- if( aes == NULL )
- return( NULL );
+ if (aes == NULL) {
+ return NULL;
+ }
- mbedtls_aes_init( aes );
+ mbedtls_aes_init(aes);
- return( aes );
+ return aes;
}
-static void aes_ctx_clone( void *dst, const void *src )
+static void aes_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_aes_context ) );
+ memcpy(dst, src, sizeof(mbedtls_aes_context));
}
-static void aes_ctx_free( void *ctx )
+static void aes_ctx_free(void *ctx)
{
- mbedtls_aes_free( (mbedtls_aes_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_aes_free((mbedtls_aes_context *) ctx);
+ mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t aes_info = {
@@ -444,39 +432,41 @@
#endif /* MBEDTLS_CIPHER_MODE_CTR */
#if defined(MBEDTLS_CIPHER_MODE_XTS)
-static int xts_aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int xts_aes_setkey_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
mbedtls_aes_xts_context *xts_ctx = ctx;
- return( mbedtls_aes_xts_setkey_enc( xts_ctx, key, key_bitlen ) );
+ return mbedtls_aes_xts_setkey_enc(xts_ctx, key, key_bitlen);
}
-static int xts_aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int xts_aes_setkey_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
mbedtls_aes_xts_context *xts_ctx = ctx;
- return( mbedtls_aes_xts_setkey_dec( xts_ctx, key, key_bitlen ) );
+ return mbedtls_aes_xts_setkey_dec(xts_ctx, key, key_bitlen);
}
-static void *xts_aes_ctx_alloc( void )
+static void *xts_aes_ctx_alloc(void)
{
- mbedtls_aes_xts_context *xts_ctx = mbedtls_calloc( 1, sizeof( *xts_ctx ) );
+ mbedtls_aes_xts_context *xts_ctx = mbedtls_calloc(1, sizeof(*xts_ctx));
- if( xts_ctx != NULL )
- mbedtls_aes_xts_init( xts_ctx );
+ if (xts_ctx != NULL) {
+ mbedtls_aes_xts_init(xts_ctx);
+ }
- return( xts_ctx );
+ return xts_ctx;
}
-static void xts_aes_ctx_free( void *ctx )
+static void xts_aes_ctx_free(void *ctx)
{
mbedtls_aes_xts_context *xts_ctx = ctx;
- if( xts_ctx == NULL )
+ if (xts_ctx == NULL) {
return;
+ }
- mbedtls_aes_xts_free( xts_ctx );
- mbedtls_free( xts_ctx );
+ mbedtls_aes_xts_free(xts_ctx);
+ mbedtls_free(xts_ctx);
}
static const mbedtls_cipher_base_t xts_aes_info = {
@@ -530,11 +520,11 @@
#endif /* MBEDTLS_CIPHER_MODE_XTS */
#if defined(MBEDTLS_GCM_C)
-static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int gcm_aes_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
- key, key_bitlen );
+ return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
+ key, key_bitlen);
}
static const mbedtls_cipher_base_t gcm_aes_info = {
@@ -600,11 +590,11 @@
#endif /* MBEDTLS_GCM_C */
#if defined(MBEDTLS_CCM_C)
-static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int ccm_aes_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
- key, key_bitlen );
+ return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
+ key, key_bitlen);
}
static const mbedtls_cipher_base_t ccm_aes_info = {
@@ -667,83 +657,117 @@
16,
&ccm_aes_info
};
+
+static const mbedtls_cipher_info_t aes_128_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 128,
+ "AES-128-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_aes_info
+};
+
+static const mbedtls_cipher_info_t aes_192_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 192,
+ "AES-192-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_aes_info
+};
+
+static const mbedtls_cipher_info_t aes_256_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 256,
+ "AES-256-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_aes_info
+};
#endif /* MBEDTLS_CCM_C */
#endif /* MBEDTLS_AES_C */
#if defined(MBEDTLS_CAMELLIA_C)
-static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
+static int camellia_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_camellia_crypt_ecb( (mbedtls_camellia_context *) ctx, operation, input,
- output );
+ return mbedtls_camellia_crypt_ecb((mbedtls_camellia_context *) ctx, operation, input,
+ output);
}
#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
+static int camellia_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation,
+ size_t length, unsigned char *iv,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_camellia_crypt_cbc( (mbedtls_camellia_context *) ctx, operation, length, iv,
- input, output );
+ return mbedtls_camellia_crypt_cbc((mbedtls_camellia_context *) ctx, operation, length, iv,
+ input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
#if defined(MBEDTLS_CIPHER_MODE_CFB)
-static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
+static int camellia_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation,
+ size_t length, size_t *iv_off, unsigned char *iv,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_camellia_crypt_cfb128( (mbedtls_camellia_context *) ctx, operation, length,
- iv_off, iv, input, output );
+ return mbedtls_camellia_crypt_cfb128((mbedtls_camellia_context *) ctx, operation, length,
+ iv_off, iv, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CFB */
#if defined(MBEDTLS_CIPHER_MODE_CTR)
-static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
+static int camellia_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off,
+ unsigned char *nonce_counter, unsigned char *stream_block,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_camellia_crypt_ctr( (mbedtls_camellia_context *) ctx, length, nc_off,
- nonce_counter, stream_block, input, output );
+ return mbedtls_camellia_crypt_ctr((mbedtls_camellia_context *) ctx, length, nc_off,
+ nonce_counter, stream_block, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CTR */
-static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int camellia_setkey_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_camellia_setkey_dec( (mbedtls_camellia_context *) ctx, key, key_bitlen );
+ return mbedtls_camellia_setkey_dec((mbedtls_camellia_context *) ctx, key, key_bitlen);
}
-static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int camellia_setkey_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_camellia_setkey_enc( (mbedtls_camellia_context *) ctx, key, key_bitlen );
+ return mbedtls_camellia_setkey_enc((mbedtls_camellia_context *) ctx, key, key_bitlen);
}
-static void * camellia_ctx_alloc( void )
+static void *camellia_ctx_alloc(void)
{
mbedtls_camellia_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_camellia_context ) );
+ ctx = mbedtls_calloc(1, sizeof(mbedtls_camellia_context));
- if( ctx == NULL )
- return( NULL );
+ if (ctx == NULL) {
+ return NULL;
+ }
- mbedtls_camellia_init( ctx );
+ mbedtls_camellia_init(ctx);
- return( ctx );
+ return ctx;
}
-static void camellia_ctx_clone( void *dst, const void *src )
+static void camellia_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_camellia_context ) );
+ memcpy(dst, src, sizeof(mbedtls_camellia_context));
}
-static void camellia_ctx_free( void *ctx )
+static void camellia_ctx_free(void *ctx)
{
- mbedtls_camellia_free( (mbedtls_camellia_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_camellia_free((mbedtls_camellia_context *) ctx);
+ mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t camellia_info = {
@@ -913,11 +937,11 @@
#endif /* MBEDTLS_CIPHER_MODE_CTR */
#if defined(MBEDTLS_GCM_C)
-static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int gcm_camellia_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
- key, key_bitlen );
+ return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
+ key, key_bitlen);
}
static const mbedtls_cipher_base_t gcm_camellia_info = {
@@ -983,11 +1007,11 @@
#endif /* MBEDTLS_GCM_C */
#if defined(MBEDTLS_CCM_C)
-static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int ccm_camellia_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
- key, key_bitlen );
+ return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
+ key, key_bitlen);
}
static const mbedtls_cipher_base_t ccm_camellia_info = {
@@ -1050,79 +1074,113 @@
16,
&ccm_camellia_info
};
+
+static const mbedtls_cipher_info_t camellia_128_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 128,
+ "CAMELLIA-128-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_camellia_info
+};
+
+static const mbedtls_cipher_info_t camellia_192_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 192,
+ "CAMELLIA-192-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_camellia_info
+};
+
+static const mbedtls_cipher_info_t camellia_256_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 256,
+ "CAMELLIA-256-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_camellia_info
+};
#endif /* MBEDTLS_CCM_C */
#endif /* MBEDTLS_CAMELLIA_C */
#if defined(MBEDTLS_ARIA_C)
-static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
+static int aria_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
+ const unsigned char *input, unsigned char *output)
{
(void) operation;
- return mbedtls_aria_crypt_ecb( (mbedtls_aria_context *) ctx, input,
- output );
+ return mbedtls_aria_crypt_ecb((mbedtls_aria_context *) ctx, input,
+ output);
}
#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static int aria_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
+static int aria_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation,
+ size_t length, unsigned char *iv,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_aria_crypt_cbc( (mbedtls_aria_context *) ctx, operation, length, iv,
- input, output );
+ return mbedtls_aria_crypt_cbc((mbedtls_aria_context *) ctx, operation, length, iv,
+ input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
#if defined(MBEDTLS_CIPHER_MODE_CFB)
-static int aria_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
+static int aria_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation,
+ size_t length, size_t *iv_off, unsigned char *iv,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_aria_crypt_cfb128( (mbedtls_aria_context *) ctx, operation, length,
- iv_off, iv, input, output );
+ return mbedtls_aria_crypt_cfb128((mbedtls_aria_context *) ctx, operation, length,
+ iv_off, iv, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CFB */
#if defined(MBEDTLS_CIPHER_MODE_CTR)
-static int aria_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
+static int aria_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off,
+ unsigned char *nonce_counter, unsigned char *stream_block,
+ const unsigned char *input, unsigned char *output)
{
- return mbedtls_aria_crypt_ctr( (mbedtls_aria_context *) ctx, length, nc_off,
- nonce_counter, stream_block, input, output );
+ return mbedtls_aria_crypt_ctr((mbedtls_aria_context *) ctx, length, nc_off,
+ nonce_counter, stream_block, input, output);
}
#endif /* MBEDTLS_CIPHER_MODE_CTR */
-static int aria_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int aria_setkey_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_aria_setkey_dec( (mbedtls_aria_context *) ctx, key, key_bitlen );
+ return mbedtls_aria_setkey_dec((mbedtls_aria_context *) ctx, key, key_bitlen);
}
-static int aria_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int aria_setkey_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_aria_setkey_enc( (mbedtls_aria_context *) ctx, key, key_bitlen );
+ return mbedtls_aria_setkey_enc((mbedtls_aria_context *) ctx, key, key_bitlen);
}
-static void * aria_ctx_alloc( void )
+static void *aria_ctx_alloc(void)
{
mbedtls_aria_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_aria_context ) );
+ ctx = mbedtls_calloc(1, sizeof(mbedtls_aria_context));
- if( ctx == NULL )
- return( NULL );
+ if (ctx == NULL) {
+ return NULL;
+ }
- mbedtls_aria_init( ctx );
+ mbedtls_aria_init(ctx);
- return( ctx );
+ return ctx;
}
-static void aria_ctx_free( void *ctx )
+static void aria_ctx_free(void *ctx)
{
- mbedtls_aria_free( (mbedtls_aria_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_aria_free((mbedtls_aria_context *) ctx);
+ mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t aria_info = {
@@ -1291,11 +1349,11 @@
#endif /* MBEDTLS_CIPHER_MODE_CTR */
#if defined(MBEDTLS_GCM_C)
-static int gcm_aria_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int gcm_aria_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA,
- key, key_bitlen );
+ return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA,
+ key, key_bitlen);
}
static const mbedtls_cipher_base_t gcm_aria_info = {
@@ -1360,11 +1418,11 @@
#endif /* MBEDTLS_GCM_C */
#if defined(MBEDTLS_CCM_C)
-static int ccm_aria_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int ccm_aria_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA,
- key, key_bitlen );
+ return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA,
+ key, key_bitlen);
}
static const mbedtls_cipher_base_t ccm_aria_info = {
@@ -1426,137 +1484,172 @@
16,
&ccm_aria_info
};
+
+static const mbedtls_cipher_info_t aria_128_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 128,
+ "ARIA-128-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_aria_info
+};
+
+static const mbedtls_cipher_info_t aria_192_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 192,
+ "ARIA-192-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_aria_info
+};
+
+static const mbedtls_cipher_info_t aria_256_ccm_star_no_tag_info = {
+ MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG,
+ MBEDTLS_MODE_CCM_STAR_NO_TAG,
+ 256,
+ "ARIA-256-CCM*-NO-TAG",
+ 12,
+ MBEDTLS_CIPHER_VARIABLE_IV_LEN,
+ 16,
+ &ccm_aria_info
+};
#endif /* MBEDTLS_CCM_C */
#endif /* MBEDTLS_ARIA_C */
#if defined(MBEDTLS_DES_C)
-static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
+static int des_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
+ const unsigned char *input, unsigned char *output)
{
((void) operation);
- return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output );
+ return mbedtls_des_crypt_ecb((mbedtls_des_context *) ctx, input, output);
}
-static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
+static int des3_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
+ const unsigned char *input, unsigned char *output)
{
((void) operation);
- return mbedtls_des3_crypt_ecb( (mbedtls_des3_context *) ctx, input, output );
+ return mbedtls_des3_crypt_ecb((mbedtls_des3_context *) ctx, input, output);
}
#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
+static int des_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length,
+ unsigned char *iv, const unsigned char *input, unsigned char *output)
{
- return mbedtls_des_crypt_cbc( (mbedtls_des_context *) ctx, operation, length, iv, input,
- output );
+ return mbedtls_des_crypt_cbc((mbedtls_des_context *) ctx, operation, length, iv, input,
+ output);
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
+static int des3_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length,
+ unsigned char *iv, const unsigned char *input, unsigned char *output)
{
- return mbedtls_des3_crypt_cbc( (mbedtls_des3_context *) ctx, operation, length, iv, input,
- output );
+ return mbedtls_des3_crypt_cbc((mbedtls_des3_context *) ctx, operation, length, iv, input,
+ output);
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
-static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int des_setkey_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) key_bitlen);
- return mbedtls_des_setkey_dec( (mbedtls_des_context *) ctx, key );
+ return mbedtls_des_setkey_dec((mbedtls_des_context *) ctx, key);
}
-static int des_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int des_setkey_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) key_bitlen);
- return mbedtls_des_setkey_enc( (mbedtls_des_context *) ctx, key );
+ return mbedtls_des_setkey_enc((mbedtls_des_context *) ctx, key);
}
-static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int des3_set2key_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) key_bitlen);
- return mbedtls_des3_set2key_dec( (mbedtls_des3_context *) ctx, key );
+ return mbedtls_des3_set2key_dec((mbedtls_des3_context *) ctx, key);
}
-static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int des3_set2key_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) key_bitlen);
- return mbedtls_des3_set2key_enc( (mbedtls_des3_context *) ctx, key );
+ return mbedtls_des3_set2key_enc((mbedtls_des3_context *) ctx, key);
}
-static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int des3_set3key_dec_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) key_bitlen);
- return mbedtls_des3_set3key_dec( (mbedtls_des3_context *) ctx, key );
+ return mbedtls_des3_set3key_dec((mbedtls_des3_context *) ctx, key);
}
-static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int des3_set3key_enc_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) key_bitlen);
- return mbedtls_des3_set3key_enc( (mbedtls_des3_context *) ctx, key );
+ return mbedtls_des3_set3key_enc((mbedtls_des3_context *) ctx, key);
}
-static void * des_ctx_alloc( void )
+static void *des_ctx_alloc(void)
{
- mbedtls_des_context *des = mbedtls_calloc( 1, sizeof( mbedtls_des_context ) );
+ mbedtls_des_context *des = mbedtls_calloc(1, sizeof(mbedtls_des_context));
- if( des == NULL )
- return( NULL );
+ if (des == NULL) {
+ return NULL;
+ }
- mbedtls_des_init( des );
+ mbedtls_des_init(des);
- return( des );
+ return des;
}
-static void des_ctx_clone( void *dst, const void *src )
+static void des_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_des_context ) );
+ memcpy(dst, src, sizeof(mbedtls_des_context));
}
-static void des_ctx_free( void *ctx )
+static void des_ctx_free(void *ctx)
{
- mbedtls_des_free( (mbedtls_des_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_des_free((mbedtls_des_context *) ctx);
+ mbedtls_free(ctx);
}
-static void * des3_ctx_alloc( void )
+static void *des3_ctx_alloc(void)
{
mbedtls_des3_context *des3;
- des3 = mbedtls_calloc( 1, sizeof( mbedtls_des3_context ) );
+ des3 = mbedtls_calloc(1, sizeof(mbedtls_des3_context));
- if( des3 == NULL )
- return( NULL );
+ if (des3 == NULL) {
+ return NULL;
+ }
- mbedtls_des3_init( des3 );
+ mbedtls_des3_init(des3);
- return( des3 );
+ return des3;
}
-static void des3_ctx_clone( void *dst, const void *src )
+static void des3_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_des3_context ) );
+ memcpy(dst, src, sizeof(mbedtls_des3_context));
}
-static void des3_ctx_free( void *ctx )
+static void des3_ctx_free(void *ctx)
{
- mbedtls_des3_free( (mbedtls_des3_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_des3_free((mbedtls_des3_context *) ctx);
+ mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t des_info = {
@@ -1715,286 +1808,59 @@
#endif /* MBEDTLS_CIPHER_MODE_CBC */
#endif /* MBEDTLS_DES_C */
-#if defined(MBEDTLS_BLOWFISH_C)
-
-static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
-{
- return mbedtls_blowfish_crypt_ecb( (mbedtls_blowfish_context *) ctx, operation, input,
- output );
-}
-
-#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, unsigned char *iv, const unsigned char *input,
- unsigned char *output )
-{
- return mbedtls_blowfish_crypt_cbc( (mbedtls_blowfish_context *) ctx, operation, length, iv,
- input, output );
-}
-#endif /* MBEDTLS_CIPHER_MODE_CBC */
-
-#if defined(MBEDTLS_CIPHER_MODE_CFB)
-static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
-{
- return mbedtls_blowfish_crypt_cfb64( (mbedtls_blowfish_context *) ctx, operation, length,
- iv_off, iv, input, output );
-}
-#endif /* MBEDTLS_CIPHER_MODE_CFB */
-
-#if defined(MBEDTLS_CIPHER_MODE_CTR)
-static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
-{
- return mbedtls_blowfish_crypt_ctr( (mbedtls_blowfish_context *) ctx, length, nc_off,
- nonce_counter, stream_block, input, output );
-}
-#endif /* MBEDTLS_CIPHER_MODE_CTR */
-
-static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
-{
- return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_bitlen );
-}
-
-static void * blowfish_ctx_alloc( void )
-{
- mbedtls_blowfish_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_blowfish_context ) );
-
- if( ctx == NULL )
- return( NULL );
-
- mbedtls_blowfish_init( ctx );
-
- return( ctx );
-}
-
-static void blowfish_ctx_clone( void *dst, const void *src )
-{
- memcpy( dst, src, sizeof( mbedtls_blowfish_context ) );
-}
-
-static void blowfish_ctx_free( void *ctx )
-{
- mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static const mbedtls_cipher_base_t blowfish_info = {
- MBEDTLS_CIPHER_ID_BLOWFISH,
- blowfish_crypt_ecb_wrap,
-#if defined(MBEDTLS_CIPHER_MODE_CBC)
- blowfish_crypt_cbc_wrap,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_CFB)
- blowfish_crypt_cfb64_wrap,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_CTR)
- blowfish_crypt_ctr_wrap,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
-#endif
- blowfish_setkey_wrap,
- blowfish_setkey_wrap,
- blowfish_ctx_alloc,
- blowfish_ctx_clone,
- blowfish_ctx_free
-};
-
-static const mbedtls_cipher_info_t blowfish_ecb_info = {
- MBEDTLS_CIPHER_BLOWFISH_ECB,
- MBEDTLS_MODE_ECB,
- 128,
- "BLOWFISH-ECB",
- 0,
- MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
- 8,
- &blowfish_info
-};
-
-#if defined(MBEDTLS_CIPHER_MODE_CBC)
-static const mbedtls_cipher_info_t blowfish_cbc_info = {
- MBEDTLS_CIPHER_BLOWFISH_CBC,
- MBEDTLS_MODE_CBC,
- 128,
- "BLOWFISH-CBC",
- 8,
- MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
- 8,
- &blowfish_info
-};
-#endif /* MBEDTLS_CIPHER_MODE_CBC */
-
-#if defined(MBEDTLS_CIPHER_MODE_CFB)
-static const mbedtls_cipher_info_t blowfish_cfb64_info = {
- MBEDTLS_CIPHER_BLOWFISH_CFB64,
- MBEDTLS_MODE_CFB,
- 128,
- "BLOWFISH-CFB64",
- 8,
- MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
- 8,
- &blowfish_info
-};
-#endif /* MBEDTLS_CIPHER_MODE_CFB */
-
-#if defined(MBEDTLS_CIPHER_MODE_CTR)
-static const mbedtls_cipher_info_t blowfish_ctr_info = {
- MBEDTLS_CIPHER_BLOWFISH_CTR,
- MBEDTLS_MODE_CTR,
- 128,
- "BLOWFISH-CTR",
- 8,
- MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
- 8,
- &blowfish_info
-};
-#endif /* MBEDTLS_CIPHER_MODE_CTR */
-#endif /* MBEDTLS_BLOWFISH_C */
-
-#if defined(MBEDTLS_ARC4_C)
-static int arc4_crypt_stream_wrap( void *ctx, size_t length,
- const unsigned char *input,
- unsigned char *output )
-{
- return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) );
-}
-
-static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
-{
- /* we get key_bitlen in bits, arc4 expects it in bytes */
- if( key_bitlen % 8 != 0 )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
-
- mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_bitlen / 8 );
- return( 0 );
-}
-
-static void * arc4_ctx_alloc( void )
-{
- mbedtls_arc4_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_arc4_context ) );
-
- if( ctx == NULL )
- return( NULL );
-
- mbedtls_arc4_init( ctx );
-
- return( ctx );
-}
-
-static void arc4_ctx_clone( void *dst, const void *src )
-{
- memcpy( dst, src, sizeof( mbedtls_arc4_context ) );
-}
-
-static void arc4_ctx_free( void *ctx )
-{
- mbedtls_arc4_free( (mbedtls_arc4_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static const mbedtls_cipher_base_t arc4_base_info = {
- MBEDTLS_CIPHER_ID_ARC4,
- NULL,
-#if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_STREAM)
- arc4_crypt_stream_wrap,
-#endif
- arc4_setkey_wrap,
- arc4_setkey_wrap,
- arc4_ctx_alloc,
- arc4_ctx_clone,
- arc4_ctx_free
-};
-
-static const mbedtls_cipher_info_t arc4_128_info = {
- MBEDTLS_CIPHER_ARC4_128,
- MBEDTLS_MODE_STREAM,
- 128,
- "ARC4-128",
- 0,
- 0,
- 1,
- &arc4_base_info
-};
-#endif /* MBEDTLS_ARC4_C */
-
#if defined(MBEDTLS_CHACHA20_C)
-static int chacha20_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int chacha20_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- if( key_bitlen != 256U )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ if (key_bitlen != 256U) {
+ return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
+ }
- if ( 0 != mbedtls_chacha20_setkey( (mbedtls_chacha20_context*)ctx, key ) )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ if (0 != mbedtls_chacha20_setkey((mbedtls_chacha20_context *) ctx, key)) {
+ return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
+ }
- return( 0 );
+ return 0;
}
-static int chacha20_stream_wrap( void *ctx, size_t length,
- const unsigned char *input,
- unsigned char *output )
+static int chacha20_stream_wrap(void *ctx, size_t length,
+ const unsigned char *input,
+ unsigned char *output)
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
- ret = mbedtls_chacha20_update( ctx, length, input, output );
- if( ret == MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ ret = mbedtls_chacha20_update(ctx, length, input, output);
+ if (ret == MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA) {
+ return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
+ }
- return( ret );
+ return ret;
}
-static void * chacha20_ctx_alloc( void )
+static void *chacha20_ctx_alloc(void)
{
mbedtls_chacha20_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_chacha20_context ) );
+ ctx = mbedtls_calloc(1, sizeof(mbedtls_chacha20_context));
- if( ctx == NULL )
- return( NULL );
+ if (ctx == NULL) {
+ return NULL;
+ }
- mbedtls_chacha20_init( ctx );
+ mbedtls_chacha20_init(ctx);
- return( ctx );
+ return ctx;
}
-static void chacha20_ctx_clone( void *dst, const void *src )
+static void chacha20_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_chacha20_context ) );
+ memcpy(dst, src, sizeof(mbedtls_chacha20_context));
}
-static void chacha20_ctx_free( void *ctx )
+static void chacha20_ctx_free(void *ctx)
{
- mbedtls_chacha20_free( (mbedtls_chacha20_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_chacha20_free((mbedtls_chacha20_context *) ctx);
+ mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t chacha20_base_info = {
@@ -2038,41 +1904,44 @@
#if defined(MBEDTLS_CHACHAPOLY_C)
-static int chachapoly_setkey_wrap( void *ctx,
- const unsigned char *key,
- unsigned int key_bitlen )
+static int chachapoly_setkey_wrap(void *ctx,
+ const unsigned char *key,
+ unsigned int key_bitlen)
{
- if( key_bitlen != 256U )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ if (key_bitlen != 256U) {
+ return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
+ }
- if ( 0 != mbedtls_chachapoly_setkey( (mbedtls_chachapoly_context*)ctx, key ) )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+ if (0 != mbedtls_chachapoly_setkey((mbedtls_chachapoly_context *) ctx, key)) {
+ return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
+ }
- return( 0 );
+ return 0;
}
-static void * chachapoly_ctx_alloc( void )
+static void *chachapoly_ctx_alloc(void)
{
mbedtls_chachapoly_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_chachapoly_context ) );
+ ctx = mbedtls_calloc(1, sizeof(mbedtls_chachapoly_context));
- if( ctx == NULL )
- return( NULL );
+ if (ctx == NULL) {
+ return NULL;
+ }
- mbedtls_chachapoly_init( ctx );
+ mbedtls_chachapoly_init(ctx);
- return( ctx );
+ return ctx;
}
-static void chachapoly_ctx_clone( void *dst, const void *src )
+static void chachapoly_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_chachapoly_context ) );
+ memcpy(dst, src, sizeof(mbedtls_chachapoly_context));
}
-static void chachapoly_ctx_free( void *ctx )
+static void chachapoly_ctx_free(void *ctx)
{
- mbedtls_chachapoly_free( (mbedtls_chachapoly_context *) ctx );
- mbedtls_free( ctx );
+ mbedtls_chachapoly_free((mbedtls_chachapoly_context *) ctx);
+ mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t chachapoly_base_info = {
@@ -2115,37 +1984,37 @@
#endif /* MBEDTLS_CHACHAPOLY_C */
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
-static int null_crypt_stream( void *ctx, size_t length,
- const unsigned char *input,
- unsigned char *output )
+static int null_crypt_stream(void *ctx, size_t length,
+ const unsigned char *input,
+ unsigned char *output)
{
((void) ctx);
- memmove( output, input, length );
- return( 0 );
+ memmove(output, input, length);
+ return 0;
}
-static int null_setkey( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int null_setkey(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
((void) ctx);
((void) key);
((void) key_bitlen);
- return( 0 );
+ return 0;
}
-static void * null_ctx_alloc( void )
+static void *null_ctx_alloc(void)
{
- return( (void *) 1 );
+ return (void *) 1;
}
-static void null_ctx_clone( void *dst, const void *src )
+static void null_ctx_clone(void *dst, const void *src)
{
((void) dst);
((void) src);
}
-static void null_ctx_free( void *ctx )
+static void null_ctx_free(void *ctx)
{
((void) ctx);
}
@@ -2191,39 +2060,40 @@
#endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */
#if defined(MBEDTLS_NIST_KW_C)
-static void *kw_ctx_alloc( void )
+static void *kw_ctx_alloc(void)
{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_nist_kw_context ) );
+ void *ctx = mbedtls_calloc(1, sizeof(mbedtls_nist_kw_context));
- if( ctx != NULL )
- mbedtls_nist_kw_init( (mbedtls_nist_kw_context *) ctx );
+ if (ctx != NULL) {
+ mbedtls_nist_kw_init((mbedtls_nist_kw_context *) ctx);
+ }
- return( ctx );
+ return ctx;
}
-static void kw_ctx_clone( void *dst, const void *src )
+static void kw_ctx_clone(void *dst, const void *src)
{
- memcpy( dst, src, sizeof( mbedtls_nist_kw_context ) );
+ memcpy(dst, src, sizeof(mbedtls_nist_kw_context));
}
-static void kw_ctx_free( void *ctx )
+static void kw_ctx_free(void *ctx)
{
- mbedtls_nist_kw_free( ctx );
- mbedtls_free( ctx );
+ mbedtls_nist_kw_free(ctx);
+ mbedtls_free(ctx);
}
-static int kw_aes_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int kw_aes_setkey_wrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_nist_kw_setkey( (mbedtls_nist_kw_context *) ctx,
- MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 1 );
+ return mbedtls_nist_kw_setkey((mbedtls_nist_kw_context *) ctx,
+ MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 1);
}
-static int kw_aes_setkey_unwrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
+static int kw_aes_setkey_unwrap(void *ctx, const unsigned char *key,
+ unsigned int key_bitlen)
{
- return mbedtls_nist_kw_setkey( (mbedtls_nist_kw_context *) ctx,
- MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 0 );
+ return mbedtls_nist_kw_setkey((mbedtls_nist_kw_context *) ctx,
+ MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 0);
}
static const mbedtls_cipher_base_t kw_aes_info = {
@@ -2360,26 +2230,12 @@
{ MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info },
{ MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info },
{ MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info },
+ { MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, &aes_128_ccm_star_no_tag_info },
+ { MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, &aes_192_ccm_star_no_tag_info },
+ { MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, &aes_256_ccm_star_no_tag_info },
#endif
#endif /* MBEDTLS_AES_C */
-#if defined(MBEDTLS_ARC4_C)
- { MBEDTLS_CIPHER_ARC4_128, &arc4_128_info },
-#endif
-
-#if defined(MBEDTLS_BLOWFISH_C)
- { MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info },
-#if defined(MBEDTLS_CIPHER_MODE_CBC)
- { MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info },
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_CFB)
- { MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info },
-#endif
-#if defined(MBEDTLS_CIPHER_MODE_CTR)
- { MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info },
-#endif
-#endif /* MBEDTLS_BLOWFISH_C */
-
#if defined(MBEDTLS_CAMELLIA_C)
{ MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info },
{ MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info },
@@ -2408,6 +2264,9 @@
{ MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info },
{ MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info },
{ MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info },
+ { MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, &camellia_128_ccm_star_no_tag_info },
+ { MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, &camellia_192_ccm_star_no_tag_info },
+ { MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, &camellia_256_ccm_star_no_tag_info },
#endif
#endif /* MBEDTLS_CAMELLIA_C */
@@ -2439,6 +2298,9 @@
{ MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info },
{ MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info },
{ MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info },
+ { MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, &aria_128_ccm_star_no_tag_info },
+ { MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, &aria_192_ccm_star_no_tag_info },
+ { MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, &aria_256_ccm_star_no_tag_info },
#endif
#endif /* MBEDTLS_ARIA_C */
@@ -2477,8 +2339,8 @@
{ MBEDTLS_CIPHER_NONE, NULL }
};
-#define NUM_CIPHERS ( sizeof(mbedtls_cipher_definitions) / \
- sizeof(mbedtls_cipher_definitions[0]) )
+#define NUM_CIPHERS (sizeof(mbedtls_cipher_definitions) / \
+ sizeof(mbedtls_cipher_definitions[0]))
int mbedtls_cipher_supported[NUM_CIPHERS];
#endif /* MBEDTLS_CIPHER_C */