Add -Wall -Werror and catch sigint (pc only)
This commit is contained in:
3
Makefile
3
Makefile
@@ -17,7 +17,8 @@ obj = $(src:.c=.o) uECC.o
|
|||||||
|
|
||||||
LIBCBOR = tinycbor/lib/libtinycbor.a
|
LIBCBOR = tinycbor/lib/libtinycbor.a
|
||||||
LDFLAGS = -Wl,--gc-sections $(LIBCBOR)
|
LDFLAGS = -Wl,--gc-sections $(LIBCBOR)
|
||||||
CFLAGS = -O2 -fdata-sections -ffunction-sections
|
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
|
INCLUDES = -I./tinycbor/src -I./crypto/sha256 -I./crypto/micro-ecc/ -Icrypto/tiny-AES-c/ -I./fido2/ -I./pc -I./fido2/extensions
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ int main(int argc, char * argv[])
|
|||||||
uint8_t key[32];
|
uint8_t key[32];
|
||||||
uint8_t authtag[BLOCK_SIZE];
|
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(nonce,0,16);
|
||||||
memset(key,0,16);
|
memset(key,0,16);
|
||||||
|
@@ -1290,7 +1290,7 @@ void ctap_init()
|
|||||||
{
|
{
|
||||||
printf1(TAG_STOR,"pin code: \"%s\"\n", STATE.pin_code);
|
printf1(TAG_STOR,"pin code: \"%s\"\n", STATE.pin_code);
|
||||||
crypto_sha256_init();
|
crypto_sha256_init();
|
||||||
crypto_sha256_update(STATE.pin_code, strnlen(STATE.pin_code, NEW_PIN_ENC_MAX_SIZE));
|
crypto_sha256_update(STATE.pin_code, strnlen((char *)STATE.pin_code, NEW_PIN_ENC_MAX_SIZE));
|
||||||
crypto_sha256_final(PIN_CODE_HASH);
|
crypto_sha256_final(PIN_CODE_HASH);
|
||||||
printf1(TAG_STOR, "attempts_left: %d\n", STATE.remaining_tries);
|
printf1(TAG_STOR, "attempts_left: %d\n", STATE.remaining_tries);
|
||||||
}
|
}
|
||||||
|
2
pc/app.h
2
pc/app.h
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#define DEBUG_LEVEL 1
|
#define DEBUG_LEVEL 1
|
||||||
|
|
||||||
|
#define ENABLE_U2F
|
||||||
|
|
||||||
//#define BRIDGE_TO_WALLET
|
//#define BRIDGE_TO_WALLET
|
||||||
|
|
||||||
void printing_init();
|
void printing_init();
|
||||||
|
20
pc/device.c
20
pc/device.c
@@ -8,6 +8,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "cbor.h"
|
#include "cbor.h"
|
||||||
@@ -136,13 +137,20 @@ void usbhid_close()
|
|||||||
udp_close(serverfd);
|
udp_close(serverfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void int_handler(int i)
|
||||||
|
{
|
||||||
|
usbhid_close();
|
||||||
|
printf("SIGINT... exiting.\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
void device_init()
|
void device_init()
|
||||||
{
|
{
|
||||||
|
signal(SIGINT, int_handler);
|
||||||
|
|
||||||
usbhid_init();
|
usbhid_init();
|
||||||
|
|
||||||
authenticator_initialize();
|
authenticator_initialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -181,7 +189,6 @@ int ctap_user_verification(uint8_t arg)
|
|||||||
uint32_t ctap_atomic_count(int sel)
|
uint32_t ctap_atomic_count(int sel)
|
||||||
{
|
{
|
||||||
static uint32_t counter1 = 25;
|
static uint32_t counter1 = 25;
|
||||||
static uint32_t counter2 = 25;
|
|
||||||
/*return 713;*/
|
/*return 713;*/
|
||||||
if (sel == 0)
|
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 ctap_generate_rng(uint8_t * dst, size_t num)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
FILE * urand = fopen("/dev/urandom","r");
|
FILE * urand = fopen("/dev/urandom","r");
|
||||||
if (urand == NULL)
|
if (urand == NULL)
|
||||||
{
|
{
|
||||||
perror("fopen");
|
perror("fopen");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fread(dst, 1, num, urand);
|
ret = fread(dst, 1, num, urand);
|
||||||
fclose(urand);
|
fclose(urand);
|
||||||
|
|
||||||
|
if (ret != num)
|
||||||
|
{
|
||||||
|
perror("fwrite");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
/*memset(dst,0xaa,num);*/
|
/*memset(dst,0xaa,num);*/
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -305,7 +318,6 @@ int authenticator_is_backup_initialized()
|
|||||||
AuthenticatorState * state = (AuthenticatorState*) header;
|
AuthenticatorState * state = (AuthenticatorState*) header;
|
||||||
FILE * f;
|
FILE * f;
|
||||||
int ret;
|
int ret;
|
||||||
uint8_t * mem;
|
|
||||||
|
|
||||||
printf("state file exists\n");
|
printf("state file exists\n");
|
||||||
f = fopen(backup_file, "rb");
|
f = fopen(backup_file, "rb");
|
||||||
|
Reference in New Issue
Block a user