From 12b12891914fcd4828ce94d2a07a7546aee344b6 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Sat, 17 Nov 2018 18:39:21 +0200 Subject: [PATCH] fido info command completed --- client/cmdhffido.c | 16 +++++++++--- client/fido/fidocore.c | 57 +++++++++++++++++++++++++----------------- client/fido/fidocore.h | 10 +++++--- 3 files changed, 52 insertions(+), 31 deletions(-) diff --git a/client/cmdhffido.c b/client/cmdhffido.c index e344e4445..954d96a8a 100644 --- a/client/cmdhffido.c +++ b/client/cmdhffido.c @@ -147,10 +147,18 @@ int CmdHFFidoInfo(const char *cmd) { return 0; } - PrintAndLog("FIDO2 version: (%d)", len); - dump_buffer((const unsigned char *)buf, len, NULL, 0); - TinyCborPrintFIDOPackage(fido2CmdGetInfo, &buf[1], len - 1); - + if (len > 1) { +// if (false) { +// PrintAndLog("FIDO2 version: (len=%d)", len); +// dump_buffer((const unsigned char *)buf, len, NULL, 0); +// } + + PrintAndLog("FIDO2 version CBOR decoded:"); + TinyCborPrintFIDOPackage(fido2CmdGetInfo, &buf[1], len - 1); + } else { + PrintAndLog("FIDO2 version length error"); + } + return 0; } diff --git a/client/fido/fidocore.c b/client/fido/fidocore.c index 1263baef9..1b41d2722 100644 --- a/client/fido/fidocore.c +++ b/client/fido/fidocore.c @@ -11,6 +11,7 @@ // #include "fidocore.h" + typedef struct { uint8_t ErrorCode; char *ShortDescription; @@ -69,30 +70,38 @@ fido2Error_t fido2Errors[] = { }; typedef struct { + fido2Commands Command; + fido2PacketType PckType; uint8_t MemberNumber; char *Description; } fido2Desc_t; -typedef fido2Desc_t fido2ArrayDesc_t[]; -/* -typedef struct { - fido2Desc_t Query[]; - fido2Desc_t Resp[]; -} fido2CmdDesc_t; - -fido2CmdDesc_t fido2CmdDesc[] = { // fido2CommandsCount - {fido2CmdGetInfoRespDesc, fido2CmdGetInfoRespDesc}, - {fido2CmdGetInfoRespDesc, fido2CmdGetInfoRespDesc}, -}; -*/ fido2Desc_t fido2CmdGetInfoRespDesc[] = { - {0x01, "versions"}, - {0x02, "extensions"}, - {0x03, "aaguid"}, - {0x04, "options"}, - {0x05, "maxMsgSize"}, - {0x06, "pinProtocols"}, - {0xff, ""}, + {fido2CmdMakeCredential, ptResponse, 0x01, "fmt"}, + {fido2CmdMakeCredential, ptResponse, 0x02, "authData"}, + {fido2CmdMakeCredential, ptResponse, 0x03, "attStmt"}, + + {fido2CmdGetAssertion, ptResponse, 0x01, "credential"}, + {fido2CmdGetAssertion, ptResponse, 0x02, "authData"}, + {fido2CmdGetAssertion, ptResponse, 0x03, "signature"}, + {fido2CmdGetAssertion, ptResponse, 0x04, "publicKeyCredentialUserEntity"}, + {fido2CmdGetAssertion, ptResponse, 0x05, "numberOfCredentials"}, + + {fido2CmdGetNextAssertion, ptResponse, 0x01, "credential"}, + {fido2CmdGetNextAssertion, ptResponse, 0x02, "authData"}, + {fido2CmdGetNextAssertion, ptResponse, 0x03, "signature"}, + {fido2CmdGetNextAssertion, ptResponse, 0x04, "publicKeyCredentialUserEntity"}, + + {fido2CmdGetInfo, ptResponse, 0x01, "versions"}, + {fido2CmdGetInfo, ptResponse, 0x02, "extensions"}, + {fido2CmdGetInfo, ptResponse, 0x03, "aaguid"}, + {fido2CmdGetInfo, ptResponse, 0x04, "options"}, + {fido2CmdGetInfo, ptResponse, 0x05, "maxMsgSize"}, + {fido2CmdGetInfo, ptResponse, 0x06, "pinProtocols"}, + + {fido2CmdClientPIN, ptResponse, 0x06, "keyAgreement"}, + {fido2CmdClientPIN, ptResponse, 0x06, "pinToken"}, + {fido2CmdClientPIN, ptResponse, 0x06, "retries"}, }; char *fido2GetCmdErrorDescription(uint8_t errorCode) { @@ -104,10 +113,12 @@ char *fido2GetCmdErrorDescription(uint8_t errorCode) { } char *fido2GetCmdMemberDescription(uint8_t cmdCode, uint8_t memberNum) { - - - - + for (int i = 0; i < sizeof(fido2CmdGetInfoRespDesc) / sizeof(fido2Desc_t); i++) + if (fido2CmdGetInfoRespDesc[i].Command == cmdCode && + fido2CmdGetInfoRespDesc[i].PckType == ptResponse && + fido2CmdGetInfoRespDesc[i].MemberNumber == memberNum ) + return fido2CmdGetInfoRespDesc[i].Description; + return NULL; } diff --git a/client/fido/fidocore.h b/client/fido/fidocore.h index 252adec90..1ed5556cf 100644 --- a/client/fido/fidocore.h +++ b/client/fido/fidocore.h @@ -15,7 +15,7 @@ #include #include -enum fido2Commands { +typedef enum { fido2CmdMakeCredential = 0x01, fido2CmdGetAssertion = 0x02, fido2CmdCancel = 0x03, @@ -23,10 +23,12 @@ enum fido2Commands { fido2CmdClientPIN = 0x06, fido2CmdReset = 0x07, fido2CmdGetNextAssertion = 0x08, -}; -#define fido2CommandsCount 9 - +} fido2Commands; +typedef enum { + ptQuery, + ptResponse, +} fido2PacketType; extern char *fido2GetCmdMemberDescription(uint8_t cmdCode, uint8_t memberNum); extern char *fido2GetCmdErrorDescription(uint8_t errorCode);