Git Product home page Git Product logo

apdu-library's Introduction

APDU Library

Library built on top of libNfc, that allows to easily send APDU commands through a terminal.

Compile

Enter the repo directory then simply :

make

Dependency : Libnfc

This code uses libnfc

If you're on Linux, you can install libnfc simply by doing :

git clone https://github.com/nfc-tools/libnfc.git
autoreconf -vis
./configure --enable-doc
make
sudo make install

Notice

The code contains an implementation of the APDU protocol according to Wikipedia. However, I'm not entierly sure if I implemented correctly the extended apdu protocol. The PN532 doesn't support it anyway...

How to use

Use the NfcManager to simplify the process of detecting, opening and transceiving data.

NfcManager manager;
if(manager.open()){
    if(manager.isTargetPresent()){
        // do things ...
    }
    manager.close();
}

Once the device opened, use the APDU class to send and receive APDUs commands. If you want to perform a select command, you would do :

APDU apdu;
apdu.setClass(0x00);
apdu.setInstruction(0xA4);
apdu.setParams(0x04, 0x00);
apdu.setCmd(hexStringToByteArray(appId));
apdu.buildAPDU();
manager.transceive(apdu);

To know more about APDUs instruction codes etc, read the beautiful ISO standard

When manager.transceive() ends, the APDU object will contain the response, if any. You can get it like this :

std::vector<uint8_t> responseBytes = apdu.getRespBytes();
std::string responseString = apdu.getRespString();

That said, NfcManager already implements the select command, you just need to do this :

manager.selectApplication(appId, apdu);

Examples

You can find a full examples here.

apdu-library's People

Contributors

omaraflak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.