mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
refactoring and GetAssertion works
This commit is contained in:
parent
26cf350713
commit
317ea30529
4 changed files with 34 additions and 11 deletions
|
@ -759,7 +759,7 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse returned cbor
|
// parse returned cbor
|
||||||
MakeCredentionalParseRes(root, &buf[1], len - 1, verbose, verbose2, showCBOR, showDERTLV);
|
FIDO2MakeCredentionalParseRes(root, &buf[1], len - 1, verbose, verbose2, showCBOR, showDERTLV);
|
||||||
|
|
||||||
if (root) {
|
if (root) {
|
||||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||||
|
@ -875,14 +875,28 @@ int CmdHFFido2GetAssertion(const char *cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PrintAndLog("MakeCredential result (%d b) OK.", len);
|
PrintAndLog("GetAssertion result (%d b) OK.", len);
|
||||||
if (showCBOR) {
|
if (showCBOR) {
|
||||||
PrintAndLog("CBOR get assertion response:");
|
PrintAndLog("CBOR get assertion response:");
|
||||||
PrintAndLog("---------------- CBOR ------------------");
|
PrintAndLog("---------------- CBOR ------------------");
|
||||||
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, true, &buf[1], len - 1);
|
TinyCborPrintFIDOPackage(fido2CmdGetAssertion, true, &buf[1], len - 1);
|
||||||
PrintAndLog("---------------- CBOR ------------------");
|
PrintAndLog("---------------- CBOR ------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse returned cbor
|
||||||
|
FIDO2GetAssertionParseRes(root, &buf[1], len - 1, verbose, verbose2, showCBOR);
|
||||||
|
|
||||||
|
/* if (root) {
|
||||||
|
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||||
|
if (res) {
|
||||||
|
PrintAndLog("ERROR: can't save the file: %s", fname);
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
PrintAndLog("File `%s` saved.", fname);
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
json_decref(root);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,12 @@ CborError CborGetStringValueBuf(CborValue *elm) {
|
||||||
};
|
};
|
||||||
|
|
||||||
int CBOREncodeElm(json_t *root, char *rootElmId, CborEncoder *encoder) {
|
int CBOREncodeElm(json_t *root, char *rootElmId, CborEncoder *encoder) {
|
||||||
json_t *elm = json_object_get(root, rootElmId);
|
json_t *elm = NULL;
|
||||||
|
if (rootElmId && strlen(rootElmId) && rootElmId[0] == '$')
|
||||||
|
elm = json_path_get(root, rootElmId);
|
||||||
|
else
|
||||||
|
elm = json_object_get(root, rootElmId);
|
||||||
|
|
||||||
if (!elm)
|
if (!elm)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,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 verbose2, bool showCBOR, bool showDERTLV) {
|
int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR, bool showDERTLV) {
|
||||||
CborParser parser;
|
CborParser parser;
|
||||||
CborValue map, mapsmt;
|
CborValue map, mapsmt;
|
||||||
int res;
|
int res;
|
||||||
|
@ -567,17 +567,15 @@ int FIDO2CreateGetAssertionReq(json_t *root, uint8_t *data, size_t maxdatalen, s
|
||||||
cbor_encoder_init(&encoder, data, maxdatalen, 0);
|
cbor_encoder_init(&encoder, data, maxdatalen, 0);
|
||||||
|
|
||||||
// create main map
|
// create main map
|
||||||
res = cbor_encoder_create_map(&encoder, &map, 5);
|
res = cbor_encoder_create_map(&encoder, &map, 3);
|
||||||
fido_check_if(res) {
|
fido_check_if(res) {
|
||||||
// rpId
|
// rpId
|
||||||
res = cbor_encode_uint(&map, 1);
|
res = cbor_encode_uint(&map, 1);
|
||||||
fido_check_if(res) {
|
fido_check_if(res) {
|
||||||
// char hashval[300] = {0};
|
|
||||||
// JsonLoadStr(json, "$.RelyingPartyEntity.id", hashval);
|
|
||||||
|
|
||||||
res = CBOREncodeElm(root, "RelyingPartyEntity", &map);
|
res = CBOREncodeElm(root, "$.RelyingPartyEntity.id", &map);
|
||||||
fido_check(res);
|
fido_check(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clientDataHash
|
// clientDataHash
|
||||||
res = cbor_encode_uint(&map, 2);
|
res = cbor_encode_uint(&map, 2);
|
||||||
|
@ -602,3 +600,8 @@ int FIDO2CreateGetAssertionReq(json_t *root, uint8_t *data, size_t maxdatalen, s
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FIDO2GetAssertionParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ extern char *fido2GetCmdErrorDescription(uint8_t errorCode);
|
||||||
|
|
||||||
extern bool CheckrpIdHash(json_t *json, uint8_t *hash);
|
extern bool CheckrpIdHash(json_t *json, uint8_t *hash);
|
||||||
extern int FIDO2CreateMakeCredentionalReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);
|
extern int FIDO2CreateMakeCredentionalReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);
|
||||||
extern int MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR, bool showDERTLV);
|
extern int FIDO2MakeCredentionalParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR, bool showDERTLV);
|
||||||
extern int FIDO2CreateGetAssertionReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);
|
extern int FIDO2CreateGetAssertionReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);
|
||||||
|
extern int FIDO2GetAssertionParseRes(json_t *root, uint8_t *data, size_t dataLen, bool verbose, bool verbose2, bool showCBOR);
|
||||||
|
|
||||||
#endif /* __FIDOCORE_H__ */
|
#endif /* __FIDOCORE_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue