From 7cb0c022d2e3219560bae461d2a35641506094f8 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 24 Oct 2023 18:07:20 +0200 Subject: [PATCH] Create a PIN upon initialization --- hwb1/src/hwb1/MyApplet.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java index a43e9e6..7dc89d5 100644 --- a/hwb1/src/hwb1/MyApplet.java +++ b/hwb1/src/hwb1/MyApplet.java @@ -12,8 +12,11 @@ import javacard.framework.*; * @author */ 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[] storage = new byte[] {}; + OwnerPIN pin; /** * Installs this applet. @@ -23,13 +26,19 @@ public class MyApplet extends Applet { * @param bLength the length in bytes of the parameter data in bArray */ 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. + * + * @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(); }