added showCBOR

This commit is contained in:
merlokk 2018-11-26 18:37:21 +02:00
commit b0e0ccb05f

View file

@ -658,7 +658,7 @@ bool CheckrpIdHash(json_t *json, uint8_t *hash) {
return !memcmp(hash, hash2, 32); return !memcmp(hash, hash2, 32);
} }
int MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool showDERTLV) { int MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool showCBOR, bool showDERTLV) {
CborParser parser; CborParser parser;
CborValue map, mapsmt; CborValue map, mapsmt;
int res; int res;
@ -724,7 +724,7 @@ int MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool v
uint8_t coseKey[65] = {0}; uint8_t coseKey[65] = {0};
uint16_t cplen = n - 55 - cridlen; uint16_t cplen = n - 55 - cridlen;
PrintAndLog("Credentional public key (COSE_KEY)[%d]: %s", cplen, sprint_hex(&ubuf[55 + cridlen], cplen)); PrintAndLog("Credentional public key (COSE_KEY)[%d]: %s", cplen, sprint_hex(&ubuf[55 + cridlen], cplen));
if (verbose) { if (showCBOR) {
TinyCborPrintFIDOPackage(fido2COSEKey, true, &ubuf[55 + cridlen], cplen); TinyCborPrintFIDOPackage(fido2COSEKey, true, &ubuf[55 + cridlen], cplen);
} }
res = COSEGetECDSAKey(&ubuf[55 + cridlen], cplen, verbose, coseKey); res = COSEGetECDSAKey(&ubuf[55 + cridlen], cplen, verbose, coseKey);
@ -831,6 +831,7 @@ int CmdHFFido2MakeCredential(const char *cmd) {
char fname[300] = {0}; char fname[300] = {0};
bool verbose = true; bool verbose = true;
bool showDERTLV = true; bool showDERTLV = true;
bool showCBOR = true;
int res = GetExistsFileNameJson("fido", "fido2", fname); int res = GetExistsFileNameJson("fido", "fido2", fname);
if(res) { if(res) {
@ -869,8 +870,10 @@ int CmdHFFido2MakeCredential(const char *cmd) {
if (res) if (res)
return res; return res;
PrintAndLog("CBOR make credentional request:"); if (showCBOR) {
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, false, data, datalen); PrintAndLog("CBOR make credentional request:");
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, false, data, datalen);
}
res = FIDO2MakeCredential(data, datalen, buf, sizeof(buf), &len, &sw); res = FIDO2MakeCredential(data, datalen, buf, sizeof(buf), &len, &sw);
DropField(); DropField();
@ -890,11 +893,13 @@ int CmdHFFido2MakeCredential(const char *cmd) {
} }
PrintAndLog("MakeCredential result (%d b) OK.", len); PrintAndLog("MakeCredential result (%d b) OK.", len);
PrintAndLog("CBOR make credentional response:"); if (showCBOR) {
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, true, &buf[1], len - 1); PrintAndLog("CBOR make credentional response:");
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, true, &buf[1], len - 1);
}
// parse returned cbor // parse returned cbor
MakeCredentionalParseRes(root, &buf[1], len - 1, verbose, showDERTLV); MakeCredentionalParseRes(root, &buf[1], len - 1, verbose, showCBOR, showDERTLV);
json_decref(root); json_decref(root);