arekinath / YkOtpApplet

Javacard applet emulating the Yubikey challenge-response interface
17 stars 9 forks source link

Add and document app-init helper script #6

Open BryanJacobs opened 2 years ago

BryanJacobs commented 2 years ago

I'm well aware this repository hasn't been updated in five years, and I can see a valid-looking PR already open to fix a bug, so I don't anticipate this PR will be merged. Nonetheless I hope this will help someone who uses the working code in this repository.

The applet here can generate HMAC challenge-response codes on a JavaCard that isn't a Yubikey. When you set it up that way, you need to get the "slot config" - the HMAC secret - into the applet somehow.

This pull request contains a simple Python script that will emit the correct ADPUs to program an arbitrary JavaCard with an HMAC secret of the user's choice. I had to learn ISO7816 to write this script; perhaps with it in hand, someone else can skip that journey of discovery and make easier use of their own smartcard.

Documentation for the use of the script is also included.

jkingsman commented 1 year ago

Thanks so much for this!

I had trouble getting Python to behave with

with open(0, 'rb') as f:
    raw_key = f.read(20)

so I just had it read from random directly and replaced that block with

import os
raw_key = os.urandom(20)