]> git.zerfleddert.de Git - proxmark3-svn/blob - client/fido/cbortools.h
Merge branch 'master' into fix_iclass_sim
[proxmark3-svn] / client / fido / cbortools.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2018 Merlok
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // Tools for work with CBOR format http://cbor.io/spec.html
9 // via Intel tinycbor (https://github.com/intel/tinycbor) library
10 //-----------------------------------------------------------------------------
11 //
12
13 #ifndef __CBORTOOLS_H__
14 #define __CBORTOOLS_H__
15
16 #include <stddef.h>
17 #include <stdint.h>
18 #include <jansson.h>
19 #include <cbor.h>
20
21 #define cbor_check_if(r) if ((r) != CborNoError) {return r;} else
22 #define cbor_check(r) if ((r) != CborNoError) return r;
23
24 extern int TinyCborPrintFIDOPackage(uint8_t cmdCode, bool isResponse, uint8_t *data, size_t length);
25 extern int JsonToCbor(json_t *elm, CborEncoder *encoder);
26
27 extern int CborMapGetKeyById(CborParser *parser, CborValue *map, uint8_t *data, size_t dataLen, int key);
28 extern CborError CborGetArrayBinStringValue(CborValue *elm, uint8_t *data, size_t maxdatalen, size_t *datalen);
29 extern CborError CborGetArrayBinStringValueEx(CborValue *elm, uint8_t *data, size_t maxdatalen, size_t *datalen, uint8_t *delimeter, size_t delimeterlen);
30 extern CborError CborGetBinStringValue(CborValue *elm, uint8_t *data, size_t maxdatalen, size_t *datalen);
31 extern CborError CborGetArrayStringValue(CborValue *elm, char *data, size_t maxdatalen, size_t *datalen, char *delimeter);
32 extern CborError CborGetStringValue(CborValue *elm, char *data, size_t maxdatalen, size_t *datalen);
33 extern CborError CborGetStringValueBuf(CborValue *elm);
34
35 extern int CBOREncodeElm(json_t *root, char *rootElmId, CborEncoder *encoder);
36 extern CborError CBOREncodeClientDataHash(json_t *root, CborEncoder *encoder);
37
38 #endif /* __CBORTOOLS_H__ */
Impressum, Datenschutz