diff --git a/client/Makefile b/client/Makefile index b478102a3..f97f395e9 100644 --- a/client/Makefile +++ b/client/Makefile @@ -30,9 +30,9 @@ JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a MBEDTLSLIBPATH = ../common/mbedtls MBEDTLSLIB = $(MBEDTLSLIBPATH)/libmbedtls.a CBORLIBPATH = ./tinycbor -CBORLIB = $(MBEDTLSLIBPATH)/tinycbor.a -LIBS = -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -INCLUDES_CLIENT = -I. -I../include -I../common -I../common/polarssl -I../zlib -I../uart -I/opt/local/include -I../liblua $(LIBS) +CBORLIB = $(CBORLIBPATH)/tinycbor.a +LIBS = -I../zlib -I../uart -I../liblua -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) +INCLUDES_CLIENT = -I. -I../include -I../common -I/opt/local/include $(LIBS) LDFLAGS = $(ENV_LDFLAGS) CFLAGS = $(ENV_CFLAGS) -std=c99 -D_ISOC99_SOURCE -DPRESETS $(INCLUDES_CLIENT) -Wall -g -O3 CXXFLAGS = -I../include -Wall -O3 @@ -111,6 +111,7 @@ CMDSRCS = crapto1/crapto1.c \ mfkey.c \ tea.c \ fido/additional_ca.c \ + fido/cbortools.c \ crypto/asn1dump.c \ crypto/libpcrypto.c\ crypto/asn1utils.c\ @@ -269,7 +270,7 @@ all: lua_build jansson_build mbedtls_build cbor_build $(BINS) all-static: LDLIBS:=-static $(LDLIBS) all-static: proxmark3 flasher fpga_compress -proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(QTLDLIBS) +proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS) proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua lualibs/mf_default_keys.lua $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@ diff --git a/client/cmdhffido.c b/client/cmdhffido.c index e2d6c0917..faff8e82c 100644 --- a/client/cmdhffido.c +++ b/client/cmdhffido.c @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include #include "comms.h" #include "cmdmain.h" #include "util.h" @@ -42,9 +45,7 @@ #include "crypto/asn1utils.h" #include "crypto/libpcrypto.h" #include "fido/additional_ca.h" -#include "mbedtls/x509_crt.h" -#include "mbedtls/x509.h" -#include "mbedtls/pk.h" +#include "fido/cbortools.h" static int CmdHelp(const char *Cmd); @@ -142,6 +143,7 @@ int CmdHFFidoInfo(const char *cmd) { PrintAndLog("FIDO2 version: (%d)", len); dump_buffer((const unsigned char *)buf, len, NULL, 0); + TinyCborPrintFIDOPackage(buf, len); return 0; } diff --git a/client/fido/cbortools.c b/client/fido/cbortools.c new file mode 100644 index 000000000..4e701b0cd --- /dev/null +++ b/client/fido/cbortools.c @@ -0,0 +1,41 @@ +//----------------------------------------------------------------------------- +// Copyright (C) 2018 Merlok +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// Tools for work with CBOR format http://cbor.io/spec.html +// via Intel tinycbor (https://github.com/intel/tinycbor) library +//----------------------------------------------------------------------------- +// + +#include "cbortools.h" +#include "cbor.h" + + +int TinyCborParser(uint8_t *data, size_t length, CborValue *cb) { + CborParser parser; + CborError err = cbor_parser_init(data, length, 0, &parser, cb); + // if (!err) + // err = dumprecursive(cb, 0); + + if (err) { + fprintf(stderr, "CBOR parsing failure at offset %d: %s\n", + cb->ptr - data, cbor_error_string(err)); + return 1; + } + + return 0; +} + +int TinyCborPrintFIDOPackage(uint8_t *data, size_t length) { + CborValue cb; + int res; + res = TinyCborParser(data, length, &cb); + if (res) + return res; + + return 0; +} + diff --git a/client/fido/cbortools.h b/client/fido/cbortools.h new file mode 100644 index 000000000..f49751b56 --- /dev/null +++ b/client/fido/cbortools.h @@ -0,0 +1,22 @@ +//----------------------------------------------------------------------------- +// Copyright (C) 2018 Merlok +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +//----------------------------------------------------------------------------- +// Tools for work with CBOR format http://cbor.io/spec.html +// via Intel tinycbor (https://github.com/intel/tinycbor) library +//----------------------------------------------------------------------------- +// + + +#ifndef __CBORTOOLS_H__ +#define __CBORTOOLS_H__ + +#include +#include + +extern int TinyCborPrintFIDOPackage(uint8_t *data, size_t length); + +#endif /* __CBORTOOLS_H__ */