Use CBC not ECB
This commit is contained in:
parent
36f24776b1
commit
468bbdc308
@ -135,7 +135,7 @@ static int tt_aes256_crypt_cbc(
|
|||||||
const uint8_t key[32],
|
const uint8_t key[32],
|
||||||
int mode,
|
int mode,
|
||||||
size_t length,
|
size_t length,
|
||||||
const unsigned char iv[16],
|
unsigned char iv[16],
|
||||||
const unsigned char* input,
|
const unsigned char* input,
|
||||||
unsigned char* output
|
unsigned char* output
|
||||||
) {
|
) {
|
||||||
@ -152,7 +152,7 @@ static int tt_aes256_crypt_cbc(
|
|||||||
} else {
|
} else {
|
||||||
mbedtls_aes_setkey_dec(&master, key, 256);
|
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);
|
mbedtls_aes_free(&master);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -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];
|
uint8_t key[32];
|
||||||
get_key(key);
|
get_key(key);
|
||||||
|
|
||||||
|
// TODO: Is this still needed after switching to regular AES functions?
|
||||||
uint8_t iv_copy[16];
|
uint8_t iv_copy[16];
|
||||||
memcpy(iv_copy, iv, sizeof(iv_copy));
|
memcpy(iv_copy, iv, sizeof(iv_copy));
|
||||||
|
|
||||||
@ -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];
|
uint8_t key[32];
|
||||||
get_key(key);
|
get_key(key);
|
||||||
|
|
||||||
|
// TODO: Is this still needed after switching to regular AES functions?
|
||||||
uint8_t iv_copy[16];
|
uint8_t iv_copy[16];
|
||||||
memcpy(iv_copy, iv, sizeof(iv_copy));
|
memcpy(iv_copy, iv, sizeof(iv_copy));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user