add wink command

This commit is contained in:
Conor Patrick 2018-12-08 20:37:30 -05:00
parent 51cf2d5ec9
commit 5dd3355bd8
6 changed files with 56 additions and 6 deletions

View File

@ -609,6 +609,8 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
ctaphid_write_buffer_init(&wb); ctaphid_write_buffer_init(&wb);
device_wink();
wb.cid = cid; wb.cid = cid;
wb.cmd = CTAPHID_WINK; wb.cmd = CTAPHID_WINK;

View File

@ -98,7 +98,8 @@ void ctap_overwrite_rk(int index,CTAP_residentKey * rk);
void boot_solo_bootloader(); void boot_solo_bootloader();
void boot_st_bootloader(); void boot_st_bootloader();
// HID wink command
void device_wink();
#endif #endif

View File

@ -22,6 +22,7 @@ void printing_init();
// 0xRRGGBB // 0xRRGGBB
#define LED_INIT_VALUE 0x000800 #define LED_INIT_VALUE 0x000800
#define LED_WINK_VALUE 0x000008
#define LED_MAX_SCALER 30 #define LED_MAX_SCALER 30
#define LED_MIN_SCALER 1 #define LED_MIN_SCALER 1
// # of ms between each change in LED // # of ms between each change in LED

View File

@ -447,4 +447,7 @@ void ctap_overwrite_rk(int index,CTAP_residentKey * rk)
printf("Warning: rk not implemented\n"); printf("Warning: rk not implemented\n");
} }
void device_wink()
{
printf("*WINK*\n");
}

View File

@ -22,8 +22,6 @@
#include "stm32l4xx_ll_iwdg.h" #include "stm32l4xx_ll_iwdg.h"
uint32_t __90_ms = 0; uint32_t __90_ms = 0;
uint32_t __device_status = 0; uint32_t __device_status = 0;
uint32_t __last_update = 0; uint32_t __last_update = 0;
@ -148,6 +146,15 @@ void main_loop_delay()
} }
static int wink_time = 0;
static uint32_t winkt1 = 0;
static uint32_t winkt2 = 0;
void device_wink()
{
wink_time = 10;
winkt1 = 0;
}
void heartbeat() void heartbeat()
{ {
static int state = 0; static int state = 0;
@ -170,11 +177,32 @@ void heartbeat()
{ {
state = !state; state = !state;
} }
if (but) led_rgb(((val * r)<<8) | ((val*b) << 16) | (val*g)); if (wink_time)
{
if (millis() - winkt1 > 120)
{
winkt1 = millis();
if (winkt2++ & 1)
{
led_rgb(LED_WINK_VALUE * (LED_MAX_SCALER - LED_MIN_SCALER)/2);
}
else
{
led_rgb(0);
}
wink_time--;
}
}
else
{
if (but)
led_rgb(((val * r)<<8) | ((val*b) << 16) | (val*g));
else else
led_rgb(((val * g)<<8) | ((val*r) << 16) | (val*b)); led_rgb(((val * g)<<8) | ((val*r) << 16) | (val*b));
} }
}
void authenticator_read_state(AuthenticatorState * a) void authenticator_read_state(AuthenticatorState * a)
{ {
uint32_t * ptr = (uint32_t *)flash_addr(STATE1_PAGE); uint32_t * ptr = (uint32_t *)flash_addr(STATE1_PAGE);
@ -520,6 +548,8 @@ void boot_solo_bootloader()
} }
void _Error_Handler(char *file, int line) void _Error_Handler(char *file, int line)
{ {
printf2(TAG_ERR,"Error: %s: %d\r\n", file, line); printf2(TAG_ERR,"Error: %s: %d\r\n", file, line);

View File

@ -131,6 +131,14 @@ class Programmer():
""" """
self.exchange(SoloBootloader.done,0,sig) self.exchange(SoloBootloader.done,0,sig)
def wink(self,):
"""
If solo is configured as solo hacker or something similar,
this command will tell the token to boot directly to the bootloader
so it can be reprogrammed
"""
self.send_data_hid(CTAPHID.WINK,b'')
def enter_solo_bootloader(self,): def enter_solo_bootloader(self,):
""" """
If solo is configured as solo hacker or something similar, If solo is configured as solo hacker or something similar,
@ -271,6 +279,7 @@ if __name__ == '__main__':
parser.add_argument("--st-dfu", action="store_true", help = 'Don\'t write anything, try to enter ST DFU. Warning, you could brick your Solo if you overwrite everything. You should reprogram the option bytes just to be safe (boot to Solo bootloader first, then run this command).') parser.add_argument("--st-dfu", action="store_true", help = 'Don\'t write anything, try to enter ST DFU. Warning, you could brick your Solo if you overwrite everything. You should reprogram the option bytes just to be safe (boot to Solo bootloader first, then run this command).')
parser.add_argument("--disable", action="store_true", help = 'Disable the Solo bootloader. Cannot be undone. No future updates can be applied.') parser.add_argument("--disable", action="store_true", help = 'Disable the Solo bootloader. Cannot be undone. No future updates can be applied.')
parser.add_argument("--rng", action="store_true", help = 'Continuously dump random numbers generated from Solo.') parser.add_argument("--rng", action="store_true", help = 'Continuously dump random numbers generated from Solo.')
parser.add_argument("--wink", action="store_true", help = 'HID Wink command.')
args = parser.parse_args() args = parser.parse_args()
print() print()
@ -297,6 +306,10 @@ if __name__ == '__main__':
sys.stdout.buffer.write(r) sys.stdout.buffer.write(r)
sys.exit(0) sys.exit(0)
if args.wink:
p.wink()
sys.exit(0)
if args.st_dfu: if args.st_dfu:
print('Sending command to boot into ST DFU...') print('Sending command to boot into ST DFU...')
p.enter_st_dfu() p.enter_st_dfu()