Use new names and selecting aid.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2023-11-06 15:23:54 +01:00
parent a083bcdb3f
commit 7f7e94c639
3 changed files with 21 additions and 25 deletions

View File

@@ -44,7 +44,7 @@ set(INCLUDES ${INCLUDES}
) )
set(USB_ITF_CCID 1) set(USB_ITF_CCID 1)
include(pico-hsm-sdk/pico_hsm_sdk_import.cmake) include(pico-keys-sdk/pico_keys_sdk_import.cmake)
target_sources(pico_openpgp PUBLIC ${SOURCES}) target_sources(pico_openpgp PUBLIC ${SOURCES})
target_include_directories(pico_openpgp PUBLIC ${INCLUDES}) target_include_directories(pico_openpgp PUBLIC ${INCLUDES})
@@ -75,5 +75,5 @@ pico_add_extra_outputs(pico_openpgp)
#target_compile_definitions(pico_openpgp PRIVATE MBEDTLS_ECDSA_DETERMINISTIC=1) #target_compile_definitions(pico_openpgp PRIVATE MBEDTLS_ECDSA_DETERMINISTIC=1)
target_link_libraries(pico_openpgp PRIVATE pico_hsm_sdk pico_stdlib tinyusb_device tinyusb_board pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc) target_link_libraries(pico_openpgp PRIVATE pico_keys_sdk pico_stdlib tinyusb_device tinyusb_board pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc)
endif() endif()

View File

@@ -362,9 +362,7 @@ int heapLeft() {
return left; return left;
} }
app_t *openpgp_select_aid(app_t *a, const uint8_t *aid, uint8_t aid_len) { int openpgp_select_aid(app_t *a) {
if (!memcmp(aid, openpgp_aid + 1, MIN(aid_len, openpgp_aid[0]))) {
a->aid = openpgp_aid;
a->process_apdu = openpgp_process_apdu; a->process_apdu = openpgp_process_apdu;
a->unload = openpgp_unload; a->unload = openpgp_unload;
init_openpgp(); init_openpgp();
@@ -378,14 +376,12 @@ app_t *openpgp_select_aid(app_t *a, const uint8_t *aid, uint8_t aid_len) {
res_APDU[res_APDU_size++] = ((heap_left >> 0) & 0xff); res_APDU[res_APDU_size++] = ((heap_left >> 0) & 0xff);
res_APDU[1] += 8; res_APDU[1] += 8;
apdu.ne = res_APDU_size; apdu.ne = res_APDU_size;
return a; return CCID_OK;
}
return NULL;
} }
void __attribute__((constructor)) openpgp_ctor() { void __attribute__((constructor)) openpgp_ctor() {
ccid_atr = (uint8_t *) atr_openpgp; ccid_atr = (uint8_t *) atr_openpgp;
register_app(openpgp_select_aid); register_app(openpgp_select_aid, openpgp_aid);
} }
int parse_do(uint16_t *fids, int mode) { int parse_do(uint16_t *fids, int mode) {
@@ -1589,7 +1585,7 @@ static int cmd_pso() {
return SW_EXEC_ERROR(); return SW_EXEC_ERROR();
} }
if (P1(apdu) == 0x80 && P2(apdu) == 0x86) { //decipher if (P1(apdu) == 0x80 && P2(apdu) == 0x86) { //decipher
r = aes_decrypt(aes_key, NULL, key_size, HSM_AES_MODE_CBC, apdu.data + 1, apdu.nc - 1); r = aes_decrypt(aes_key, NULL, key_size, PICO_KEYS_AES_MODE_CBC, apdu.data + 1, apdu.nc - 1);
memset(aes_key, 0, sizeof(aes_key)); memset(aes_key, 0, sizeof(aes_key));
if (r != CCID_OK) { if (r != CCID_OK) {
return SW_EXEC_ERROR(); return SW_EXEC_ERROR();
@@ -1598,7 +1594,7 @@ static int cmd_pso() {
res_APDU_size = apdu.nc - 1; res_APDU_size = apdu.nc - 1;
} }
else if (P1(apdu) == 0x86 && P2(apdu) == 0x80) { //encipher else if (P1(apdu) == 0x86 && P2(apdu) == 0x80) { //encipher
r = aes_encrypt(aes_key, NULL, key_size, HSM_AES_MODE_CBC, apdu.data, apdu.nc); r = aes_encrypt(aes_key, NULL, key_size, PICO_KEYS_AES_MODE_CBC, apdu.data, apdu.nc);
memset(aes_key, 0, sizeof(aes_key)); memset(aes_key, 0, sizeof(aes_key));
if (r != CCID_OK) { if (r != CCID_OK) {
return SW_EXEC_ERROR(); return SW_EXEC_ERROR();

View File

@@ -23,7 +23,7 @@
#include <pico/stdlib.h> #include <pico/stdlib.h>
#endif #endif
#include "hsm.h" #include "pico_keys.h"
#include "apdu.h" #include "apdu.h"
extern bool has_pw1; extern bool has_pw1;