Giter VIP home page Giter VIP logo

ber-tlv's Introduction

BER-TLV parser and builder(C Standard)

Features

  • It supports nested TLV whether to build or parse
  • It designed according EMV 4.1 Book 3 - Annex B

How to parse

	uint32 hexStrLen = 54;
	uint8 hexStr[hexStrLen] = "50045649534157131000023100000033D44122011003400000481F";
	uint8 bytes[hexStrLen/ 2];
	uint32 bytesLength = hexStrLen / 2;
	tlvNode_t * tlvHeader; //Start Saving data from this point
	hex2bin(hexStr, bytes, hexStrLen);

	initTlvList();
	tlvListParse(bytes, bytesLength);
	tlvHeader = getTlvNodeHeader();

	printAllOfTlvTagValuePair();
	freeTlvList(); //Lost All Parsed Data

How to build

	uint32 tlvListBufferLength;
	uint8* tlvBufferList;
	uint8 tag1Str[1] = "88";
	uint8 value1Str[] = "02";
	uint8 tag2Str[] = "5F2D";
	uint8 value2Str[] = "656E";	
	uint8 tag1[1], value1[1], tag2[2], value2[2];
	hex2bin(tag1Str, tag1, 2);
	hex2bin(value1Str, value1, 2);
	hex2bin(tag2Str, tag2 4);
	hex2bin(value2Str, value2, 4);
	
	initTlvListBuffer();
	initTlvList();
	addNexTlvToList(tag1, sizeof(tag1), value1, sizeof(value1));
	addNexTlvToList(tag2, sizeof(tag2), value2, sizeof(value2));
	tlvListBufferLength = buildTlvListBuffer();
	tlvBufferList = getTlvListBuffer();

	printAllOfTlvBuffers();	
	freeTlvList(); //Lost Of All TLV List
	freeTlvListBuffer();//Lost Build of Buffer Data

More Information

For more information and how to build nested TLVs refer to test units written in main.c.

Written By H.assaran with Code Blocks 17.12 IDE and MINGW compiler

ber-tlv's People

Contributors

hosseinassaran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.