From b713136a003bb7d637e03f0583f8a4e9eace07ca Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 15 Jan 2021 19:16:20 +0100 Subject: [PATCH] Fix -Wcast-qual compiler warning The CBC initialization vector is passed as a const pointer, and then cast to a non-const pointer to store it in the aes state struct. This cast can easily be avoided by changing the struct field into a const pointer. --- src/aes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aes.c b/src/aes.c index 55eac5c..15a1963 100644 --- a/src/aes.c +++ b/src/aes.c @@ -98,7 +98,7 @@ typedef struct aes_state_t { #if defined(CBC) && CBC // Initial Vector used only for CBC mode - uint8_t* Iv; + const uint8_t* Iv; #endif } aes_state_t; @@ -542,7 +542,7 @@ void AES128_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, if(iv != 0) { - state.Iv = (uint8_t*)iv; + state.Iv = iv; } for(i = 0; i < length; i += KEYLEN) @@ -584,7 +584,7 @@ void AES128_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, // If iv is passed as 0, we continue to encrypt without re-setting the Iv if(iv != 0) { - state.Iv = (uint8_t*)iv; + state.Iv = iv; } for(i = 0; i < length; i += KEYLEN)