X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/700d8687944db0a48535f818b59b6c9859952c61..7b6e32053373740516833b1a228a0ad01bb14bd2:/client/crypto/asn1utils.c?ds=sidebyside diff --git a/client/crypto/asn1utils.c b/client/crypto/asn1utils.c index 2a3fe698..f48c2e12 100644 --- a/client/crypto/asn1utils.c +++ b/client/crypto/asn1utils.c @@ -9,7 +9,14 @@ //----------------------------------------------------------------------------- #include "asn1utils.h" +#include +#include #include +#include "emv/tlv.h" +#include "emv/dump.h" +#include "asn1dump.h" +#include "util.h" +#include "ui.h" // PrintAndLog int ecdsa_asn1_get_signature(uint8_t *signature, size_t signaturelen, uint8_t *rval, uint8_t *sval) { if (!signature || !signaturelen || !rval || !sval) @@ -55,7 +62,27 @@ exit: return res; } -int asn1_print(uint8_t *asn1buf, int level) { +static bool print_cb(void *data, const struct tlv *tlv, int level, bool is_leaf) { + bool candump = true; + asn1_tag_dump(tlv, stdout, level, &candump); + if (is_leaf && candump) { + dump_buffer(tlv->value, tlv->len, stdout, level); + } + + return true; +} + +int asn1_print(uint8_t *asn1buf, size_t asn1buflen, char *indent) { + + struct tlvdb *t = NULL; + t = tlvdb_parse_multi(asn1buf, asn1buflen); + if (t) { + tlvdb_visit(t, print_cb, NULL, 0); + tlvdb_free(t); + } else { + PrintAndLogEx(ERR, "Can't parse data as TLV tree."); + return 1; + } return 0; }