Skip to content

Commit

Permalink
Use CBC not ECB
Browse files Browse the repository at this point in the history
  • Loading branch information
KenVanHoeylandt committed Jan 17, 2024
1 parent 36f2477 commit 468bbdc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/tactility-core/src/secure.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int tt_aes256_crypt_cbc(
const uint8_t key[32],
int mode,
size_t length,
const unsigned char iv[16],
unsigned char iv[16],
const unsigned char* input,
unsigned char* output
) {
Expand All @@ -152,7 +152,7 @@ static int tt_aes256_crypt_cbc(
} else {
mbedtls_aes_setkey_dec(&master, key, 256);
}
int result = mbedtls_aes_crypt_ecb(&master, mode, input, output);
int result = mbedtls_aes_crypt_cbc(&master, mode, length, iv, input, output);
mbedtls_aes_free(&master);
return result;
}
Expand All @@ -162,6 +162,7 @@ int tt_secure_encrypt(const uint8_t iv[16], uint8_t* in_data, uint8_t* out_data,
uint8_t key[32];
get_key(key);

// TODO: Is this still needed after switching to regular AES functions?
uint8_t iv_copy[16];
memcpy(iv_copy, iv, sizeof(iv_copy));

Expand All @@ -173,6 +174,7 @@ int tt_secure_decrypt(const uint8_t iv[16], uint8_t* in_data, uint8_t* out_data,
uint8_t key[32];
get_key(key);

// TODO: Is this still needed after switching to regular AES functions?
uint8_t iv_copy[16];
memcpy(iv_copy, iv, sizeof(iv_copy));

Expand Down

0 comments on commit 468bbdc

Please sign in to comment.