From 39948e42f260ce51d33b381c81f071ef248e8ed5 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 13 Oct 2023 01:20:36 +0200 Subject: [PATCH] Add an instruction for querying stored data --- hwb1/src/hwb1/MyApplet.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java index 515f49a..0b37194 100644 --- a/hwb1/src/hwb1/MyApplet.java +++ b/hwb1/src/hwb1/MyApplet.java @@ -60,14 +60,23 @@ public class MyApplet extends Applet { switch (instruction) { case 0x00: + case 0x04: + byte[] response; length = apdu.setOutgoing(); + + if (instruction == 0x00) { + response = AuthorName; + } + else { + response = storage; + } - if (length > AuthorName.length) { - length = (short)AuthorName.length; + if (length > response.length) { + length = (short)response.length; } apdu.setOutgoingLength(length); - apdu.sendBytesLong(AuthorName, (short)0, length); + apdu.sendBytesLong(response, (short)0, length); break; case 0x02: length = apdu.setIncomingAndReceive();