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.
This commit is contained in:
Jef Driesen 2021-01-15 19:16:20 +01:00
parent 03ddc84384
commit b713136a00

View File

@ -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)