From 8f7e657a9c146ef6a8b508591d35592fe9b93ba4 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 12 Oct 2023 19:23:38 +0200 Subject: [PATCH] Add an instruction for querying the author name --- hwb1/scripts/MyApplet.script | 2 ++ hwb1/src/hwb1/MyApplet.java | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 hwb1/scripts/MyApplet.script diff --git a/hwb1/scripts/MyApplet.script b/hwb1/scripts/MyApplet.script new file mode 100644 index 0000000..b94f472 --- /dev/null +++ b/hwb1/scripts/MyApplet.script @@ -0,0 +1,2 @@ +// Query Author Name +0x80 0x00 0x00 0x00 0x00 0x7F; diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java index 4231487..efd3489 100644 --- a/hwb1/src/hwb1/MyApplet.java +++ b/hwb1/src/hwb1/MyApplet.java @@ -53,6 +53,22 @@ public class MyApplet extends Applet { */ @Override public void process(APDU apdu) { - //Insert your code here + short responseLength; + byte[] buffer = apdu.getBuffer(); + + byte instruction = buffer[ISO7816.OFFSET_INS]; + + switch (instruction) { + case 0x00: + responseLength = apdu.setOutgoing(); + + if (responseLength > MyAppletStrings.AuthorName.length) { + responseLength = (short)MyAppletStrings.AuthorName.length; + } + + apdu.setOutgoingLength(responseLength); + apdu.sendBytesLong(MyAppletStrings.AuthorName, (short)0, responseLength); + break; + } } }