Blame SOURCES/pki-core-BASE-format-G-and-D-cards.patch

dd68f4
From 618a17ad33363633c6589c4ce7170c34f21bf459 Mon Sep 17 00:00:00 2001
dd68f4
From: Jack Magne <jmagne@dhcp-16-206.sjc.redhat.com>
dd68f4
Date: Tue, 15 Nov 2016 17:37:07 -0800
dd68f4
Subject: [PATCH] Change lifecycle at end of enrollment if it is not already
dd68f4
 set.
dd68f4
dd68f4
TPS throws "err=6" when attempting to format and enroll G&D Cards.
dd68f4
https://bugzilla.redhat.com/show_bug.cgi?id=1320283
dd68f4
dd68f4
This fix addresses this bug , but also:
dd68f4
Fixes this issue:
dd68f4
dd68f4
Applet upgrade during rekey operation results in formatted token.
dd68f4
dd68f4
 Also, it takes care of a related issue where the new apdu needed for the
dd68f4
lifecycle state causes the testing tool "tpslcient" to seg fault.
dd68f4
The fix here is a minimal fix to have tpsclient return an error when it gets
dd68f4
this apdu it can't handle, instead of crashing.
dd68f4
dd68f4
(cherry picked from commit 4027d3caa872f2950dae0b3d2208c0c54ceb4a4c)
dd68f4
(cherry picked from commit fbb7cf7d70263aa63274a41ecba235bc87c961f0)
dd68f4
---
dd68f4
 base/common/src/org/dogtagpki/tps/apdu/APDU.java   |  3 +-
dd68f4
 .../org/dogtagpki/tps/apdu/GetLifecycleAPDU.java   | 35 +++++++++++++
dd68f4
 2 files changed, 37 insertions(+), 1 deletions(-)
dd68f4
 create mode 100644 base/common/src/org/dogtagpki/tps/apdu/GetLifecycleAPDU.java
dd68f4
dd68f4
diff --git a/base/common/src/org/dogtagpki/tps/apdu/APDU.java b/base/common/src/org/dogtagpki/tps/apdu/APDU.java
dd68f4
index 86f07ee..390252f 100644
dd68f4
--- a/base/common/src/org/dogtagpki/tps/apdu/APDU.java
dd68f4
+++ b/base/common/src/org/dogtagpki/tps/apdu/APDU.java
dd68f4
@@ -56,7 +56,8 @@ public abstract class APDU {
dd68f4
         APDU_IMPORT_KEY_ENC,
dd68f4
         APDU_SET_ISSUERINFO,
dd68f4
         APDU_GET_ISSUERINFO,
dd68f4
-        APDU_GENERATE_KEY_ECC
dd68f4
+        APDU_GENERATE_KEY_ECC,
dd68f4
+        APDU_GET_LIFECYCLE
dd68f4
     }
dd68f4
 
dd68f4
     protected byte cla;
dd68f4
diff --git a/base/common/src/org/dogtagpki/tps/apdu/GetLifecycleAPDU.java b/base/common/src/org/dogtagpki/tps/apdu/GetLifecycleAPDU.java
dd68f4
new file mode 100644
dd68f4
index 0000000..6f55b01
dd68f4
--- /dev/null
dd68f4
+++ b/base/common/src/org/dogtagpki/tps/apdu/GetLifecycleAPDU.java
dd68f4
@@ -0,0 +1,35 @@
dd68f4
+package org.dogtagpki.tps.apdu;
dd68f4
+
dd68f4
+import org.dogtagpki.tps.main.TPSBuffer;
dd68f4
+
dd68f4
+
dd68f4
+public class GetLifecycleAPDU extends APDU {
dd68f4
+    public GetLifecycleAPDU() {
dd68f4
+        setCLA((byte) 0xB0);
dd68f4
+        setINS((byte) 0xf2);
dd68f4
+        setP1((byte) 0x0);
dd68f4
+        setP2((byte) 0x0);
dd68f4
+    }
dd68f4
+
dd68f4
+    @Override
dd68f4
+    public Type getType()
dd68f4
+    {
dd68f4
+        return Type.APDU_GET_LIFECYCLE;
dd68f4
+    }
dd68f4
+
dd68f4
+    @Override
dd68f4
+    public TPSBuffer getEncoding()
dd68f4
+    {
dd68f4
+        TPSBuffer encoding = new TPSBuffer();
dd68f4
+
dd68f4
+        encoding.add(cla);
dd68f4
+        encoding.add(ins);
dd68f4
+        encoding.add(p1);
dd68f4
+        encoding.add(p2);
dd68f4
+        encoding.add((byte) 0x01);
dd68f4
+
dd68f4
+        return encoding;
dd68f4
+    } /* Encode */
dd68f4
+
dd68f4
+
dd68f4
+}
dd68f4
-- 
dd68f4
1.8.3.1