finish bootloader

This commit is contained in:
Conor Patrick
2018-07-14 23:03:25 -04:00
parent b05f3cc9e8
commit 4cb4be21d9
17 changed files with 1504 additions and 51 deletions

View File

@@ -9,6 +9,7 @@
#include "time.h"
#include "util.h"
#include "log.h"
#include "app.h"
typedef enum
{
@@ -497,10 +498,12 @@ void ctaphid_handle_packet(uint8_t * pkt_raw)
case BUFFERED:
switch(buffer_cmd())
{
case CTAPHID_INIT:
printf2(TAG_ERR,"CTAPHID_INIT, error this should already be handled\n");
exit(1);
break;
#ifndef DISABLE_CTAPHID_PING
case CTAPHID_PING:
printf1(TAG_HID,"CTAPHID_PING\n");
@@ -514,7 +517,8 @@ void ctaphid_handle_packet(uint8_t * pkt_raw)
t2 = millis();
printf1(TAG_TIME,"PING writeback: %d ms\n",(uint32_t)(t2-t1));
break;
#endif
#ifndef DISABLE_CTAPHID_WINK
case CTAPHID_WINK:
printf1(TAG_HID,"CTAPHID_WINK\n");
@@ -526,7 +530,8 @@ void ctaphid_handle_packet(uint8_t * pkt_raw)
ctaphid_write(&wb,NULL,0);
break;
#endif
#ifndef DISABLE_CTAPHID_CBOR
case CTAPHID_CBOR:
printf1(TAG_HID,"CTAPHID_CBOR\n");
if (buffer_len() == 0)
@@ -552,7 +557,7 @@ void ctaphid_handle_packet(uint8_t * pkt_raw)
t2 = millis();
printf1(TAG_TIME,"CBOR writeback: %d ms\n",(uint32_t)(t2-t1));
break;
#endif
case CTAPHID_MSG:
printf1(TAG_HID,"CTAPHID_MSG\n");
if (buffer_len() == 0)

View File

@@ -31,8 +31,10 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
rcode = U2F_SW_CLASS_NOT_SUPPORTED;
goto end;
}
#ifdef BRIDGE_TO_WALLET
#if defined(BRIDGE_TO_WALLET)
struct u2f_authenticate_request * auth = (struct u2f_authenticate_request *) req->payload;
if (req->ins == U2F_AUTHENTICATE)
{
if (req->p1 == U2F_AUTHENTICATE_CHECK)
@@ -77,6 +79,7 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
{
rcode = U2F_SW_INS_NOT_SUPPORTED;
}
#else
switch(req->ins)
{

View File

@@ -200,12 +200,6 @@ int16_t bridge_u2f_to_wallet(uint8_t * _chal, uint8_t * _appid, uint8_t klen, ui
memset(lens,0,sizeof(lens));
for (i = 0; i < sizeof(sig); i++)
{
sig[i] = i;
}
wallet_request * req = (wallet_request *) msg_buf;
uint8_t * payload = req->payload;
@@ -219,12 +213,15 @@ int16_t bridge_u2f_to_wallet(uint8_t * _chal, uint8_t * _appid, uint8_t klen, ui
}
else
{
count = 0;
count = 10;
}
u2f_response_writeback(&up,1);
u2f_response_writeback((uint8_t *)&count,4);
u2f_response_writeback((uint8_t *)&ret,1);
#ifndef IS_BOOTLOADER
int offset = 0;
for (i = 0; i < MIN(5,req->numArgs); i++)
{
@@ -454,6 +451,9 @@ int16_t bridge_u2f_to_wallet(uint8_t * _chal, uint8_t * _appid, uint8_t klen, ui
ret = CTAP1_ERR_INVALID_COMMAND;
break;
}
#else
ret = bootloader_bridge(klen, keyh);
#endif
cleanup:
if (ret != 0)