mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
added cbor print sketch
This commit is contained in:
parent
cbdb42560c
commit
2d17fb172a
4 changed files with 73 additions and 7 deletions
41
client/fido/cbortools.c
Normal file
41
client/fido/cbortools.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018 Merlok
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Tools for work with CBOR format http://cbor.io/spec.html
|
||||
// via Intel tinycbor (https://github.com/intel/tinycbor) library
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "cbortools.h"
|
||||
#include "cbor.h"
|
||||
|
||||
|
||||
int TinyCborParser(uint8_t *data, size_t length, CborValue *cb) {
|
||||
CborParser parser;
|
||||
CborError err = cbor_parser_init(data, length, 0, &parser, cb);
|
||||
// if (!err)
|
||||
// err = dumprecursive(cb, 0);
|
||||
|
||||
if (err) {
|
||||
fprintf(stderr, "CBOR parsing failure at offset %d: %s\n",
|
||||
cb->ptr - data, cbor_error_string(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TinyCborPrintFIDOPackage(uint8_t *data, size_t length) {
|
||||
CborValue cb;
|
||||
int res;
|
||||
res = TinyCborParser(data, length, &cb);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
client/fido/cbortools.h
Normal file
22
client/fido/cbortools.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018 Merlok
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Tools for work with CBOR format http://cbor.io/spec.html
|
||||
// via Intel tinycbor (https://github.com/intel/tinycbor) library
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
#ifndef __CBORTOOLS_H__
|
||||
#define __CBORTOOLS_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern int TinyCborPrintFIDOPackage(uint8_t *data, size_t length);
|
||||
|
||||
#endif /* __CBORTOOLS_H__ */
|
Loading…
Add table
Add a link
Reference in a new issue