Merge pull request #24 from 0x0ece/error

Add -Wall -Werror and catch sigint (pc only)
This commit is contained in:
Conor Patrick
2018-11-04 17:15:12 -05:00
committed by GitHub
4 changed files with 20 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ obj = $(src:.c=.o) uECC.o
LIBCBOR = tinycbor/lib/libtinycbor.a
LDFLAGS = -Wl,--gc-sections $(LIBCBOR)
CFLAGS = -O2 -fdata-sections -ffunction-sections
CFLAGS += -Wall -Werror
INCLUDES = -I./tinycbor/src -I./crypto/sha256 -I./crypto/micro-ecc/ -Icrypto/tiny-AES-c/ -I./fido2/ -I./pc -I./fido2/extensions

View File

@@ -29,7 +29,7 @@ int main(int argc, char * argv[])
uint8_t key[32];
uint8_t authtag[BLOCK_SIZE];
uint8_t * authtag1 = "\x53\x0f\x8a\xfb\xc7\x45\x36\xb9\xa9\x63\xb4\xf1\xc4\xcb\x73\x8b";
// uint8_t * authtag1 = (uint8_t *)"\x53\x0f\x8a\xfb\xc7\x45\x36\xb9\xa9\x63\xb4\xf1\xc4\xcb\x73\x8b";
memset(nonce,0,16);
memset(key,0,16);

View File

@@ -14,6 +14,8 @@
#define DEBUG_LEVEL 1
#define ENABLE_U2F
//#define BRIDGE_TO_WALLET
void printing_init();

View File

@@ -8,6 +8,7 @@
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "device.h"
#include "cbor.h"
@@ -136,13 +137,20 @@ void usbhid_close()
udp_close(serverfd);
}
void int_handler(int i)
{
usbhid_close();
printf("SIGINT... exiting.\n");
exit(0);
}
void device_init()
{
signal(SIGINT, int_handler);
usbhid_init();
authenticator_initialize();
}
@@ -181,7 +189,6 @@ int ctap_user_verification(uint8_t arg)
uint32_t ctap_atomic_count(int sel)
{
static uint32_t counter1 = 25;
static uint32_t counter2 = 25;
/*return 713;*/
if (sel == 0)
{
@@ -197,15 +204,21 @@ uint32_t ctap_atomic_count(int sel)
int ctap_generate_rng(uint8_t * dst, size_t num)
{
int ret;
FILE * urand = fopen("/dev/urandom","r");
if (urand == NULL)
{
perror("fopen");
exit(1);
}
fread(dst, 1, num, urand);
ret = fread(dst, 1, num, urand);
fclose(urand);
if (ret != num)
{
perror("fwrite");
exit(1);
}
/*memset(dst,0xaa,num);*/
return 1;
@@ -305,7 +318,6 @@ int authenticator_is_backup_initialized()
AuthenticatorState * state = (AuthenticatorState*) header;
FILE * f;
int ret;
uint8_t * mem;
printf("state file exists\n");
f = fopen(backup_file, "rb");