diff --git a/fido2/Makefile b/fido2/Makefile new file mode 100644 index 0000000..076473c --- /dev/null +++ b/fido2/Makefile @@ -0,0 +1,44 @@ +include version.mk + +ifndef APP_CONFIG +APP_CONFIG=example_app.h +endif + +INC = -I./ -I./extensions +INC += -I../tinycbor/src +INC += -I../crypto/sha256 -I../crypto/micro-ecc -I../crypto/tiny-AES-c +INC += -I../crypto/cifra/src -I../crypto/cifra/src/ext + +CFLAGS += -DAPP_CONFIG=\"$(APP_CONFIG)\" +CFLAGS += $(INC) +CFLAGS += $(SOLO_VERSION_FLAGS) + +SRC = apdu.c util.c u2f.c test_power.c +SRC += stubs.c log.c ctaphid.c ctap.c +SRC += ctap_parse.c crypto.c main.c +SRC += device.c +SRC += version.c +SRC += data_migration.c +SRC += extensions/extensions.c extensions/solo.c +SRC += extensions/wallet.c + +# Crypto libs +SRC += ../crypto/sha256/sha256.c ../crypto/micro-ecc/uECC.c ../crypto/tiny-AES-c/aes.c +SRC += ../crypto/cifra/src/sha512.c ../crypto/cifra/src/blockwise.c + +OBJ = $(SRC:.c=.o) + +all: libsolo.a + +libsolo.a: $(OBJ) + $(AR) cqs $@ $^ + +%.o: %.c + $(CC) $^ $(CFLAGS) -c -o $@ + +../crypto/micro-ecc/uECC.o: ../crypto/micro-ecc/uECC.c + $(CC) $^ $(ECC_CFLAGS) -c -o $@ + +clean: + rm $(OBJ) libsolo.a + diff --git a/fido2/example_app.h b/fido2/example_app.h new file mode 100644 index 0000000..b5e8bd2 --- /dev/null +++ b/fido2/example_app.h @@ -0,0 +1,43 @@ +// Copyright 2019 SoloKeys Developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +#ifndef SRC_APP_H_ +#define SRC_APP_H_ +#include + +#define USING_DEV_BOARD + +#define USING_PC + +#define DEBUG_LEVEL 1 + +#define ENABLE_U2F +#define ENABLE_U2F_EXTENSIONS +//#define BRIDGE_TO_WALLET + +void printing_init(); + +extern bool use_udp; + +// 0xRRGGBB +#define LED_INIT_VALUE 0x000800 +#define LED_WINK_VALUE 0x000008 +#define LED_MAX_SCALER 30 +#define LED_MIN_SCALER 1 +// # of ms between each change in LED +#define HEARTBEAT_PERIOD 100 +// Each LED channel will be multiplied by a integer between LED_MAX_SCALER +// and LED_MIN_SCALER to cause the slow pulse. E.g. +// #define LED_INIT_VALUE 0x301000 +// #define LED_MAX_SCALER 30 +// #define LED_MIN_SCALER 1 +// #define HEARTBEAT_PERIOD 8 +// Will pulse from 0x301000 to 0x903000 to 0x301000 ... +// Which will take ~8 * (30)*2 ms + + +#endif /* SRC_APP_H_ */ diff --git a/fido2/main.c b/fido2/main.c index a22d48c..34ad664 100644 --- a/fido2/main.c +++ b/fido2/main.c @@ -29,20 +29,21 @@ int main(int argc, char *argv[]) set_logging_mask( /*0*/ - //TAG_GEN| + // TAG_GEN| // TAG_MC | // TAG_GA | TAG_WALLET | TAG_STOR | //TAG_NFC_APDU | TAG_NFC | - //TAG_CP | + // TAG_CP | // TAG_CTAP| - //TAG_HID| + // TAG_HID| TAG_U2F| - //TAG_PARSE | + // TAG_PARSE | //TAG_TIME| // TAG_DUMP| + // TAG_DUMP2| TAG_GREEN| TAG_RED| TAG_EXT| diff --git a/fido2/u2f.c b/fido2/u2f.c index 11c24f9..4a3b1d1 100644 --- a/fido2/u2f.c +++ b/fido2/u2f.c @@ -306,7 +306,7 @@ static int16_t u2f_register(struct u2f_register_request * req) uint8_t * sig = (uint8_t*)req; - const uint16_t attest_size = attestation_cert_der_get_size(); + const uint16_t attest_size = device_attestation_cert_der_get_size(); if ( ! ctap_user_presence_test(750)) { diff --git a/fido2/version.mk b/fido2/version.mk new file mode 100644 index 0000000..719ce2b --- /dev/null +++ b/fido2/version.mk @@ -0,0 +1,9 @@ + +SOLO_VERSION_FULL?=$(shell git describe) +SOLO_VERSION:=$(shell python -c 'print("$(SOLO_VERSION_FULL)".split("-")[0])') +SOLO_VERSION_MAJ:=$(shell python -c 'print("$(SOLO_VERSION)".split(".")[0])') +SOLO_VERSION_MIN:=$(shell python -c 'print("$(SOLO_VERSION)".split(".")[1])') +SOLO_VERSION_PAT:=$(shell python -c 'print("$(SOLO_VERSION)".split(".")[2])') + +SOLO_VERSION_FLAGS := -DSOLO_VERSION_MAJ=$(SOLO_VERSION_MAJ) -DSOLO_VERSION_MIN=$(SOLO_VERSION_MIN) \ + -DSOLO_VERSION_PATCH=$(SOLO_VERSION_PAT) -DSOLO_VERSION=\"$(SOLO_VERSION_FULL)\" \ No newline at end of file diff --git a/targets/stm32l432/build/application.mk b/targets/stm32l432/build/application.mk index 57c2749..3a5cdc9 100644 --- a/targets/stm32l432/build/application.mk +++ b/targets/stm32l432/build/application.mk @@ -2,14 +2,14 @@ include build/common.mk # ST related SRC = src/main.c src/init.c src/redirect.c src/flash.c src/rng.c src/led.c src/device.c -SRC += src/fifo.c src/crypto.c src/attestation.c src/nfc.c src/ams.c src/sense.c +SRC += src/fifo.c src/attestation.c src/nfc.c src/ams.c src/sense.c SRC += src/startup_stm32l432xx.s src/system_stm32l4xx.c SRC += $(DRIVER_LIBS) $(USB_LIB) # FIDO2 lib SRC += ../../fido2/apdu.c ../../fido2/util.c ../../fido2/u2f.c ../../fido2/test_power.c SRC += ../../fido2/stubs.c ../../fido2/log.c ../../fido2/ctaphid.c ../../fido2/ctap.c -SRC += ../../fido2/ctap_parse.c ../../fido2/main.c +SRC += ../../fido2/ctap_parse.c ../../fido2/crypto.c ../../fido2/main.c SRC += ../../fido2/version.c SRC += ../../fido2/data_migration.c SRC += ../../fido2/extensions/extensions.c ../../fido2/extensions/solo.c @@ -22,7 +22,9 @@ SRC += ../../crypto/cifra/src/sha512.c ../../crypto/cifra/src/blockwise.c OBJ1=$(SRC:.c=.o) OBJ=$(OBJ1:.s=.o) -INC = -Isrc/ -Isrc/cmsis/ -Ilib/ -Ilib/usbd/ -I../../fido2/ -I../../fido2/extensions +INC = -Isrc/ -Isrc/cmsis/ -Ilib/ -Ilib/usbd/ + +INC+= -I../../fido2/ -I../../fido2/extensions INC += -I../../tinycbor/src -I../../crypto/sha256 -I../../crypto/micro-ecc INC += -I../../crypto/tiny-AES-c INC += -I../../crypto/cifra/src -I../../crypto/cifra/src/ext