components/coolkey/patches/07-slot.h.patch
author Stephen Gaul Jr <steve.gaul@oracle.com>
Tue, 12 Jul 2016 17:34:11 -0700
changeset 6401 8e624b116c1d
permissions -rw-r--r--
PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices 22017764 Add Coolkey v1.1.0 to Userland consolidation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6401
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     1
Upstream fixes already included in the latest community updates to coolkey v1.1.0
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     2
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     3
Adds header definitions for newer CAC and PIV card support.
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     4
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     5
--- ORIGINAL/./src/coolkey/slot.h	2016-06-24 16:07:28.549068021 -0400
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     6
+++ ././src/coolkey/slot.h	2016-06-27 14:01:31.527689321 -0400
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     7
@@ -79,9 +79,11 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     8
     bool CUIDIsEqual(const CKYBuffer *cuid) const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
     9
     unsigned short getVersion() const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    10
     unsigned short getDataVersion() const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    11
+    unsigned char  getFirstCacCert() const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    12
     void setCUID(const CKYBuffer *cuid);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    13
     void setVersion(unsigned short version);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    14
     void setDataVersion(unsigned short version);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    15
+    void setFirstCacCert(unsigned char firstCacCert);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    16
     bool isValid() const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    17
     int size() const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    18
     const unsigned char *getCUID() const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    19
@@ -90,6 +92,7 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    20
     void setSize(int size);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    21
     void readData(CKYBuffer *data) const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    22
     void writeData(const CKYBuffer *data);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    23
+    void initCACHeaders(void);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    24
     void readCACCert(CKYBuffer *data, CKYByte instance) const;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    25
     void writeCACCert(const CKYBuffer *data, CKYByte instance);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    26
     void clearValid(CKYByte instance);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    27
@@ -211,24 +214,27 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    28
     State state;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    29
     CKYByte keyNum;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    30
     CKYBuffer result;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    31
+    PKCS11Object::KeyType keyType;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    32
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    33
-    CryptOpState() : state(NOT_INITIALIZED), keyNum(0) 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    34
+    CryptOpState() : state(NOT_INITIALIZED), keyNum(0), keyType(PKCS11Object::unknown)
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    35
 				{ CKYBuffer_InitEmpty(&result); }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    36
     CryptOpState(const CryptOpState &cpy) : 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    37
