mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
all works except of jansson private symbols linking
This commit is contained in:
parent
f03261be9a
commit
074c138de7
5 changed files with 108 additions and 4 deletions
|
@ -23,7 +23,7 @@ ENV_CFLAGS := $(CFLAGS)
|
||||||
VPATH = ../common ../zlib ../uart
|
VPATH = ../common ../zlib ../uart
|
||||||
OBJDIR = obj
|
OBJDIR = obj
|
||||||
|
|
||||||
LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm -L/usr/include
|
LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm -L/usr/lib -ljansson
|
||||||
LUALIB = ../liblua/liblua.a
|
LUALIB = ../liblua/liblua.a
|
||||||
LDFLAGS = $(ENV_LDFLAGS)
|
LDFLAGS = $(ENV_LDFLAGS)
|
||||||
INCLUDES_CLIENT = -I/usr/include -I. -I../include -I../common -I../common/polarssl -I../zlib -I../uart -I/opt/local/include -I../liblua
|
INCLUDES_CLIENT = -I/usr/include -I. -I../include -I../common -I../common/polarssl -I../zlib -I../uart -I/opt/local/include -I../liblua
|
||||||
|
|
|
@ -272,7 +272,7 @@ static const struct emv_tag emv_tags[] = {
|
||||||
{ 0x9f6a, "Unpredictable Number", EMV_TAG_NUMERIC },
|
{ 0x9f6a, "Unpredictable Number", EMV_TAG_NUMERIC },
|
||||||
{ 0x9f6b, "Track 2 Data" },
|
{ 0x9f6b, "Track 2 Data" },
|
||||||
{ 0x9f6c, "Card Transaction Qualifiers (CTQ)", EMV_TAG_BITMASK, &EMV_CTQ },
|
{ 0x9f6c, "Card Transaction Qualifiers (CTQ)", EMV_TAG_BITMASK, &EMV_CTQ },
|
||||||
{ 0x9f6e, "Form Factor Indicator" },
|
{ 0x9f6e, "Form Factor Indicator" },
|
||||||
{ 0xa5 , "File Control Information (FCI) Proprietary Template" },
|
{ 0xa5 , "File Control Information (FCI) Proprietary Template" },
|
||||||
{ 0xbf0c, "File Control Information (FCI) Issuer Discretionary Data" },
|
{ 0xbf0c, "File Control Information (FCI) Issuer Discretionary Data" },
|
||||||
{ 0xdf20, "Issuer Proprietary Bitmap (IPB)" },
|
{ 0xdf20, "Issuer Proprietary Bitmap (IPB)" },
|
||||||
|
@ -391,7 +391,7 @@ static unsigned long emv_value_numeric(const struct tlv *tlv, unsigned start, un
|
||||||
|
|
||||||
static void emv_tag_dump_numeric(const struct tlv *tlv, const struct emv_tag *tag, FILE *f, int level) {
|
static void emv_tag_dump_numeric(const struct tlv *tlv, const struct emv_tag *tag, FILE *f, int level) {
|
||||||
PRINT_INDENT(level);
|
PRINT_INDENT(level);
|
||||||
fprintf(f, "\tNumeric value %" PRIu32 " \n", emv_value_numeric(tlv, 0, tlv->len * 2));
|
fprintf(f, "\tNumeric value %lu\n", emv_value_numeric(tlv, 0, tlv->len * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emv_tag_dump_yymmdd(const struct tlv *tlv, const struct emv_tag *tag, FILE *f, int level) {
|
static void emv_tag_dump_yymmdd(const struct tlv *tlv, const struct emv_tag *tag, FILE *f, int level) {
|
||||||
|
@ -681,3 +681,17 @@ bool emv_tag_dump(const struct tlv *tlv, FILE *f, int level)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *emv_get_tag_name(const struct tlv *tlv)
|
||||||
|
{
|
||||||
|
static char *defstr = "";
|
||||||
|
|
||||||
|
if (!tlv)
|
||||||
|
return defstr;
|
||||||
|
|
||||||
|
const struct emv_tag *tag = emv_get_tag(tlv);
|
||||||
|
if (tag)
|
||||||
|
return tag->name;
|
||||||
|
|
||||||
|
return defstr;
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#include "tlv.h"
|
#include "tlv.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
// AC
|
// AC
|
||||||
# define EMVAC_AC_MASK 0xC0
|
# define EMVAC_AC_MASK 0xC0
|
||||||
|
@ -32,5 +31,6 @@
|
||||||
# define EMVCID_REASON_MASK 0x07
|
# define EMVCID_REASON_MASK 0x07
|
||||||
|
|
||||||
bool emv_tag_dump(const struct tlv *tlv, FILE *f, int level);
|
bool emv_tag_dump(const struct tlv *tlv, FILE *f, int level);
|
||||||
|
char *emv_get_tag_name(const struct tlv *tlv);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -318,6 +318,24 @@ struct tlvdb *tlvdb_find(struct tlvdb *tlvdb, tlv_tag_t tag) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_find_full(struct tlvdb *tlvdb, tlv_tag_t tag) {
|
||||||
|
if (!tlvdb)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (; tlvdb; tlvdb = tlvdb->next) {
|
||||||
|
if (tlvdb->tag.tag == tag)
|
||||||
|
return tlvdb;
|
||||||
|
|
||||||
|
if (tlvdb->children) {
|
||||||
|
struct tlvdb * ch = tlvdb_find_full(tlvdb->children, tag);
|
||||||
|
if (ch)
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct tlvdb *tlvdb_find_path(struct tlvdb *tlvdb, tlv_tag_t tag[]) {
|
struct tlvdb *tlvdb_find_path(struct tlvdb *tlvdb, tlv_tag_t tag[]) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct tlvdb *tnext = tlvdb;
|
struct tlvdb *tnext = tlvdb;
|
||||||
|
@ -342,6 +360,52 @@ void tlvdb_add(struct tlvdb *tlvdb, struct tlvdb *other)
|
||||||
tlvdb->next = other;
|
tlvdb->next = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tlvdb_change_or_add_node(struct tlvdb *tlvdb, tlv_tag_t tag, size_t len, const unsigned char *value)
|
||||||
|
{
|
||||||
|
struct tlvdb *telm = tlvdb_find_full(tlvdb, tag);
|
||||||
|
if (telm == NULL) {
|
||||||
|
// new tlv element
|
||||||
|
tlvdb_add(tlvdb, tlvdb_fixed(tag, len, value));
|
||||||
|
} else {
|
||||||
|
// the same tlv structure
|
||||||
|
if (telm->tag.tag == tag && telm->tag.len == len && !memcmp(telm->tag.value, value, len))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// replace tlv element
|
||||||
|
struct tlvdb *tnewelm = tlvdb_fixed(tag, len, value);
|
||||||
|
tnewelm->next = telm->next;
|
||||||
|
tnewelm->parent = telm->parent;
|
||||||
|
|
||||||
|
// if telm stayed first in children chain
|
||||||
|
if (telm->parent && telm->parent->children == telm) {
|
||||||
|
telm->parent->children = tnewelm;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if telm have previous element
|
||||||
|
if (telm != tlvdb) {
|
||||||
|
// elm in root
|
||||||
|
struct tlvdb *celm = tlvdb;
|
||||||
|
// elm in child list of node
|
||||||
|
if (telm->parent && telm->parent->children)
|
||||||
|
celm = telm->parent->children;
|
||||||
|
|
||||||
|
// find previous element
|
||||||
|
for (; celm; celm = celm->next) {
|
||||||
|
if (celm->next == telm) {
|
||||||
|
celm->next = tnewelm;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// free old element with childrens
|
||||||
|
telm->next = NULL;
|
||||||
|
tlvdb_free(telm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void tlvdb_visit(const struct tlvdb *tlvdb, tlv_cb cb, void *data, int level)
|
void tlvdb_visit(const struct tlvdb *tlvdb, tlv_cb cb, void *data, int level)
|
||||||
{
|
{
|
||||||
struct tlvdb *next = NULL;
|
struct tlvdb *next = NULL;
|
||||||
|
@ -394,6 +458,10 @@ const struct tlv *tlvdb_get_inchild(const struct tlvdb *tlvdb, tlv_tag_t tag, co
|
||||||
return tlvdb_get(tlvdb, tag, prev);
|
return tlvdb_get(tlvdb, tag, prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct tlv *tlvdb_get_tlv(const struct tlvdb *tlvdb) {
|
||||||
|
return &tlvdb->tag;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char *tlv_encode(const struct tlv *tlv, size_t *len)
|
unsigned char *tlv_encode(const struct tlv *tlv, size_t *len)
|
||||||
{
|
{
|
||||||
size_t size = tlv->len;
|
size_t size = tlv->len;
|
||||||
|
@ -452,3 +520,18 @@ bool tlv_equal(const struct tlv *a, const struct tlv *b)
|
||||||
|
|
||||||
return a->tag == b->tag && a->len == b->len && !memcmp(a->value, b->value, a->len);
|
return a->tag == b->tag && a->len == b->len && !memcmp(a->value, b->value, a->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_next(struct tlvdb *tlvdb)
|
||||||
|
{
|
||||||
|
return tlvdb->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_children(struct tlvdb *tlvdb)
|
||||||
|
{
|
||||||
|
return tlvdb->children;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_parent(struct tlvdb *tlvdb)
|
||||||
|
{
|
||||||
|
return tlvdb->parent;
|
||||||
|
}
|
||||||
|
|
|
@ -39,15 +39,22 @@ struct tlvdb *tlvdb_parse(const unsigned char *buf, size_t len);
|
||||||
struct tlvdb *tlvdb_parse_multi(const unsigned char *buf, size_t len);
|
struct tlvdb *tlvdb_parse_multi(const unsigned char *buf, size_t len);
|
||||||
void tlvdb_free(struct tlvdb *tlvdb);
|
void tlvdb_free(struct tlvdb *tlvdb);
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_next(struct tlvdb *tlvdb);
|
||||||
|
struct tlvdb *tlvdb_elm_get_children(struct tlvdb *tlvdb);
|
||||||
|
struct tlvdb *tlvdb_elm_get_parent(struct tlvdb *tlvdb);
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_find_full(struct tlvdb *tlvdb, tlv_tag_t tag); // search also in childrens
|
||||||
struct tlvdb *tlvdb_find(struct tlvdb *tlvdb, tlv_tag_t tag);
|
struct tlvdb *tlvdb_find(struct tlvdb *tlvdb, tlv_tag_t tag);
|
||||||
struct tlvdb *tlvdb_find_next(struct tlvdb *tlvdb, tlv_tag_t tag);
|
struct tlvdb *tlvdb_find_next(struct tlvdb *tlvdb, tlv_tag_t tag);
|
||||||
struct tlvdb *tlvdb_find_path(struct tlvdb *tlvdb, tlv_tag_t tag[]);
|
struct tlvdb *tlvdb_find_path(struct tlvdb *tlvdb, tlv_tag_t tag[]);
|
||||||
|
|
||||||
void tlvdb_add(struct tlvdb *tlvdb, struct tlvdb *other);
|
void tlvdb_add(struct tlvdb *tlvdb, struct tlvdb *other);
|
||||||
|
void tlvdb_change_or_add_node(struct tlvdb *tlvdb, tlv_tag_t tag, size_t len, const unsigned char *value);
|
||||||
|
|
||||||
void tlvdb_visit(const struct tlvdb *tlvdb, tlv_cb cb, void *data, int level);
|
void tlvdb_visit(const struct tlvdb *tlvdb, tlv_cb cb, void *data, int level);
|
||||||
const struct tlv *tlvdb_get(const struct tlvdb *tlvdb, tlv_tag_t tag, const struct tlv *prev);
|
const struct tlv *tlvdb_get(const struct tlvdb *tlvdb, tlv_tag_t tag, const struct tlv *prev);
|
||||||
const struct tlv *tlvdb_get_inchild(const struct tlvdb *tlvdb, tlv_tag_t tag, const struct tlv *prev);
|
const struct tlv *tlvdb_get_inchild(const struct tlvdb *tlvdb, tlv_tag_t tag, const struct tlv *prev);
|
||||||
|
const struct tlv *tlvdb_get_tlv(const struct tlvdb *tlvdb);
|
||||||
|
|
||||||
bool tlv_parse_tl(const unsigned char **buf, size_t *len, struct tlv *tlv);
|
bool tlv_parse_tl(const unsigned char **buf, size_t *len, struct tlv *tlv);
|
||||||
unsigned char *tlv_encode(const struct tlv *tlv, size_t *len);
|
unsigned char *tlv_encode(const struct tlv *tlv, size_t *len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue