Skip to content

Commit

Permalink
add temporary command to force flash locking
Browse files Browse the repository at this point in the history
  • Loading branch information
conorpp committed Feb 13, 2020
1 parent b78f2cd commit e713dab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fido2/ctaphid.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ extern void _check_ret(CborError ret, int line, const char * filename);

uint8_t ctaphid_custom_command(int len, CTAP_RESPONSE * ctap_resp, CTAPHID_WRITE_BUFFER * wb);


extern void solo_lock_if_not_already();

uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
{
uint8_t cmd = 0;
Expand Down Expand Up @@ -762,6 +765,16 @@ uint8_t ctaphid_custom_command(int len, CTAP_RESPONSE * ctap_resp, CTAPHID_WRITE
return 1;
break;

// Remove on next release
#if !defined(IS_BOOTLOADER) && defined(SOLO)
case 0x99:
solo_lock_if_not_already();
wb->bcnt = 0;
ctaphid_write(wb, NULL, 0);
return 1;
break;
#endif

#if !defined(IS_BOOTLOADER) && (defined(SOLO_EXPERIMENTAL))
case CTAPHID_LOADKEY:
/**
Expand Down
14 changes: 14 additions & 0 deletions targets/stm32l432/src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ int solo_is_locked(){
return tag == ATTESTATION_CONFIGURED_TAG && (device_settings & SOLO_FLAG_LOCKED) != 0;
}

// Locks solo flash from debugging. Locks on next reboot.
// This should be removed in next Solo release.
void solo_lock_if_not_already() {
uint8_t buf[2048];

memmove(buf, (uint8_t*)ATTESTATION_PAGE_ADDR, 2048);

((flash_attestation_page *)buf)->device_settings |= SOLO_FLAG_LOCKED;

flash_erase_page(ATTESTATION_PAGE);

flash_write(ATTESTATION_PAGE_ADDR, buf, 2048);
}

/** device_migrate
* Depending on version of device, migrates:
* * Moves attestation certificate to data segment.
Expand Down

0 comments on commit e713dab

Please sign in to comment.