From 8f2788eee56259edc6a86fab737c478db2f84fe6 Mon Sep 17 00:00:00 2001 From: Gregor Johannson Date: Wed, 27 Mar 2019 15:40:24 +0200 Subject: [PATCH] #153: Add tag '9E' before Delete Token --- src/main/java/pro/javacard/gp/DMTokenGenerator.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/pro/javacard/gp/DMTokenGenerator.java b/src/main/java/pro/javacard/gp/DMTokenGenerator.java index a29bcb38..17a8efc3 100644 --- a/src/main/java/pro/javacard/gp/DMTokenGenerator.java +++ b/src/main/java/pro/javacard/gp/DMTokenGenerator.java @@ -8,6 +8,8 @@ import java.security.PrivateKey; import java.security.Signature; +import static pro.javacard.gp.GlobalPlatform.INS_DELETE; + public class DMTokenGenerator { private static final Logger logger = LoggerFactory.getLogger(DMTokenGenerator.class); private static final String acceptedSignatureAlgorithm = "SHA1withRSA"; @@ -23,6 +25,11 @@ public CommandAPDU applyToken(CommandAPDU apdu) { try { newData.write(apdu.getData()); + if (apdu.getINS() == INS_DELETE || apdu.getINS() == (INS_DELETE & 255)) { + // See GP 2.3.1 Table 11-23 + logger.debug("Adding tag 0x9E before Delete Token"); + newData.write(0x9E); + } if (key == null) { logger.debug("No private key for token generation provided"); newData.write(0); //Token length