Add -Wall -Werror and catch sigint (pc only)

pull/24/head
Emanuele Cesena 2018-10-24 21:09:04 -07:00
rodzic fb93891685
commit f9757c0a08
5 zmienionych plików z 22 dodań i 7 usunięć

Wyświetl plik

@ -17,7 +17,8 @@ obj = $(src:.c=.o) uECC.o
LIBCBOR = tinycbor/lib/libtinycbor.a
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

Wyświetl plik

@ -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);

Wyświetl plik

@ -1290,7 +1290,7 @@ void ctap_init()
{
printf1(TAG_STOR,"pin code: \"%s\"\n", STATE.pin_code);
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);
printf1(TAG_STOR, "attempts_left: %d\n", STATE.remaining_tries);
}

Wyświetl plik

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

Wyświetl plik

@ -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");