mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-22 21:17:31 +08:00
added CBOR description for queries
This commit is contained in:
parent
f705402b7a
commit
979a14d978
5 changed files with 43 additions and 16 deletions
|
@ -116,7 +116,7 @@ int CmdHFFidoInfo(const char *cmd) {
|
|||
// }
|
||||
|
||||
PrintAndLog("FIDO2 version CBOR decoded:");
|
||||
TinyCborPrintFIDOPackage(fido2CmdGetInfo, &buf[1], len - 1);
|
||||
TinyCborPrintFIDOPackage(fido2CmdGetInfo, true, &buf[1], len - 1);
|
||||
} else {
|
||||
PrintAndLog("FIDO2 version length error");
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
return res;
|
||||
|
||||
PrintAndLog("CBOR make credentional request:");
|
||||
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, data, datalen);
|
||||
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, false, data, datalen);
|
||||
|
||||
res = FIDO2MakeCredential(data, datalen, buf, sizeof(buf), &len, &sw);
|
||||
DropField();
|
||||
|
@ -763,9 +763,9 @@ int CmdHFFido2MakeCredential(const char *cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("MakeCredential result (%d) OK.", len);
|
||||
PrintAndLog("MakeCredential result (%d b) OK.", len);
|
||||
PrintAndLog("CBOR make credentional response:");
|
||||
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, &buf[1], len - 1);
|
||||
TinyCborPrintFIDOPackage(fido2CmdMakeCredential, true, &buf[1], len - 1);
|
||||
|
||||
json_decref(root);
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ static CborError dumpelm(CborValue *it, bool *got_next, int nestingLevel) {
|
|||
return CborNoError;
|
||||
}
|
||||
|
||||
static CborError dumprecursive(uint8_t cmdCode, CborValue *it, bool isMapType, int nestingLevel) {
|
||||
static CborError dumprecursive(uint8_t cmdCode, bool isResponse, CborValue *it, bool isMapType, int nestingLevel) {
|
||||
int elmCount = 0;
|
||||
while (!cbor_value_at_end(it)) {
|
||||
CborError err;
|
||||
|
@ -142,7 +142,7 @@ static CborError dumprecursive(uint8_t cmdCode, CborValue *it, bool isMapType, i
|
|||
err = cbor_value_enter_container(it, &recursed);
|
||||
if (err)
|
||||
return err; // parse error
|
||||
err = dumprecursive(cmdCode, &recursed, (type == CborMapType), nestingLevel + 1);
|
||||
err = dumprecursive(cmdCode, isResponse, &recursed, (type == CborMapType), nestingLevel + 1);
|
||||
if (err)
|
||||
return err; // parse error
|
||||
err = cbor_value_leave_container(it, &recursed);
|
||||
|
@ -161,7 +161,7 @@ static CborError dumprecursive(uint8_t cmdCode, CborValue *it, bool isMapType, i
|
|||
if (cmdCode > 0 && nestingLevel == 1 && isMapType && !(elmCount % 2)) {
|
||||
int64_t val;
|
||||
cbor_value_get_int64(it, &val);
|
||||
char *desc = fido2GetCmdMemberDescription(cmdCode, val);
|
||||
char *desc = fido2GetCmdMemberDescription(cmdCode, isResponse, val);
|
||||
if (desc)
|
||||
printf(" (%s)", desc);
|
||||
}
|
||||
|
@ -193,14 +193,14 @@ int TinyCborInit(uint8_t *data, size_t length, CborValue *cb) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int TinyCborPrintFIDOPackage(uint8_t cmdCode, uint8_t *data, size_t length) {
|
||||
int TinyCborPrintFIDOPackage(uint8_t cmdCode, bool isResponse, uint8_t *data, size_t length) {
|
||||
CborValue cb;
|
||||
int res;
|
||||
res = TinyCborInit(data, length, &cb);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
CborError err = dumprecursive(cmdCode, &cb, false, 0);
|
||||
CborError err = dumprecursive(cmdCode, isResponse, &cb, false, 0);
|
||||
|
||||
if (err) {
|
||||
fprintf(stderr, "CBOR parsing failure at offset %d: %s\n",
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define cbor_check_if(r) if ((r) != CborNoError) {return r;} else
|
||||
#define cbor_check(r) if ((r) != CborNoError) return r;
|
||||
|
||||
extern int TinyCborPrintFIDOPackage(uint8_t cmdCode, uint8_t *data, size_t length);
|
||||
extern int TinyCborPrintFIDOPackage(uint8_t cmdCode, bool isResponse, uint8_t *data, size_t length);
|
||||
extern int JsonToCbor(json_t *elm, CborEncoder *encoder);
|
||||
|
||||
#endif /* __CBORTOOLS_H__ */
|
||||
|
|
|
@ -84,12 +84,30 @@ fido2Desc_t fido2CmdGetInfoRespDesc[] = {
|
|||
{fido2CmdMakeCredential, ptResponse, 0x01, "fmt"},
|
||||
{fido2CmdMakeCredential, ptResponse, 0x02, "authData"},
|
||||
{fido2CmdMakeCredential, ptResponse, 0x03, "attStmt"},
|
||||
|
||||
{fido2CmdMakeCredential, ptQuery, 0x01, "clientDataHash"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x02, "rp"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x03, "user"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x04, "pubKeyCredParams"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x05, "excludeList"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x06, "extensions"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x07, "options"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x08, "pinAuth"},
|
||||
{fido2CmdMakeCredential, ptQuery, 0x09, "pinProtocol"},
|
||||
|
||||
{fido2CmdGetAssertion, ptResponse, 0x01, "credential"},
|
||||
{fido2CmdGetAssertion, ptResponse, 0x02, "authData"},
|
||||
{fido2CmdGetAssertion, ptResponse, 0x03, "signature"},
|
||||
{fido2CmdGetAssertion, ptResponse, 0x04, "publicKeyCredentialUserEntity"},
|
||||
{fido2CmdGetAssertion, ptResponse, 0x05, "numberOfCredentials"},
|
||||
|
||||
{fido2CmdGetAssertion, ptQuery, 0x01, "rpId"},
|
||||
{fido2CmdGetAssertion, ptQuery, 0x02, "clientDataHash"},
|
||||
{fido2CmdGetAssertion, ptQuery, 0x03, "allowList"},
|
||||
{fido2CmdGetAssertion, ptQuery, 0x04, "extensions"},
|
||||
{fido2CmdGetAssertion, ptQuery, 0x05, "options"},
|
||||
{fido2CmdGetAssertion, ptQuery, 0x06, "pinAuth"},
|
||||
{fido2CmdGetAssertion, ptQuery, 0x07, "pinProtocol"},
|
||||
|
||||
{fido2CmdGetNextAssertion, ptResponse, 0x01, "credential"},
|
||||
{fido2CmdGetNextAssertion, ptResponse, 0x02, "authData"},
|
||||
|
@ -103,9 +121,18 @@ fido2Desc_t fido2CmdGetInfoRespDesc[] = {
|
|||
{fido2CmdGetInfo, ptResponse, 0x05, "maxMsgSize"},
|
||||
{fido2CmdGetInfo, ptResponse, 0x06, "pinProtocols"},
|
||||
|
||||
{fido2CmdClientPIN, ptResponse, 0x06, "keyAgreement"},
|
||||
{fido2CmdClientPIN, ptResponse, 0x06, "pinToken"},
|
||||
{fido2CmdClientPIN, ptResponse, 0x06, "retries"},
|
||||
{fido2CmdClientPIN, ptResponse, 0x01, "keyAgreement"},
|
||||
{fido2CmdClientPIN, ptResponse, 0x02, "pinToken"},
|
||||
{fido2CmdClientPIN, ptResponse, 0x03, "retries"},
|
||||
|
||||
{fido2CmdClientPIN, ptQuery, 0x01, "pinProtocol"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x02, "subCommand"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x03, "keyAgreement"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x04, "pinAuth"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x05, "newPinEnc"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x06, "pinHashEnc"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x07, "getKeyAgreement"},
|
||||
{fido2CmdClientPIN, ptQuery, 0x08, "getRetries"},
|
||||
};
|
||||
|
||||
char *fido2GetCmdErrorDescription(uint8_t errorCode) {
|
||||
|
@ -116,10 +143,10 @@ char *fido2GetCmdErrorDescription(uint8_t errorCode) {
|
|||
return fido2Errors[0].Description;
|
||||
}
|
||||
|
||||
char *fido2GetCmdMemberDescription(uint8_t cmdCode, uint8_t memberNum) {
|
||||
char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, 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].PckType == (isResponse ? ptResponse : ptQuery) &&
|
||||
fido2CmdGetInfoRespDesc[i].MemberNumber == memberNum )
|
||||
return fido2CmdGetInfoRespDesc[i].Description;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ extern int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen,
|
|||
extern int FIDO2MakeCredential(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||
extern int FIDO2GetAssertion(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||
|
||||
extern char *fido2GetCmdMemberDescription(uint8_t cmdCode, uint8_t memberNum);
|
||||
extern char *fido2GetCmdMemberDescription(uint8_t cmdCode, bool isResponse, uint8_t memberNum);
|
||||
extern char *fido2GetCmdErrorDescription(uint8_t errorCode);
|
||||
|
||||
extern int FIDO2CreateMakeCredentionalReq(json_t *root, uint8_t *data, size_t maxdatalen, size_t *datalen);
|
||||
|
|
Loading…
Add table
Reference in a new issue