mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
sketch for get cmd code name
This commit is contained in:
parent
8201526f6e
commit
f4bb63a728
3 changed files with 20 additions and 9 deletions
|
@ -49,6 +49,8 @@
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
|
#define FIDO2_CMD_INFO 0x04
|
||||||
|
|
||||||
int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
||||||
uint8_t data[] = {0xA0, 0x00, 0x00, 0x06, 0x47, 0x2F, 0x00, 0x01};
|
uint8_t data[] = {0xA0, 0x00, 0x00, 0x06, 0x47, 0x2F, 0x00, 0x01};
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uin
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
||||||
uint8_t data[] = {0x04};
|
uint8_t data[] = {FIDO2_CMD_INFO};
|
||||||
return FIDOExchange((sAPDU){0x80, 0x10, 0x00, 0x00, sizeof(data), data}, Result, MaxResultLen, ResultLen, sw);
|
return FIDOExchange((sAPDU){0x80, 0x10, 0x00, 0x00, sizeof(data), data}, Result, MaxResultLen, ResultLen, sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +150,7 @@ int CmdHFFidoInfo(const char *cmd) {
|
||||||
|
|
||||||
PrintAndLog("FIDO2 version: (%d)", len);
|
PrintAndLog("FIDO2 version: (%d)", len);
|
||||||
dump_buffer((const unsigned char *)buf, len, NULL, 0);
|
dump_buffer((const unsigned char *)buf, len, NULL, 0);
|
||||||
TinyCborPrintFIDOPackage(&buf[1], len - 1);
|
TinyCborPrintFIDOPackage(FIDO2_CMD_INFO, &buf[1], len - 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,11 @@ static CborError dumpelm(CborValue *it, bool *got_next, int nestingLevel) {
|
||||||
return CborNoError;
|
return CborNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CborError dumprecursive(CborValue *it, bool isMapType, int nestingLevel) {
|
char *getCmdCodeDescription (uint8_t cmdCode, uint8_t memberNum) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CborError dumprecursive(uint8_t cmdCode, CborValue *it, bool isMapType, int nestingLevel) {
|
||||||
int elmCount = 0;
|
int elmCount = 0;
|
||||||
while (!cbor_value_at_end(it)) {
|
while (!cbor_value_at_end(it)) {
|
||||||
CborError err;
|
CborError err;
|
||||||
|
@ -141,7 +145,7 @@ static CborError dumprecursive(CborValue *it, bool isMapType, int nestingLevel)
|
||||||
err = cbor_value_enter_container(it, &recursed);
|
err = cbor_value_enter_container(it, &recursed);
|
||||||
if (err)
|
if (err)
|
||||||
return err; // parse error
|
return err; // parse error
|
||||||
err = dumprecursive(&recursed, (type == CborMapType), nestingLevel + 1);
|
err = dumprecursive(cmdCode, &recursed, (type == CborMapType), nestingLevel + 1);
|
||||||
if (err)
|
if (err)
|
||||||
return err; // parse error
|
return err; // parse error
|
||||||
err = cbor_value_leave_container(it, &recursed);
|
err = cbor_value_leave_container(it, &recursed);
|
||||||
|
@ -157,8 +161,13 @@ static CborError dumprecursive(CborValue *it, bool isMapType, int nestingLevel)
|
||||||
err = dumpelm(it, &got_next, (isMapType && (elmCount % 2)) ? 0 : nestingLevel);
|
err = dumpelm(it, &got_next, (isMapType && (elmCount % 2)) ? 0 : nestingLevel);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
// if (nestingLevel == 1 && isMapType && !(elmCount % 2))
|
if (cmdCode > 0 && nestingLevel == 1 && isMapType && !(elmCount % 2)) {
|
||||||
// printf(" ()");
|
int64_t val;
|
||||||
|
cbor_value_get_int64(it, &val);
|
||||||
|
char *desc = getCmdCodeDescription(cmdCode, val);
|
||||||
|
if (desc)
|
||||||
|
printf(" (%s)", desc);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +196,7 @@ int TinyCborInit(uint8_t *data, size_t length, CborValue *cb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TinyCborPrintFIDOPackage(uint8_t *data, size_t length) {
|
int TinyCborPrintFIDOPackage(uint8_t cmdCode, uint8_t *data, size_t length) {
|
||||||
CborValue cb;
|
CborValue cb;
|
||||||
int res;
|
int res;
|
||||||
res = TinyCborInit(data, length, &cb);
|
res = TinyCborInit(data, length, &cb);
|
||||||
|
@ -196,7 +205,7 @@ int TinyCborPrintFIDOPackage(uint8_t *data, size_t length) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CborError err = dumprecursive(&cb, false, 0);
|
CborError err = dumprecursive(cmdCode, &cb, false, 0);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
fprintf(stderr, "CBOR parsing failure at offset %d: %s\n",
|
fprintf(stderr, "CBOR parsing failure at offset %d: %s\n",
|
||||||
|
|
|
@ -17,6 +17,6 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern int TinyCborPrintFIDOPackage(uint8_t *data, size_t length);
|
extern int TinyCborPrintFIDOPackage(uint8_t cmdCode, uint8_t *data, size_t length);
|
||||||
|
|
||||||
#endif /* __CBORTOOLS_H__ */
|
#endif /* __CBORTOOLS_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue