From 5e6c8843155d2bd3b1526bbfa0a246365c83a544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 8 Feb 2022 11:29:59 +0100 Subject: [PATCH] Improve info() function in cipher_aead_demo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- programs/cipher/cipher_aead_demo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/programs/cipher/cipher_aead_demo.c b/programs/cipher/cipher_aead_demo.c index 069c2ee50d..c92eab09d6 100644 --- a/programs/cipher/cipher_aead_demo.c +++ b/programs/cipher/cipher_aead_demo.c @@ -167,8 +167,9 @@ exit: */ static void aead_info( const mbedtls_cipher_context_t *ctx, size_t tag_len ) { - // no convenient way to get the just cipher type (for example, AES) - const char *ciph = "???"; + mbedtls_cipher_type_t type = mbedtls_cipher_get_type( ctx ); + const mbedtls_cipher_info_t *info = mbedtls_cipher_info_from_type( type ); + const char *ciph = mbedtls_cipher_info_get_name( info ); int key_bits = mbedtls_cipher_get_key_bitlen( ctx ); mbedtls_cipher_mode_t mode = mbedtls_cipher_get_cipher_mode( ctx );