RTC command is not available in emulation.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2023-01-12 20:04:23 +01:00
parent 9793977ffc
commit 742c3f3e3c

View File

@@ -18,7 +18,9 @@
#include "common.h" #include "common.h"
#include "mbedtls/ecdh.h" #include "mbedtls/ecdh.h"
#include "sc_hsm.h" #include "sc_hsm.h"
#ifndef ENABLE_EMULATION
#include "hardware/rtc.h" #include "hardware/rtc.h"
#endif
#include "files.h" #include "files.h"
#include "random.h" #include "random.h"
#include "kek.h" #include "kek.h"
@@ -30,6 +32,7 @@ int cmd_extras() {
if (P2(apdu) != 0x0) if (P2(apdu) != 0x0)
return SW_INCORRECT_P1P2(); return SW_INCORRECT_P1P2();
if (apdu.nc == 0) { if (apdu.nc == 0) {
#ifndef ENABLE_EMULATION
datetime_t dt; datetime_t dt;
if (!rtc_get_datetime(&dt)) if (!rtc_get_datetime(&dt))
return SW_EXEC_ERROR(); return SW_EXEC_ERROR();
@@ -41,10 +44,12 @@ int cmd_extras() {
res_APDU[res_APDU_size++] = dt.hour; res_APDU[res_APDU_size++] = dt.hour;
res_APDU[res_APDU_size++] = dt.min; res_APDU[res_APDU_size++] = dt.min;
res_APDU[res_APDU_size++] = dt.sec; res_APDU[res_APDU_size++] = dt.sec;
#endif
} }
else { else {
if (apdu.nc != 8) if (apdu.nc != 8)
return SW_WRONG_LENGTH(); return SW_WRONG_LENGTH();
#ifndef ENABLE_EMULATION
datetime_t dt; datetime_t dt;
dt.year = (apdu.data[0] << 8) | (apdu.data[1]); dt.year = (apdu.data[0] << 8) | (apdu.data[1]);
dt.month = apdu.data[2]; dt.month = apdu.data[2];
@@ -55,6 +60,7 @@ int cmd_extras() {
dt.sec = apdu.data[7]; dt.sec = apdu.data[7];
if (!rtc_set_datetime(&dt)) if (!rtc_set_datetime(&dt))
return SW_WRONG_DATA(); return SW_WRONG_DATA();
#endif
} }
} }
else if (P1(apdu) == 0x6) { //dynamic options else if (P1(apdu) == 0x6) { //dynamic options