Skip to content

nightcode/jcconnect

Repository files navigation

JavaCard Connect

Build Status Maven Central

JavaCard Connect is a framework which provides an implementation of a secure communication protocol in conformance with the Global Platform Card Specification. It allows to establish a secure channel between an off-card entity and a card.

How to use

code

  TerminalFactory tf = TerminalFactory.getInstance("PC/SC", null);
  CardTerminals terminals = tf.terminals();
  CardTerminal terminal = terminals.list(CardTerminals.State.CARD_PRESENT).get(0);
  Card card = terminal.connect("*");

  CardChannelService service = new CardChannelServiceImpl(KeyProvider.DEFAULT); 


  CardProperties cardProperties = CardProperties.builder()
      .aid(Aid.parse("A000000151000000"))
      .keyVersionNumber((byte) 0xFF)
      .scpVersion(ScpVersion.SCP_02)
      .build();

  CardChannelContext context = service.createCardChannelContext(cardProperties, new PlainApduChannel(card.getBasicChannel()));
  SecureChannelSession channelSession = service.createSecureChannelSession(context);

  channelSession.openSecureChannel(EnumSet.of(SecurityLevel.C_MAC));

  // GET STATUS command
  CommandAPDU command = new CommandAPDU(0x80, 0xF2, 0x40, 0x00, new byte[] {0x4F, 0x00});
  ResponseAPDU response = channelSession.transmit(command);

Download

Download the latest jar via Maven:

<dependency>
  <groupId>org.nightcode</groupId>
  <artifactId>jc-connect</artifactId>
  <version>0.1.10</version>
</dependency>

License


Feedback is welcome. Please don't hesitate to open up a new github issue or simply drop me a line at dmitry@nightcode.org.

About

JavaCard Connect is a framework which provides an implementation of a secure communication protocol in conformance with the Global Platform Card Specification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages