]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/emv/tlv.h
2 * libopenemv - a library to work with EMV family of smart cards
3 * Copyright (C) 2012, 2015 Dmitry Eremin-Solenikov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * https://github.com/lumag/emv-tools/blob/master/lib/include/openemv/tlv.h
25 typedef uint16_t tlv_tag_t
;
30 const unsigned char *value
;
34 typedef bool (*tlv_cb
)(void *data
, const struct tlv
*tlv
, int level
, bool is_leaf
);
36 struct tlvdb
*tlvdb_fixed(tlv_tag_t tag
, size_t len
, const unsigned char *value
);
37 struct tlvdb
*tlvdb_external(tlv_tag_t tag
, size_t len
, const unsigned char *value
);
38 struct tlvdb
*tlvdb_parse(const unsigned char *buf
, size_t len
);
39 struct tlvdb
*tlvdb_parse_multi(const unsigned char *buf
, size_t len
);
40 void tlvdb_free(struct tlvdb
*tlvdb
);
42 struct tlvdb
*tlvdb_elm_get_next(struct tlvdb
*tlvdb
);
43 struct tlvdb
*tlvdb_elm_get_children(struct tlvdb
*tlvdb
);
44 struct tlvdb
*tlvdb_elm_get_parent(struct tlvdb
*tlvdb
);
46 struct tlvdb
*tlvdb_find_full(struct tlvdb
*tlvdb
, tlv_tag_t tag
); // search also in childrens
47 struct tlvdb
*tlvdb_find(struct tlvdb
*tlvdb
, tlv_tag_t tag
);
48 struct tlvdb
*tlvdb_find_next(struct tlvdb
*tlvdb
, tlv_tag_t tag
);
49 struct tlvdb
*tlvdb_find_path(struct tlvdb
*tlvdb
, tlv_tag_t tag
[]);
51 void tlvdb_add(struct tlvdb
*tlvdb
, struct tlvdb
*other
);
52 void tlvdb_change_or_add_node(struct tlvdb
*tlvdb
, tlv_tag_t tag
, size_t len
, const unsigned char *value
);
54 void tlvdb_visit(const struct tlvdb
*tlvdb
, tlv_cb cb
, void *data
, int level
);
55 const struct tlv
*tlvdb_get(const struct tlvdb
*tlvdb
, tlv_tag_t tag
, const struct tlv
*prev
);
56 const struct tlv
*tlvdb_get_inchild(const struct tlvdb
*tlvdb
, tlv_tag_t tag
, const struct tlv
*prev
);
57 const struct tlv
*tlvdb_get_tlv(const struct tlvdb
*tlvdb
);
59 bool tlv_parse_tl(const unsigned char **buf
, size_t *len
, struct tlv
*tlv
);
60 unsigned char *tlv_encode(const struct tlv
*tlv
, size_t *len
);
61 bool tlv_is_constructed(const struct tlv
*tlv
);
62 bool tlv_equal(const struct tlv
*a
, const struct tlv
*b
);