fido info command completed

This commit is contained in:
merlokk 2018-11-17 18:39:21 +02:00
commit 12b1289191
3 changed files with 52 additions and 31 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -15,7 +15,7 @@
#include <stddef.h>
#include <stdint.h>
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);