-				state(cpy.state), keyNum(cpy.keyNum) { 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    38
+				state(cpy.state), keyNum(cpy.keyNum), keyType(cpy.keyType) { 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    39
 	CKYBuffer_InitFromCopy(&result, &cpy.result);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    40
     }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    41
     CryptOpState &operator=(const CryptOpState &cpy) {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    42
 	state = cpy.state,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    43
 	keyNum = cpy.keyNum;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    44
+        keyType = cpy.keyType;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    45
 	CKYBuffer_Replace(&result, 0, CKYBuffer_Data(&cpy.result),
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    46
 				CKYBuffer_Size(&cpy.result));
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    47
 	return *this;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    48
     }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    49
     ~CryptOpState() { CKYBuffer_FreeData(&result); }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    50
-    void initialize(CKYByte keyNum) {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    51
+    void initialize(CKYByte keyNum, PKCS11Object::KeyType theKeyType) {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    52
         state = IN_PROCESS;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    53
         this->keyNum = keyNum;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    54
+        this->keyType = theKeyType;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    55
         CKYBuffer_Resize(&result, 0);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    56
     }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    57
 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    58
@@ -258,6 +264,7 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    59
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    60
     CryptOpState signatureState;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    61
     CryptOpState decryptionState;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    62
+    CryptOpState keyAgreementState;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    63
 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    64
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    65
 typedef list<Session> SessionList;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    66
@@ -267,13 +274,11 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    67
 class CryptParams {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    68
   private:
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    69
     unsigned int keySize; // in bits
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    70
-  protected:
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    71
-    unsigned int getKeySize() const { return keySize; }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    72
   public:
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    73
-    // !!!XXX hack. The right way to get the key size is to get all the
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    74
-    // key information from the token with MSCListKeys, the same way
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    75
-    // we get all the object information with MSCListObjects.
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    76
-    enum { FIXED_KEY_SIZE = 1024 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    77
+    // set the actual key size obtained from the card
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    78
+    void setKeySize(unsigned int newKeySize) { keySize = newKeySize; }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    79
+    unsigned int getKeySize() const { return keySize; }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    80
+    enum { DEFAULT_KEY_SIZE = 1024, ECC_DEFAULT_KEY_SIZE=256 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    81
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    82
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    83
     CryptParams(unsigned int keySize_) : keySize(keySize_) { }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    84
@@ -295,6 +300,13 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    85
 				 const CKYBuffer *paddedOutput) const = 0;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    86
 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    87
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    88
+#define MAX_CERT_SLOTS 10
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    89
+typedef enum {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    90
+    ALG_NONE= 0x0,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    91
+    ALG_ECC = 0x1,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    92
+    ALG_RSA = 0x2
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    93
+} SlotAlgs;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    94
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    95
 class Slot {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    96
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    97
   public:
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    98
@@ -304,12 +316,15 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
    99
         ATR_MATCH = 0x04,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   100
         APPLET_SELECTABLE = 0x08,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   101
         APPLET_PERSONALIZED = 0x10,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   102
-        CAC_CARD = 0x20
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   103
+        CAC_CARD = 0x20,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   104
+        PIV_CARD = 0x40
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   105
     };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   106
     enum {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   107
 	NONCE_SIZE = 8
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   108
     };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   109
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   110
+    static const SlotState GOV_CARD = (SlotState)(CAC_CARD|PIV_CARD);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   111
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   112
   private:
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   113
     Log *log;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   114
     char *readerName;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   115
@@ -329,6 +344,8 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   116
     CKYBuffer nonce;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   117
     CKYBuffer cardATR;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   118
     CKYBuffer mCUID;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   119
+    CKYBuffer cardAID[MAX_CERT_SLOTS];
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   120
+    unsigned short cardEF[MAX_CERT_SLOTS];
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   121
     bool isVersion1Key;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   122
     bool needLogin;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   123
     long publicFree;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   124
@@ -336,7 +353,12 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   125
     long privateFree;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   126
     bool fullTokenName;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   127
     bool mCoolkey;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   128
-
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   129
+    bool mOldCAC;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   130
+    bool mCACLocalLogin;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   131
+    int pivContainer;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   132
+    int pivKey;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   133
+    int maxCacCerts;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   134
+    SlotAlgs algs;
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   135
     //enum { RW_SESSION_HANDLE = 1, RO_SESSION_HANDLE = 2 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   136
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   137
 #ifdef USE_SHMEM
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   138
@@ -383,6 +405,7 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   139
     const CKYBuffer *getATR();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   140
     bool isLoggedIn();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   141
     bool needLoggedIn();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   142
+    bool getPIVLoginType();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   143
     void testNonce();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   144
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   145
     void addKeyObject(list<PKCS11Object>& objectList,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   146
@@ -392,6 +415,7 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   147
 	const CKYBuffer *derCert, CK_OBJECT_HANDLE handle);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   148
     void addObject(list<PKCS11Object>& objectList,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   149
         const ListObjectInfo& info, CK_OBJECT_HANDLE handle);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   150
+    PKCS11Object *createSecretKeyObject(CK_OBJECT_HANDLE handle, CKYBuffer *secretKeyBuffer,CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   151
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   152
     void ensureValidSession(SessionHandleSuffix suffix);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   153
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   154
@@ -399,8 +423,12 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   155
     list<ListObjectInfo> fetchCombinedObjects(const CKYBuffer *header);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   156
     list<ListObjectInfo> fetchSeparateObjects();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   157
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   158
+    CKYStatus getCACAid();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   159
+    CKYStatus readCACCertificateFirst(CKYBuffer *cert, CKYSize *nextSize);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   160
+    CKYStatus readCACCertificateAppend(CKYBuffer *cert, CKYSize nextSize);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   161
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   162
     void selectApplet();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   163
-    void selectCACApplet(CKYByte instance);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   164
+    void selectCACApplet(CKYByte instance,bool do_disconnect);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   165
     void unloadObjects();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   166
     void loadCACObjects();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   167
     void loadCACCert(CKYByte instance);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   168
@@ -422,14 +450,27 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   169
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   170
     void cryptRSA(SessionHandleSuffix suffix, CK_BYTE_PTR pInput,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   171
         CK_ULONG ulInputLen, CK_BYTE_PTR pOutput,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   172
-        CK_ULONG_PTR pulOutputLen, const CryptParams& params);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   173
+        CK_ULONG_PTR pulOutputLen, CryptParams& params);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   174
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   175
-    void performRSAOp(CKYBuffer *out, const CKYBuffer *input, CKYByte keyNum, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   176
-							     CKYByte direction);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   177
+    void performRSAOp(CKYBuffer *out, const CKYBuffer *input, unsigned int keySize,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   178
+						CKYByte keyNum, CKYByte direction);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   179
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   180
+    void signECC(SessionHandleSuffix suffix, CK_BYTE_PTR pInput,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   181
+        CK_ULONG ulInputLen, CK_BYTE_PTR pOutput,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   182
+        CK_ULONG_PTR pulOutputLen, CryptParams& params);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   183
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   184
+    void performECCSignature(CKYBuffer *out, const CKYBuffer *input, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   185
+					unsigned int keySize, CKYByte keyNum);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   186
+    void performECCKeyAgreement(CK_MECHANISM_TYPE deriveMech, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   187
+        CKYBuffer *publicDataBuffer, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   188
+        CKYBuffer *secretKeyBuffer, CKYByte keyNum, unsigned int keySize);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   189
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   190
     void processComputeCrypt(CKYBuffer *result, const CKYAPDU *apdu);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   191
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   192
     CKYByte objectHandleToKeyNum(CK_OBJECT_HANDLE hKey);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   193
+    unsigned int calcECCKeySize(CKYByte keyNum);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   194
+    void initCACShMem(void);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   195
+    void verifyCACShMem(void);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   196
     Slot(const Slot &cpy)
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   197
 #ifdef USE_SHMEM
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   198
 	: shmem(readerName)
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   199
@@ -460,6 +501,11 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   200
         return (char )((objectID >> 16) & 0xff) - '0';
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   201
     }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   202
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   203
+    // actually get the size of a key in bits from the card
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   204
+    unsigned int getRSAKeySize(CKYByte keyNum);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   205
+    unsigned int getECCKeySize(CKYByte keyNum);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   206
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   207
+    PKCS11Object::KeyType  getKeyTypeFromHandle(CK_OBJECT_HANDLE hKey);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   208
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   209
     SessionHandleSuffix openSession(Session::Type type);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   210
     void closeSession(SessionHandleSuffix handleSuffix);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   211
@@ -501,6 +547,16 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   212
 	CK_ULONG len);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   213
     void generateRandom(SessionHandleSuffix suffix, CK_BYTE_PTR data,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   214
 	CK_ULONG len);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   215
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   216
+    void derive(SessionHandleSuffix suffix, CK_MECHANISM_PTR pMechanism,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   217
+        CK_OBJECT_HANDLE hKey, CK_ATTRIBUTE_PTR pTemplate, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   218
+        CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   219
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   220
+    void deriveECC(SessionHandleSuffix suffix, CK_MECHANISM_PTR pMechanism,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   221
+       CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   222
+       CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey, CryptParams& params);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   223
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   224
+    SlotAlgs getAlgs() { return algs; }
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   225
 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   226
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   227
 class SlotList {
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   228
@@ -527,6 +583,8 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   229
      * has called 'C_GetSlotList' with a NULL parameter */
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   230
     void updateReaderList();
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   231
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   232
+     /* see if a reader name exists in a caller provided reader name list. */
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   233
+    bool readerNameExistsInList(const char *readerName,CKYReaderNameList *readerNameList );
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   234
     bool readerExists(const char *readerName, unsigned int *hint = 0);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   235
   public:
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   236
     SlotList(Log *log);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   237
@@ -592,6 +650,10 @@
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   238
     void seedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   239
         CK_ULONG ulDataLen);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   240
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   241
+    void derive(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   242
+        CK_OBJECT_HANDLE hKey, CK_ATTRIBUTE_PTR pTemplate, 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   243
+        CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey);
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   244
+
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   245
 
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   246
 };
8e624b116c1d PSARC/2016/219 Coolkey PKCS#11 provider for smartcard devices
Stephen Gaul Jr <steve.gaul@oracle.com>
parents:
diff changeset
   247
 #endif