diff --git a/client/cmdhffido.c b/client/cmdhffido.c index 1d082f868..97e48b3ec 100644 --- a/client/cmdhffido.c +++ b/client/cmdhffido.c @@ -721,8 +721,15 @@ int MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool v PrintAndLog("Credential id[%d]: %s", cridlen, sprint_hex(&ubuf[55], cridlen)); //Credentional public key (COSE_KEY) + uint8_t coseKey[65] = {0}; uint16_t cplen = n - 55 - cridlen; PrintAndLog("Credentional public key (COSE_KEY)[%d]: %s", cplen, sprint_hex(&ubuf[55 + cridlen], cplen)); + if (verbose) { + TinyCborPrintFIDOPackage(fido2COSEKey, true, &ubuf[55 + cridlen], cplen); + } + res = COSEGetECDSAKey(&ubuf[55 + cridlen], cplen, verbose, coseKey); + if (res) + PrintAndLog("ERROR: Can't get COSE_KEY."); free(ubuf); diff --git a/client/fido/cose.c b/client/fido/cose.c index 17f1e71b3..90bb66308 100644 --- a/client/fido/cose.c +++ b/client/fido/cose.c @@ -126,5 +126,10 @@ const char *GetCOSEAlgDescription(int id) { return COSEEmptyStr; } +int COSEGetECDSAKey(uint8_t *data, size_t datalen, bool verbose, uint8_t *public_key) { + + + return 0; +} diff --git a/client/fido/cose.h b/client/fido/cose.h index e8feb6d3f..1b685e4a8 100644 --- a/client/fido/cose.h +++ b/client/fido/cose.h @@ -20,4 +20,6 @@ extern const char *GetCOSEAlgName(int id); extern const char *GetCOSEAlgDescription(int id); +extern int COSEGetECDSAKey(uint8_t *data, size_t datalen, bool verbose, uint8_t *public_key); + #endif /* __COSE_H__ */ diff --git a/client/fido/fidocore.c b/client/fido/fidocore.c index 2df34b5ef..c65959eff 100644 --- a/client/fido/fidocore.c +++ b/client/fido/fidocore.c @@ -82,7 +82,7 @@ fido2Error_t fido2Errors[] = { typedef struct { fido2Commands Command; fido2PacketType PckType; - uint8_t MemberNumber; + int MemberNumber; char *Description; } fido2Desc_t; @@ -139,6 +139,13 @@ fido2Desc_t fido2CmdGetInfoRespDesc[] = { {fido2CmdClientPIN, ptQuery, 0x06, "pinHashEnc"}, {fido2CmdClientPIN, ptQuery, 0x07, "getKeyAgreement"}, {fido2CmdClientPIN, ptQuery, 0x08, "getRetries"}, + + {fido2COSEKey, ptResponse, 0x01, "kty"}, + {fido2COSEKey, ptResponse, 0x03, "alg"}, + {fido2COSEKey, ptResponse, -1, "crv"}, + {fido2COSEKey, ptResponse, -2, "x - coordinate"}, + {fido2COSEKey, ptResponse, -3, "y - coordinate"}, + {fido2COSEKey, ptResponse, -4, "d - private key"}, }; char *fido2GetCmdErrorDescription(uint8_t errorCode) { @@ -149,7 +156,7 @@ char *fido2GetCmdErrorDescription(uint8_t errorCode) { return fido2Errors[0].Description; } -char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, uint8_t memberNum) { +char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, int memberNum) { for (int i = 0; i < sizeof(fido2CmdGetInfoRespDesc) / sizeof(fido2Desc_t); i++) if (fido2CmdGetInfoRespDesc[i].Command == cmdCode && fido2CmdGetInfoRespDesc[i].PckType == (isResponse ? ptResponse : ptQuery) && diff --git a/client/fido/fidocore.h b/client/fido/fidocore.h index 97c3f0f06..5d6dc4be1 100644 --- a/client/fido/fidocore.h +++ b/client/fido/fidocore.h @@ -25,6 +25,9 @@ typedef enum { fido2CmdClientPIN = 0x06, fido2CmdReset = 0x07, fido2CmdGetNextAssertion = 0x08, + + // another data + fido2COSEKey = 0xF0 } fido2Commands; typedef enum { @@ -42,7 +45,7 @@ extern int FIDO2GetAssertion(uint8_t *params, uint8_t paramslen, uint8_t *Result extern int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *publicKey, size_t publicKeyMaxLen); -extern char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, uint8_t memberNum); +extern char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, int memberNum); extern char *fido2GetCmdErrorDescription(uint8_t errorCode); extern int FIDO2CreateMakeCredentionalReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);