Switching to new style.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2023-02-15 00:10:35 +01:00
parent e7495d11f2
commit cd6e280f4f
33 changed files with 1067 additions and 642 deletions

View File

@@ -19,14 +19,14 @@
#include "sc_hsm.h"
#include "kek.h"
int cmd_change_pin()
{
int cmd_change_pin() {
if (P1(apdu) == 0x0) {
if (P2(apdu) == 0x81 || P2(apdu) == 0x88) {
file_t *file_pin = NULL;
if (P2(apdu) == 0x81) {
file_pin = file_pin1;
} else if (P2(apdu) == 0x88) {
}
else if (P2(apdu) == 0x88) {
file_pin = file_sopin;
}
if (!file_pin) {
@@ -48,10 +48,11 @@ int cmd_change_pin()
//encrypt MKEK with new pin
if (P2(apdu) == 0x81) {
hash_multi(apdu.data+pin_len, apdu.nc-pin_len, session_pin);
hash_multi(apdu.data + pin_len, apdu.nc - pin_len, session_pin);
has_session_pin = true;
} else if (P2(apdu) == 0x88) {
hash_multi(apdu.data+pin_len, apdu.nc-pin_len, session_sopin);
}
else if (P2(apdu) == 0x88) {
hash_multi(apdu.data + pin_len, apdu.nc - pin_len, session_sopin);
has_session_sopin = true;
}
r = store_mkek(mkek);
@@ -60,8 +61,8 @@ int cmd_change_pin()
return SW_EXEC_ERROR();
}
uint8_t dhash[33];
dhash[0] = apdu.nc-pin_len;
double_hash_pin(apdu.data+pin_len, apdu.nc-pin_len, dhash+1);
dhash[0] = apdu.nc - pin_len;
double_hash_pin(apdu.data + pin_len, apdu.nc - pin_len, dhash + 1);
flash_write_data_to_file(file_pin, dhash, sizeof(dhash));
low_flash_available();
return SW_OK();