Create a PIN upon initialization

This commit is contained in:
Manuel Thalmann 2023-10-24 18:07:20 +02:00
parent 5d679cccc1
commit 7cb0c022d2

View file

@ -12,8 +12,11 @@ import javacard.framework.*;
* @author <user> * @author <user>
*/ */
public class MyApplet extends Applet { public class MyApplet extends Applet {
final static byte PIN_TRY_LIMIT =(byte)0x03;
final static byte MAX_PIN_SIZE =(byte)0x08;
private byte[] authorName = new byte[] { 'M', 'a', 'n', 'u', 'e', 'l' }; private byte[] authorName = new byte[] { 'M', 'a', 'n', 'u', 'e', 'l' };
private byte[] storage = new byte[] {}; private byte[] storage = new byte[] {};
OwnerPIN pin;
/** /**
* Installs this applet. * Installs this applet.
@ -23,13 +26,19 @@ public class MyApplet extends Applet {
* @param bLength the length in bytes of the parameter data in bArray * @param bLength the length in bytes of the parameter data in bArray
*/ */
public static void install(byte[] bArray, short bOffset, byte bLength) { public static void install(byte[] bArray, short bOffset, byte bLength) {
new MyApplet(); new MyApplet(byte[] bArray, short bOffset, byte bLength);
} }
/** /**
* Only this class's install method should create the applet object. * Only this class's install method should create the applet object.
*
* @param bArray the array containing installation parameters
* @param bOffset the starting offset in bArray
* @param bLength the length in bytes of the parameter data in bArray
*/ */
protected MyApplet() { protected MyApplet(byte[] bArray, short bOffset, byte bLength) {
pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
pin.update(bArray, bOffset, bLength);
register(); register();
} }