diff --git a/Makefile b/Makefile index a9e0191..493e6e6 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/crypto/aes-gcm/aes_gcm.c b/crypto/aes-gcm/aes_gcm.c index 74786dc..6cfcc5e 100644 --- a/crypto/aes-gcm/aes_gcm.c +++ b/crypto/aes-gcm/aes_gcm.c @@ -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); diff --git a/fido2/ctap.c b/fido2/ctap.c index 2e62a01..90e2282 100644 --- a/fido2/ctap.c +++ b/fido2/ctap.c @@ -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); } diff --git a/pc/app.h b/pc/app.h index 692e291..a45833f 100644 --- a/pc/app.h +++ b/pc/app.h @@ -14,6 +14,8 @@ #define DEBUG_LEVEL 1 +#define ENABLE_U2F + //#define BRIDGE_TO_WALLET void printing_init(); diff --git a/pc/device.c b/pc/device.c index 43ad521..b76082f 100644 --- a/pc/device.c +++ b/pc/device.c @@ -8,6 +8,7 @@ #include #include #include +#include #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");