From 8f1c67d5125006d90547dcdc71e536dcb7f1631e Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Sat, 17 Nov 2018 16:19:09 +0200 Subject: [PATCH] added fidocore --- client/Makefile | 1 + client/cmdhffido.c | 7 +++---- client/fido/cbortools.c | 7 ++----- client/fido/cbortools.h | 1 - client/fido/fidocore.c | 22 ++++++++++++++++++++++ client/fido/fidocore.h | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 client/fido/fidocore.c create mode 100644 client/fido/fidocore.h diff --git a/client/Makefile b/client/Makefile index f97f395e9..1e88e5dc9 100644 --- a/client/Makefile +++ b/client/Makefile @@ -112,6 +112,7 @@ CMDSRCS = crapto1/crapto1.c \ tea.c \ fido/additional_ca.c \ fido/cbortools.c \ + fido/fidocore.c \ crypto/asn1dump.c \ crypto/libpcrypto.c\ crypto/asn1utils.c\ diff --git a/client/cmdhffido.c b/client/cmdhffido.c index b3eb47384..2a61a29c7 100644 --- a/client/cmdhffido.c +++ b/client/cmdhffido.c @@ -46,11 +46,10 @@ #include "crypto/libpcrypto.h" #include "fido/additional_ca.h" #include "fido/cbortools.h" +#include "fido/fidocore.h" static int CmdHelp(const char *Cmd); -#define FIDO2_CMD_INFO 0x04 - int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) { uint8_t data[] = {0xA0, 0x00, 0x00, 0x06, 0x47, 0x2F, 0x00, 0x01}; @@ -84,7 +83,7 @@ int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uin } int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) { - uint8_t data[] = {FIDO2_CMD_INFO}; + uint8_t data[] = {fido2CmdGetInfo}; return FIDOExchange((sAPDU){0x80, 0x10, 0x00, 0x00, sizeof(data), data}, Result, MaxResultLen, ResultLen, sw); } @@ -150,7 +149,7 @@ int CmdHFFidoInfo(const char *cmd) { PrintAndLog("FIDO2 version: (%d)", len); dump_buffer((const unsigned char *)buf, len, NULL, 0); - TinyCborPrintFIDOPackage(FIDO2_CMD_INFO, &buf[1], len - 1); + TinyCborPrintFIDOPackage(fido2CmdGetInfo, &buf[1], len - 1); return 0; } diff --git a/client/fido/cbortools.c b/client/fido/cbortools.c index edf881925..cd8f905bb 100644 --- a/client/fido/cbortools.c +++ b/client/fido/cbortools.c @@ -14,6 +14,7 @@ #include #include "cbor.h" #include "util.h" +#include "fidocore.h" static void indent(int nestingLevel) { while (nestingLevel--) @@ -121,10 +122,6 @@ static CborError dumpelm(CborValue *it, bool *got_next, int nestingLevel) { return CborNoError; } -char *getCmdCodeDescription (uint8_t cmdCode, uint8_t memberNum) { - return NULL; -} - static CborError dumprecursive(uint8_t cmdCode, CborValue *it, bool isMapType, int nestingLevel) { int elmCount = 0; while (!cbor_value_at_end(it)) { @@ -164,7 +161,7 @@ static CborError dumprecursive(uint8_t cmdCode, CborValue *it, bool isMapType, i if (cmdCode > 0 && nestingLevel == 1 && isMapType && !(elmCount % 2)) { int64_t val; cbor_value_get_int64(it, &val); - char *desc = getCmdCodeDescription(cmdCode, val); + char *desc = fido2GetCmdMemberDescription(cmdCode, val); if (desc) printf(" (%s)", desc); } diff --git a/client/fido/cbortools.h b/client/fido/cbortools.h index 93d46209f..bb442f1f8 100644 --- a/client/fido/cbortools.h +++ b/client/fido/cbortools.h @@ -10,7 +10,6 @@ //----------------------------------------------------------------------------- // - #ifndef __CBORTOOLS_H__ #define __CBORTOOLS_H__ diff --git a/client/fido/fidocore.c b/client/fido/fidocore.c new file mode 100644 index 000000000..4676aa7d3 --- /dev/null +++ b/client/fido/fidocore.c @@ -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. +//----------------------------------------------------------------------------- +// FIDO2 authenticators core data and commands +// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html +//----------------------------------------------------------------------------- +// + +#include "fidocore.h" + +char *fido2GetCmdMemberDescription(uint8_t cmdCode, uint8_t memberNum) { + + + + + return NULL; +} + diff --git a/client/fido/fidocore.h b/client/fido/fidocore.h new file mode 100644 index 000000000..10ed65ea0 --- /dev/null +++ b/client/fido/fidocore.h @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- +// FIDO2 authenticators core data and commands +// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html +//----------------------------------------------------------------------------- +// +#ifndef __FIDOCORE_H__ +#define __FIDOCORE_H__ + +#include +#include + +enum fido2Commands { + fido2CmdMakeCredential = 0x01, + fido2CmdGetAssertion = 0x02, + fido2CmdCancel = 0x03, + fido2CmdGetInfo = 0x04, + fido2CmdClientPIN = 0x06, + fido2CmdReset = 0x07, + fido2CmdGetNextAssertion = 0x08, +}; + + + +extern char *fido2GetCmdMemberDescription(uint8_t cmdCode, uint8_t memberNum); + +#endif /* __FIDOCORE_H__ */