From 6b839f84b0b6d07b459c68a6422a272207725c3b Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 12 Oct 2023 17:20:28 +0200 Subject: [PATCH] Initialize a new Java Card project --- hwb1/.classpath | 16 +++ hwb1/.gen/.gitignore | 1 + hwb1/.gen/hwb1/MyAppletStrings.java | 8 ++ hwb1/.javacard_project | 29 +++++ hwb1/.project | 28 +++++ hwb1/apdu_scripts/cap-hwb1.script | 66 ++++++++++++ .../create-hwb1.hwb1.MyApplet.script | 15 +++ hwb1/apdu_scripts/digest-hwb1.txt | 12 +++ .../select-hwb1.hwb1.MyApplet.script | 12 +++ hwb1/configurations/hwb1.conf | 9 ++ hwb1/configurations/hwb1.scriptgen | 5 + hwb1/deliverables/hwb1/hwb1/javacard/hwb1.cap | Bin 0 -> 5306 bytes hwb1/deliverables/hwb1/hwb1/javacard/hwb1.exp | Bin 0 -> 33 bytes hwb1/deliverables/hwb1/hwb1/javacard/hwb1.jca | 102 ++++++++++++++++++ hwb1/src/hwb1/MyApplet.java | 57 ++++++++++ 15 files changed, 360 insertions(+) create mode 100644 hwb1/.classpath create mode 100644 hwb1/.gen/.gitignore create mode 100644 hwb1/.gen/hwb1/MyAppletStrings.java create mode 100644 hwb1/.javacard_project create mode 100644 hwb1/.project create mode 100644 hwb1/apdu_scripts/cap-hwb1.script create mode 100644 hwb1/apdu_scripts/create-hwb1.hwb1.MyApplet.script create mode 100644 hwb1/apdu_scripts/digest-hwb1.txt create mode 100644 hwb1/apdu_scripts/select-hwb1.hwb1.MyApplet.script create mode 100644 hwb1/configurations/hwb1.conf create mode 100644 hwb1/configurations/hwb1.scriptgen create mode 100644 hwb1/deliverables/hwb1/hwb1/javacard/hwb1.cap create mode 100644 hwb1/deliverables/hwb1/hwb1/javacard/hwb1.exp create mode 100644 hwb1/deliverables/hwb1/hwb1/javacard/hwb1.jca create mode 100644 hwb1/src/hwb1/MyApplet.java diff --git a/hwb1/.classpath b/hwb1/.classpath new file mode 100644 index 0000000..d1f9706 --- /dev/null +++ b/hwb1/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/hwb1/.gen/.gitignore b/hwb1/.gen/.gitignore new file mode 100644 index 0000000..20b9cb5 --- /dev/null +++ b/hwb1/.gen/.gitignore @@ -0,0 +1 @@ +/hwb1/ diff --git a/hwb1/.gen/hwb1/MyAppletStrings.java b/hwb1/.gen/hwb1/MyAppletStrings.java new file mode 100644 index 0000000..59f9942 --- /dev/null +++ b/hwb1/.gen/hwb1/MyAppletStrings.java @@ -0,0 +1,8 @@ +package hwb1; + +final class MyAppletStrings { + + static final byte[] Package = new byte[] {0x68, 0x77, 0x62, 0x31, }; + static final byte[] AppletName = new byte[] {0x4d, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x74, }; + +} diff --git a/hwb1/.javacard_project b/hwb1/.javacard_project new file mode 100644 index 0000000..01d0ddb --- /dev/null +++ b/hwb1/.javacard_project @@ -0,0 +1,29 @@ + + + + src/hwb1 + + + IsJavaCardPackage + 1 + + + AID + 52C4C7C95C1337 + + + + + src/hwb1/MyApplet.java + + + AID + 52C4C7C95C0420 + + + IsJavaCardApplet + 1 + + + + diff --git a/hwb1/.project b/hwb1/.project new file mode 100644 index 0000000..34370ec --- /dev/null +++ b/hwb1/.project @@ -0,0 +1,28 @@ + + + hwb1 + + + + + + com.oracle.javacard.jcdk.core.projectbuild.JCDKCleanBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.oracle.javacard.jcdk.core.projectbuild.JCDKBuilder + + + + + + org.eclipse.jdt.core.javanature + com.oracle.javacard.jcdk.core.projectbuild.JCDKNature + + diff --git a/hwb1/apdu_scripts/cap-hwb1.script b/hwb1/apdu_scripts/cap-hwb1.script new file mode 100644 index 0000000..a500a4e --- /dev/null +++ b/hwb1/apdu_scripts/cap-hwb1.script @@ -0,0 +1,66 @@ +// Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + +// Cap File Installation APDU Script +// +// Package: hwb1.hwb1 +// Package AID: //aid/52C4C7C95C/1337 +// + +powerup; + +// Select the installer applet +0x00 0xA4 0x04 0x00 0x09 0xA0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F; +0x80 0xB0 0x00 0x00 0x00 0x7F; + +// hwb1/javacard/Header.cap +0x80 0xB2 0x01 0x00 0x00 0x7F; +0x80 0xB4 0x01 0x00 0x15 0x01 0x00 0x12 0xDE 0xCA 0xFF 0xED 0x03 0x02 0x04 0x00 0x01 0x07 0x52 0xC4 0xC7 0xC9 0x5C 0x13 0x37 0x00 0x7F; +0x80 0xBC 0x01 0x00 0x00 0x7F; + +// hwb1/javacard/Directory.cap +0x80 0xB2 0x02 0x00 0x00 0x7F; +0x80 0xB4 0x02 0x00 0x20 0x02 0x00 0x25 0x00 0x12 0x00 0x25 0x00 0x0B 0x00 0x15 0x00 0x16 0x00 0x23 0x00 0x1F 0x00 0x1C 0x00 0x09 0x00 0x00 0x00 0x68 0x02 0x29 0x00 0x00 0x00 0x00 0x00 0x7F; +0x80 0xB4 0x02 0x00 0x08 0x04 0x00 0x02 0x00 0x0C 0x02 0x01 0x00 0x7F; +0x80 0xBC 0x02 0x00 0x00 0x7F; + +// hwb1/javacard/Import.cap +0x80 0xB2 0x04 0x00 0x00 0x7F; +0x80 0xB4 0x04 0x00 0x18 0x04 0x00 0x15 0x02 0x08 0x01 0x07 0xA0 0x00 0x00 0x00 0x62 0x01 0x01 0x00 0x01 0x07 0xA0 0x00 0x00 0x00 0x62 0x00 0x01 0x7F; +0x80 0xBC 0x04 0x00 0x00 0x7F; + +// hwb1/javacard/Applet.cap +0x80 0xB2 0x03 0x00 0x00 0x7F; +0x80 0xB4 0x03 0x00 0x0E 0x03 0x00 0x0B 0x01 0x07 0x52 0xC4 0xC7 0xC9 0x5C 0x04 0x20 0x00 0x01 0x7F; +0x80 0xBC 0x03 0x00 0x00 0x7F; + +// hwb1/javacard/Class.cap +0x80 0xB2 0x06 0x00 0x00 0x7F; +0x80 0xB4 0x06 0x00 0x20 0x06 0x00 0x23 0x00 0x00 0x00 0x80 0x03 0x00 0xFF 0x00 0x07 0x01 0x00 0x00 0x00 0x15 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x00 0x81 0x00 0x00 0xFF 0x00 0x7F; +0x80 0xB4 0x06 0x00 0x06 0x01 0x00 0x00 0x00 0x00 0x01 0x7F; +0x80 0xBC 0x06 0x00 0x00 0x7F; + +// hwb1/javacard/Method.cap +0x80 0xB2 0x07 0x00 0x00 0x7F; +0x80 0xB4 0x07 0x00 0x20 0x07 0x00 0x1F 0x00 0x01 0x30 0x8F 0x00 0x01 0x8C 0x00 0x00 0x7A 0x01 0x10 0x18 0x8C 0x00 0x02 0x18 0x8B 0x00 0x03 0x7A 0x00 0x20 0x7A 0x01 0x10 0x18 0x8C 0x00 0x7F; +0x80 0xB4 0x07 0x00 0x02 0x04 0x7A 0x7F; +0x80 0xBC 0x07 0x00 0x00 0x7F; + +// hwb1/javacard/StaticField.cap +0x80 0xB2 0x08 0x00 0x00 0x7F; +0x80 0xB4 0x08 0x00 0x1F 0x08 0x00 0x1C 0x00 0x04 0x00 0x02 0x00 0x02 0x03 0x00 0x04 0x68 0x77 0x62 0x31 0x03 0x00 0x08 0x4D 0x79 0x41 0x70 0x70 0x6C 0x65 0x74 0x00 0x00 0x00 0x00 0x7F; +0x80 0xBC 0x08 0x00 0x00 0x7F; + +// hwb1/javacard/ConstantPool.cap +0x80 0xB2 0x05 0x00 0x00 0x7F; +0x80 0xB4 0x05 0x00 0x19 0x05 0x00 0x16 0x00 0x05 0x06 0x00 0x00 0x0A 0x01 0x00 0x02 0x00 0x06 0x80 0x03 0x00 0x03 0x80 0x03 0x01 0x06 0x81 0x00 0x00 0x7F; +0x80 0xBC 0x05 0x00 0x00 0x7F; + +// hwb1/javacard/RefLocation.cap +0x80 0xB2 0x09 0x00 0x00 0x7F; +0x80 0xB4 0x09 0x00 0x0C 0x09 0x00 0x09 0x00 0x00 0x00 0x05 0x04 0x03 0x07 0x04 0x0A 0x7F; +0x80 0xBC 0x09 0x00 0x00 0x7F; + +0x80 0xBA 0x00 0x00 0x00 0x7F; + + +//powerdown; diff --git a/hwb1/apdu_scripts/create-hwb1.hwb1.MyApplet.script b/hwb1/apdu_scripts/create-hwb1.hwb1.MyApplet.script new file mode 100644 index 0000000..b6218ae --- /dev/null +++ b/hwb1/apdu_scripts/create-hwb1.hwb1.MyApplet.script @@ -0,0 +1,15 @@ +// Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + +// Applet Instantiation APDU Script +// +// Package: hwb1.hwb1 +// Package AID: //aid/52C4C7C95C/1337 +// Applet: hwb1.MyApplet +// Applet AID: //aid/52C4C7C95C/0420 +// + +// Select the installer applet +0x00 0xA4 0x04 0x00 0x09 0xA0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F; + +// Create hwb1.MyApplet applet +0x80 0xB8 0x00 0x00 0x09 0x07 0x52 0xC4 0xC7 0xC9 0x5C 0x04 0x20 0x00 0x7F; diff --git a/hwb1/apdu_scripts/digest-hwb1.txt b/hwb1/apdu_scripts/digest-hwb1.txt new file mode 100644 index 0000000..ccaf5d9 --- /dev/null +++ b/hwb1/apdu_scripts/digest-hwb1.txt @@ -0,0 +1,12 @@ +Digest for hwb1/javacard/ConstantPool.cap [SHA-256: 6c5bf615cd3746d52c815e8264b910a41a94217161862a7520087799fd03098b] +Digest for hwb1/javacard/Debug.cap [SHA-256: 0247d72e4a6b685f23bc380c218522f6e8906d38158579ad5c57177ae67f18cc] +Digest for hwb1/javacard/Directory.cap [SHA-256: a38a6a20b2537681a3697a2d003fbc480d4b529618a7dfae8eeeff8fd952514e] +Digest for hwb1/javacard/RefLocation.cap [SHA-256: b2b3f5e23eee662b8c406212d5cb291959a8eeddb92e58b9a45941c0b91388be] +Digest for hwb1/javacard/Applet.cap [SHA-256: 0aefcbcd7c0a951f88b522d9a840fb851c15c1f92cf8cd2ac55ec1d188e9687b] +Digest for hwb1/javacard/Descriptor.cap [SHA-256: ae5b4ee1c0c7b98f7916a7a75e0521e7ae1450d1a13897f8f92764503edc8db9] +Digest for hwb1/javacard/Class.cap [SHA-256: af7f91359fc2e4feefa1653905001e7589a5cb1d241c960b99d749f3e828f366] +Digest for hwb1/javacard/Import.cap [SHA-256: 8cc3642a6d49023dc39aece31584cf15757e6bbcbc1e299514366eae84efce86] +Digest for hwb1/javacard/Method.cap [SHA-256: 651231359c6bb65fbcb0e3a49f52cee1a682ed7e97610365b374583638757365] +Digest for hwb1/javacard/Header.cap [SHA-256: 30bc8192745192eecda697856d62c5d7734b17897944959c6c8876caf6949e41] +Digest for hwb1/javacard/StaticField.cap [SHA-256: 983c0b9dbdc069d517cb18c91ff8d9816b50f1f949ca135f828fcaa4faca3b2e] +Verification completed with 0 warnings and 0 errors. diff --git a/hwb1/apdu_scripts/select-hwb1.hwb1.MyApplet.script b/hwb1/apdu_scripts/select-hwb1.hwb1.MyApplet.script new file mode 100644 index 0000000..f9953eb --- /dev/null +++ b/hwb1/apdu_scripts/select-hwb1.hwb1.MyApplet.script @@ -0,0 +1,12 @@ +// Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + +// Applet Selection APDU Script +// +// Package: hwb1.hwb1 +// Package AID: //aid/52C4C7C95C/1337 +// Applet: hwb1.MyApplet +// Applet AID: //aid/52C4C7C95C/0420 +// + +// Select hwb1.MyApplet applet +0x00 0xA4 0x04 0x00 0x07 0x52 0xC4 0xC7 0xC9 0x5C 0x04 0x20 0x7F; diff --git a/hwb1/configurations/hwb1.conf b/hwb1/configurations/hwb1.conf new file mode 100644 index 0000000..e093435 --- /dev/null +++ b/hwb1/configurations/hwb1.conf @@ -0,0 +1,9 @@ +-i +-classdir ..\bin +-applet 0x52:0xC4:0xC7:0xC9:0x5C:0x04:0x20 hwb1.MyApplet +-out CAP JCA EXP +-d ..\deliverables\hwb1 +-debug +-target 3.1.0 +hwb1 +0x52:0xC4:0xC7:0xC9:0x5C:0x13:0x37 1.0 diff --git a/hwb1/configurations/hwb1.scriptgen b/hwb1/configurations/hwb1.scriptgen new file mode 100644 index 0000000..be348a2 --- /dev/null +++ b/hwb1/configurations/hwb1.scriptgen @@ -0,0 +1,5 @@ +#Thu Oct 12 17:03:08 CEST 2023 +SCRIPTGEN_NO_POWER_UP=false +SCRIPTGEN_NO_POWER_DOWN=true +SCRIPTGEN_NO_BANNER=false +SCRIPTGEN_NO_BEGIN_END=false diff --git a/hwb1/deliverables/hwb1/hwb1/javacard/hwb1.cap b/hwb1/deliverables/hwb1/hwb1/javacard/hwb1.cap new file mode 100644 index 0000000000000000000000000000000000000000..e7c63e20eda9cc8a63cc6df46e7f967a2187470d GIT binary patch literal 5306 zcmd^DeQXow8Gr81_BoCNCgg*x8Mx+SAtOGAkO4^ubrLc{oYY|R5$HzG_K}!4w(D~U zNu~)DkWkAsV04VJigi`Dj;>QFRp}^9KwCQ4s&+`Ns!A=;siW0InS{1>A5Hc=ceXEg zChhk34DZGFe*E6&eV*U@eAwT~nM%NFwL)^AZzD|llz<7kRt3E^9o_9hm$$p4eN`an z?rI;u0@G_j&nmlpE&TuY&Oce&bAxjZx0POKKQGfqqX}=4mm2mwfpuz-hX1#mP>El?7u$x zX=tveyx~IAk8h0Z+8q4N;a5+z1fu@?*1lO-P*~CWomqlo{^9!VcVgVT=Py@&H2m`B zx5tj$8LoRQ5o8sizOFxv|=}rRd`^=Jl?BkFQ*re!2O%TUQUn zq}RM}c(1i=+-&`k`R0cwmz-F-du+v>NcpXe@`4YGS3Fev?nk3%U)b?txZ(NFUU%(# zy6@um!VA1b<(s zPqV+1x7Jnvp?ib@=;HwVXg?c(6%_kj?EUfZN3}mfc`Drt^qsT7Y2G%JV^EqAU}d1@#7iC=ml~AujlteUcI>5= zkGxLW=1YVTJrO6d3ltKWO&o8s=>^CHqiR>hlLZl&TkHu-g zAtHl>_6s51;ml34FtUjKlPN zt)&khXP(sySyk7uY!PltE#L5MQfRQ3P+-B#V`}6E0-6RK?zPQSDd6GVmTrx9K)yj4gDnUiMN?W zG3X44MBa#4X97-7ur+Tie{nfZp+*ir7p${(a_=07HLb*lbBC0Y@m8&H)w(?{rxXt- zBB=iruJyt8nq{t)&9J=7yJhj56E?*$rCk==-3R&Y}Nn0#O8)RiHd;fDNB-d1% zJKb&}_dk*d%Yq6b3(i7+ zbq8-mfJ~HOzBtSv0>v5B!IXi90b3w3m0D~{QzEax*0o&tvI`so|_dX@qPh7uLF5&x3!FQ`5ZCDkuL zsRlev0iq~EF=UYfZdWH`G$5bPU|MhwK1sfMY~+0y4S+-kj42c@%GANkLRwmh=@sow zX)FtK^nt@#c=RVXa5c3WobYAL%!Xn;L1!rhy=z=oc$yd6@hF)vo*~hsV2(6t3dfXm zB+E;Mx0J8hDeJN*nVTK8VfpVVtL8Vv$eDJG&;>aLPLVno$aD8x#DgLchgeiMF^F<+ zluGHLY=8vCiVTuyTl)C;v(_HY(HHD7IfjBgW=AO4V{z05PeGx>stk3}&@c^oX($=& z;pt&@#DYBzi$lUE??~fC_@ox zgff()V; + // 1 + .classRef MyApplet; + // 2 + staticMethodRef 0.3.0()V; // javacard/framework/Applet.()V + // 3 + virtualMethodRef 0.3.1()V; // register()V + // 4 + staticMethodRef 1.0.0()V; // java/lang/Object.()V + } + + .class public MyApplet 0 extends 0.3 { // extends javacard/framework/Applet + + .publicMethodTable 7 8 { + equals(Ljava/lang/Object;)Z 0; + register()V 1; + register([BSB)V 2; + selectingApplet()Z 3; + deselect()V 4; + getShareableInterfaceObject(Ljavacard/framework/AID;B)Ljavacard/framework/Shareable; 5; + select()Z 6; + process(Ljavacard/framework/APDU;)V 7; + } + + .packageMethodTable 0 { + } + + .method public static install([BSB)V 0 { + .stack 1; + .locals 0; + + L0: new 1; // hwb1/MyApplet + invokespecial 0; // hwb1/MyApplet.()V + return; + } + + .method protected ()V 1 { + .stack 1; + .locals 0; + + L0: aload_0; + invokespecial 2; // javacard/framework/Applet.()V + aload_0; + invokevirtual 3; // register()V + return; + } + + .method public process(Ljavacard/framework/APDU;)V 7 { + .stack 0; + .locals 0; + + .descriptor Ljavacard/framework/APDU; 0.10; + + L0: return; + } + + } + + .class final MyAppletStrings extends 1.0 { // extends java/lang/Object + + .fields { + static final byte[] Package = {104,119,98,49}; // [B + static final byte[] AppletName = {77,121,65,112,112,108,101,116}; // [B + } + + .publicMethodTable 1 1 { + equals(Ljava/lang/Object;)Z 0; + } + + .packageMethodTable 0 { + } + + .method ()V { + .stack 1; + .locals 0; + + L0: aload_0; + invokespecial 4; // java/lang/Object.()V + return; + } + + } + +} diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java new file mode 100644 index 0000000..ac9d92d --- /dev/null +++ b/hwb1/src/hwb1/MyApplet.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * + */ + + +package hwb1; + +import javacard.framework.*; +import javacardx.annotations.*; +import static hwb1.MyAppletStrings.*; + +/** + * Applet class + * + * @author + */ +@StringPool(value = { + @StringDef(name = "Package", value = "hwb1"), + @StringDef(name = "AppletName", value = "MyApplet")}, + // Insert your strings here + name = "MyAppletStrings") +public class MyApplet extends Applet { + + /** + * Installs this applet. + * + * @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 + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + new MyApplet(); + } + + /** + * Only this class's install method should create the applet object. + */ + protected MyApplet() { + register(); + } + + /** + * Processes an incoming APDU. + * + * @see APDU + * @param apdu + * the incoming APDU + */ + @Override + public void process(APDU apdu) { + //Insert your code here + } +}