Switching to new style.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user