Fix when initialize with 0 dkek shares. DKEK is automatically generated and saved.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-03-04 23:10:15 +01:00
parent 010c8018ea
commit f022c3235d
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3

View File

@ -462,7 +462,7 @@ static int cmd_initialize() {
memcpy(tmp_dkek, p, IV_SIZE);
if (dkeks == 0) {
p = random_bytes_get(32);
memcpy(tmp_dkek, p, 32);
memcpy(tmp_dkek+IV_SIZE, p, 32);
encrypt(session_pin, tmp_dkek, tmp_dkek+IV_SIZE, 32);
file_t *tf = search_by_fid(EF_DKEK, NULL, SPECIFY_EF);
flash_write_data_to_file(tf, tmp_dkek, sizeof(tmp_dkek));