remove printf references, add bootloader script, merge hex files

This commit is contained in:
Conor Patrick
2018-12-01 17:10:49 -05:00
parent 93d4112bc3
commit ac7950f4c4
22 changed files with 409 additions and 74 deletions

View File

@@ -104,7 +104,7 @@ void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac)
if(klen > 64)
{
printf("Error, key size must be <= 64\n");
printf2(TAG_ERR,"Error, key size must be <= 64\n");
exit(1);
}
@@ -134,7 +134,7 @@ void crypto_sha256_hmac_final(uint8_t * key, uint32_t klen, uint8_t * hmac)
if(klen > 64)
{
printf("Error, key size must be <= 64\n");
printf2(TAG_ERR,"Error, key size must be <= 64\n");
exit(1);
}
memmove(buf, key, klen);
@@ -168,7 +168,7 @@ void crypto_ecc256_sign(uint8_t * data, int len, uint8_t * sig)
{
if ( uECC_sign(_signing_key, data, len, sig, _es256_curve) == 0)
{
printf("error, uECC failed\n");
printf2(TAG_ERR,"error, uECC failed\n");
exit(1);
}
}
@@ -205,19 +205,19 @@ void crypto_ecdsa_sign(uint8_t * data, int len, uint8_t * sig, int MBEDTLS_ECP_I
if (_key_len != 32) goto fail;
break;
default:
printf("error, invalid ECDSA alg specifier\n");
printf2(TAG_ERR,"error, invalid ECDSA alg specifier\n");
exit(1);
}
if ( uECC_sign(_signing_key, data, len, sig, curve) == 0)
{
printf("error, uECC failed\n");
printf2(TAG_ERR,"error, uECC failed\n");
exit(1);
}
return;
fail:
printf("error, invalid key length\n");
printf2(TAG_ERR,"error, invalid key length\n");
exit(1);
}
@@ -257,7 +257,7 @@ void crypto_ecc256_make_key_pair(uint8_t * pubkey, uint8_t * privkey)
{
if (uECC_make_key(pubkey, privkey, _es256_curve) != 1)
{
printf("Error, uECC_make_key failed\n");
printf2(TAG_ERR,"Error, uECC_make_key failed\n");
exit(1);
}
}
@@ -266,7 +266,7 @@ void crypto_ecc256_shared_secret(const uint8_t * pubkey, const uint8_t * privkey
{
if (uECC_shared_secret(pubkey, privkey, shared_secret, _es256_curve) != 1)
{
printf("Error, uECC_shared_secret failed\n");
printf2(TAG_ERR,"Error, uECC_shared_secret failed\n");
exit(1);
}

View File

@@ -616,7 +616,6 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
break;
#endif
#ifndef DISABLE_CTAPHID_CBOR
#error rere
case CTAPHID_CBOR:
printf1(TAG_HID,"CTAPHID_CBOR\n");

View File

@@ -44,6 +44,7 @@ void usbhid_close();
void main_loop_delay();
void heartbeat();
void bootloader_heartbeat();
void authenticator_read_state(AuthenticatorState * );
@@ -62,6 +63,9 @@ void device_manage();
// A timer should be set up to call `ctaphid_update_status`
void device_set_status(int status);
// Returns if button is currently pressed
int device_is_button_pressed();
// Test for user presence
// Return 1 for user is present, 0 user not present, -1 if cancel is requested.
extern int ctap_user_presence_test();
@@ -93,4 +97,10 @@ void ctap_overwrite_rk(int index,CTAP_residentKey * rk);
// Boot laoder application
int bootloader_bridge(uint8_t klen, uint8_t * keyh);
// Trigger software reset
void device_reboot();
// for bootloader
int is_authorized_to_boot();
#endif

View File

@@ -100,7 +100,7 @@ int16_t extend_u2f(struct u2f_request_apdu* req, uint32_t len)
}
else
{
rcode = U2F_SW_WRONG_DATA;
rcode = U2F_SW_WRONG_DATA;
}
printf1(TAG_WALLET,"Ignoring U2F request\n");
goto end;

View File

@@ -312,8 +312,6 @@ int16_t bridge_u2f_to_wallet(uint8_t * _chal, uint8_t * _appid, uint8_t klen, ui
memmove(chksum, args[0] + lens[0] - 4, 4);
lens[0] -= 4;
/*printf("chksum: "); dump_hex1(TAG_WALLET, chksum, 4);*/
// perform integrity check
/*printf1(TAG_WALLET,"shasum on [%d]: ",lens[0]); dump_hex1(TAG_WALLET, args[0], lens[0]);*/
crypto_sha256_init();

View File

@@ -76,7 +76,7 @@ int main(int argc, char * argv[])
{
if (millis() - t1 > 100)
{
/*printf("heartbeat %ld\n", beat++);*/
/*printf1(TAG_GEN,"heartbeat %ld\n", beat++);*/
heartbeat();
t1 = millis();
}

View File

@@ -31,18 +31,18 @@
void ctap_init()
{
printf("STUB: ctap_init\n");
printf1(TAG_GEN,"STUB: ctap_init\n");
}
#endif
#if defined(STUB_CTAPHID)
void ctaphid_init()
{
printf("STUB: ctaphid_init\n");
printf1(TAG_GEN,"STUB: ctaphid_init\n");
}
void ctaphid_handle_packet(uint8_t * hidmsg)
{
printf("STUB: ctaphid_handle_packet\n");
printf1(TAG_GEN,"STUB: ctaphid_handle_packet\n");
}
void ctaphid_check_timeouts()
@@ -57,7 +57,7 @@ void ctaphid_check_timeouts()
void ctap_reset_state()
{
printf("STUB: ctap_reset_state\n");
printf1(TAG_GEN,"STUB: ctap_reset_state\n");
}
void ctap_response_init(CTAP_RESPONSE * resp)
@@ -66,12 +66,12 @@ void ctap_response_init(CTAP_RESPONSE * resp)
void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
{
printf("STUB: u2f_request\n");
printf1(TAG_GEN,"STUB: u2f_request\n");
}
uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
{
printf("STUB: ctap_request\n");
printf1(TAG_GEN,"STUB: ctap_request\n");
return 0;
}
#endif

View File

@@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdio.h>
#if DEBUG_LEVEL
void dump_hex(uint8_t * buf, int size)
{
while(size--)
@@ -30,5 +31,9 @@ void dump_hex(uint8_t * buf, int size)
}
printf("\n");
}
#else
void dump_hex(uint8_t * buf, int size)
{
}
#endif