added showing cose_key in cbor text type

This commit is contained in:
merlokk 2018-11-26 18:30:14 +02:00
commit b9c4bd1e0c
5 changed files with 27 additions and 3 deletions

View file

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

View file

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

View file

@ -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__ */

View file

@ -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) &&

View file

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