mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
extract some descriptions from cose_key
This commit is contained in:
parent
56c9270574
commit
f7354c705d
2 changed files with 50 additions and 0 deletions
|
@ -11,6 +11,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "cose.h"
|
#include "cose.h"
|
||||||
|
#include <cbor.h>
|
||||||
|
#include "cbortools.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static const char COSEEmptyStr[] = "";
|
static const char COSEEmptyStr[] = "";
|
||||||
|
@ -126,8 +128,55 @@ const char *GetCOSEAlgDescription(int id) {
|
||||||
return COSEEmptyStr;
|
return COSEEmptyStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int COSEGetECDSAKey(uint8_t *data, size_t datalen, bool verbose, uint8_t *public_key) {
|
COSEValueNameDesc_t *GetCOSEktyElm(int id) {
|
||||||
|
for (int i = 0; i < ARRAYLEN(COSEKeyTypeValueDesc); i++)
|
||||||
|
if (COSEKeyTypeValueDesc[i].Value == id)
|
||||||
|
return &COSEKeyTypeValueDesc[i];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *GetCOSEktyDescription(int id) {
|
||||||
|
COSEValueNameDesc_t *elm = GetCOSEktyElm(id);
|
||||||
|
if (elm)
|
||||||
|
return elm->Description;
|
||||||
|
return COSEEmptyStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int COSEGetECDSAKey(uint8_t *data, size_t datalen, bool verbose, uint8_t *public_key) {
|
||||||
|
CborParser parser;
|
||||||
|
CborValue map;
|
||||||
|
int64_t i64;
|
||||||
|
|
||||||
|
if(verbose)
|
||||||
|
PrintAndLog("----------- CBOR decode ----------------");
|
||||||
|
|
||||||
|
// kty
|
||||||
|
int res = CborMapGetKeyById(&parser, &map, data, datalen, 1);
|
||||||
|
if(!res) {
|
||||||
|
cbor_value_get_int64(&map, &i64);
|
||||||
|
if(verbose)
|
||||||
|
PrintAndLog("kty [%lld] %s", (long long)i64, GetCOSEktyDescription(i64));
|
||||||
|
}
|
||||||
|
|
||||||
|
// algorithm
|
||||||
|
res = CborMapGetKeyById(&parser, &map, data, datalen, 3);
|
||||||
|
if(!res) {
|
||||||
|
cbor_value_get_int64(&map, &i64);
|
||||||
|
if(verbose)
|
||||||
|
PrintAndLog("algorithm [%lld] %s", (long long)i64, GetCOSEAlgDescription(i64));
|
||||||
|
}
|
||||||
|
|
||||||
|
// curve
|
||||||
|
res = CborMapGetKeyById(&parser, &map, data, datalen, -1);
|
||||||
|
if(!res) {
|
||||||
|
cbor_value_get_int64(&map, &i64);
|
||||||
|
if(verbose)
|
||||||
|
PrintAndLog("curve [%lld] %s", (long long)i64, GetCOSEAlgDescription(i64));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(verbose)
|
||||||
|
PrintAndLog("----------- CBOR decode ----------------");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
extern const char *GetCOSEAlgName(int id);
|
extern const char *GetCOSEAlgName(int id);
|
||||||
extern const char *GetCOSEAlgDescription(int id);
|
extern const char *GetCOSEAlgDescription(int id);
|
||||||
|
extern const char *GetCOSEktyDescription(int id);
|
||||||
|
|
||||||
extern int COSEGetECDSAKey(uint8_t *data, size_t datalen, bool verbose, uint8_t *public_key);
|
extern int COSEGetECDSAKey(uint8_t *data, size_t datalen, bool verbose, uint8_t *public_key);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue