Giter Site home page Giter Site logo

wxleong / secora-blockchain-apdu Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 50 KB

The secora-blockchain-apdu library is a Java package designed to handle the APDU commands of Infineon's SECORA™ Blockchain and Blockchain Security 2Go starter kit.

License: MIT License

Java 100.00%

secora-blockchain-apdu's Introduction

Github actions

Introduction

The secora-blockchain-apdu library is a Java package designed to handle the APDU commands of Infineon's SECORA™ Blockchain and Blockchain Security 2Go starter kit. It was derived from the project BlockchainSecurity2Go-Android@085aa39.

Library Import Guide

To evaluate the library, you can import it into your project using the JitPack package repository.

User Guide for Android Application

To incorporate the library into an Android application, the IsoDep object needs to be wrapped within the NfcTransceiver interface. Here's an example:

import android.nfc.tech.IsoDep;
import com.github.infineon.NfcTranceiver;

import java.io.IOException;

/**
 * Wraps IsoDep tag into NfcTranceiver interface.
 * (this wrapper is used so that the com.github.infineon package
 * doesn't have any Android dependencies)
 */
public class IsoTagWrapper implements NfcTranceiver {

    private final IsoDep isoDep;

    private IsoTagWrapper(IsoDep isoDep) {
        this.isoDep = isoDep;
    }

    /**
     * Create wrapper of given IsoDep tag.
     *
     * @param isoDep
     * @return wrapper instance
     */
    public static IsoTagWrapper of(IsoDep isoDep) {
        return new IsoTagWrapper(isoDep);
    }

    /**
     * Sends a command APDU to the NFC card and returns the received response APDU.
     *
     * @param commandApdu command APDU to send
     * @return bytes received as response
     * @throws IOException in case of communication errors
     */
    @Override
    public byte[] transceive(byte[] commandApdu) throws IOException {

        if (!isoDep.isConnected()) {
            isoDep.connect();
        }
        return isoDep.transceive(commandApdu);
    }
}

Here's an example of how to read the public key from a SECORA™ Blockchain contactless card:

public void readPublicKey() {
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    IsoDep isoDep = IsoDep.get(tag); // ISO 14443-4 Type A & B
    String pubkey = com.github.infineon
                       .NfcUtils.readPublicKeyOrCreateIfNotExists(
                           IsoTagWrapper.of(isoDep), 1
                       ).getPublicKeyInHexWithoutPrefix();
    isoDep.close();
}

Implementation Examples

License

This project is licensed under the MIT License - see the LICENSE file for details.

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.