add temporary command to force flash locking

This commit is contained in:
Conor Patrick 2020-02-13 16:58:53 -05:00
parent b78f2cd2e7
commit e713daba26
2 changed files with 27 additions and 0 deletions

View File

@ -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); 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 ctaphid_handle_packet(uint8_t * pkt_raw)
{ {
uint8_t cmd = 0; uint8_t cmd = 0;
@ -762,6 +765,16 @@ uint8_t ctaphid_custom_command(int len, CTAP_RESPONSE * ctap_resp, CTAPHID_WRITE
return 1; return 1;
break; 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)) #if !defined(IS_BOOTLOADER) && (defined(SOLO_EXPERIMENTAL))
case CTAPHID_LOADKEY: case CTAPHID_LOADKEY:
/** /**

View File

@ -199,6 +199,20 @@ int solo_is_locked(){
return tag == ATTESTATION_CONFIGURED_TAG && (device_settings & SOLO_FLAG_LOCKED) != 0; 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 /** device_migrate
* Depending on version of device, migrates: * Depending on version of device, migrates:
* * Moves attestation certificate to data segment. * * Moves attestation certificate to data segment.