From f57bf8b467b8ca7ce82ffedb9846aa8b1e2f9a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 18 Jun 2018 11:14:09 +0200 Subject: [PATCH] Define specific mode for ChachaPoly The TLS layer is checking for mode, such as GCM, CCM, CBC, STREAM. ChachaPoly needs to have its own mode, even if it's used just one cipher, in order to allow consistent handling of mode in the TLS layer. --- include/mbedtls/cipher.h | 1 + library/cipher_wrap.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index e707808a2..a1f4738a9 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -186,6 +186,7 @@ typedef enum { MBEDTLS_MODE_STREAM, /**< The stream cipher mode. */ MBEDTLS_MODE_CCM, /**< The CCM cipher mode. */ MBEDTLS_MODE_XTS, /**< The XTS cipher mode. */ + MBEDTLS_MODE_CHACHAPOLY, /**< The ChaCha-Poly cipher mode. */ } mbedtls_cipher_mode_t; /** Supported cipher padding types. */ diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c index e22c172f9..893490acc 100644 --- a/library/cipher_wrap.c +++ b/library/cipher_wrap.c @@ -2040,7 +2040,7 @@ static const mbedtls_cipher_base_t chachapoly_base_info = { }; static const mbedtls_cipher_info_t chachapoly_info = { MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MODE_NONE, + MBEDTLS_MODE_CHACHAPOLY, 256, "CHACHA20-POLY1305", 12,