Skip to content

Commit

Permalink
Merge pull request #24 from LedgerHQ/xch/nanos-ux-updates
Browse files Browse the repository at this point in the history
src/tests: Update flows with new product design
  • Loading branch information
xchapron-ledger authored Oct 2, 2023
2 parents 0832189 + 331666c commit c305dfa
Show file tree
Hide file tree
Showing 963 changed files with 453 additions and 791 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PATH_APP_LOAD_PARAMS = "5722689'" # int("WRA".encode("ascii").hex(), 16)
PATH_APP_LOAD_PARAMS += "5262163'" # int("PKS".encode("ascii").hex(), 16)

APPVERSION_M=1
APPVERSION_N=2
APPVERSION_N=3
APPVERSION_P=0
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)

Expand Down
6 changes: 2 additions & 4 deletions include/ctap2.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ typedef struct ctap2_register_data_s {
typedef union ctap2_assert_multiple_flow_data_s {
struct {
cbipItem_t credentialItem;
uint32_t credentialsNumber;
uint32_t currentCredential;
} allowList;
struct {
Expand Down Expand Up @@ -180,7 +179,6 @@ typedef enum ctap2_ux_state_e {
} ctap2_ux_state_t;

bool ctap2_check_rpid_filter(const char *rpId, uint32_t rpIdLen);
void ctap2_ux_get_rpid(const char *rpId, uint32_t rpIdLen, uint8_t *rpIdHash);
void send_cbor_error(u2f_service_t *service, uint8_t error);
void send_cbor_response(u2f_service_t *service, uint32_t length);
void ctap2_send_keepalive_processing(void);
Expand All @@ -203,8 +201,8 @@ void ctap2_make_credential_confirm(void);
void ctap2_make_credential_user_cancel(void);

void ctap2_get_assertion_ux(ctap2_ux_state_t state);
void ctap2_get_assertion_next_credential_ux_helper(void);
void ctap2_get_assertion_confirm(void);
void ctap2_get_assertion_credential_idx(uint16_t idx);
void ctap2_get_assertion_confirm(uint16_t idx);
void ctap2_get_assertion_user_cancel(void);

void ctap2_reset_ux(void);
Expand Down
1 change: 1 addition & 0 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

extern char verifyHash[65];
extern char verifyName[20];
extern char rpID[65];

extern u2f_service_t G_io_u2f;

Expand Down
2 changes: 2 additions & 0 deletions src/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
void app_ticker_event_callback(void) {
if (ctap2UxState == CTAP2_UX_STATE_CANCELLED) {
ctap2UxState = CTAP2_UX_STATE_NONE;
#ifdef HAVE_BAGL
ux_stack_pop();
ux_stack_push();
#endif
ui_idle();
} else if (ctap2UxState != CTAP2_UX_STATE_NONE) {
u2f_transport_ctap2_send_keepalive(&G_io_u2f, KEEPALIVE_REASON_TUP_NEEDED);
Expand Down
34 changes: 18 additions & 16 deletions src/ctap2_get_assertion.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,20 @@ void ctap2_get_assertion_handle(u2f_service_t *service,
return;
}

void ctap2_get_assertion_next_credential_ux_helper(void) {
void ctap2_get_assertion_credential_idx(uint16_t idx) {
ctap2_assert_data_t *ctap2AssertData = globals_get_ctap2_assert_data();
int status;

while (1) {
if (ctap2AssertData->currentCredentialIndex == idx) {
return;
}

if (!ctap2AssertData->allowListPresent) {
if (ctap2AssertData->currentCredentialIndex == ctap2AssertData->availableCredentials) {
if (ctap2AssertData->currentCredentialIndex > idx) {
ctap2AssertData->currentCredentialIndex = 0;
ctap2AssertData->multipleFlowData.rk.minAge = 0;
}
ctap2AssertData->currentCredentialIndex++;

// Find the next entry in rk
status = rk_storage_find_youngest(ctap2AssertData->rpIdHash,
Expand All @@ -460,15 +463,17 @@ void ctap2_get_assertion_next_credential_ux_helper(void) {
&ctap2AssertData->credentialLen);
if (status <= 0) {
// Should not happen, just continue a credential will be picked eventually
continue;
PRINTF("Unexpected failure rk\n");
}
break;

ctap2AssertData->currentCredentialIndex++;
continue;
} else {
cbipDecoder_t decoder;
cbip_decoder_init(&decoder, ctap2AssertData->buffer, CUSTOM_IO_APDU_BUFFER_SIZE);

if (ctap2AssertData->multipleFlowData.allowList.currentCredential ==
ctap2AssertData->multipleFlowData.allowList.credentialsNumber) {
if (ctap2AssertData->multipleFlowData.allowList.currentCredential == 0 ||
ctap2AssertData->currentCredentialIndex > idx) {
cbipItem_t mapItem;
cbip_first(&decoder, &mapItem);
status =
Expand All @@ -478,11 +483,8 @@ void ctap2_get_assertion_next_credential_ux_helper(void) {
NULL,
&ctap2AssertData->multipleFlowData.allowList.credentialItem,
cbipArray);
if (status == CBIPH_STATUS_FOUND) {
ctap2AssertData->multipleFlowData.allowList.credentialsNumber =
ctap2AssertData->multipleFlowData.allowList.credentialItem.value;
} else {
ctap2AssertData->multipleFlowData.allowList.credentialsNumber = 0;
if (status != CBIPH_STATUS_FOUND) {
PRINTF("Unexpected failure allowlist\n");
}

ctap2AssertData->multipleFlowData.allowList.currentCredential = 0;
Expand All @@ -509,9 +511,8 @@ void ctap2_get_assertion_next_credential_ux_helper(void) {
continue;
}

// Process the item to display
ctap2AssertData->currentCredentialIndex++;
break;
continue;
}
}
}
Expand Down Expand Up @@ -855,15 +856,15 @@ static int sign_and_build_getAssert_authData(uint8_t *authData,
return encoder.offset;
}

void ctap2_get_assertion_confirm() {
void ctap2_get_assertion_confirm(uint16_t idx) {
ctap2_assert_data_t *ctap2AssertData = globals_get_ctap2_assert_data();
int status;
uint32_t dataLen;
credential_data_t credData;

ctap2UxState = CTAP2_UX_STATE_NONE;

PRINTF("ctap2_get_assertion_confirm\n");
PRINTF("ctap2_get_assertion_confirm %d\n", idx);

ctap2_send_keepalive_processing();

Expand All @@ -888,6 +889,7 @@ void ctap2_get_assertion_confirm() {
}

// Retrieve needed data from credential
ctap2_get_assertion_credential_idx(idx);
status = credential_decode(&credData,
ctap2AssertData->credential,
ctap2AssertData->credentialLen,
Expand Down
Loading

0 comments on commit c305dfa

Please sign in to comment.