components/coolkey/patches/05-object.h.patch
branchs11u3-sru
changeset 6535 8f23248b161c
equal deleted inserted replaced
6529:50a81baffe58 6535:8f23248b161c
       
     1 Upstream fixes already included in the latest community updates to coolkey v1.1.0
       
     2 
       
     3 Adds header definitions for PKCS11 object handling issues.
       
     4  
       
     5 --- ORIGINAL/./src/coolkey/object.h	2016-06-24 16:07:19.916341445 -0400
       
     6 +++ ././src/coolkey/object.h	2016-06-24 12:56:39.367675143 -0400
       
     7 @@ -49,7 +49,7 @@
       
     8  				CKYBuffer_Size(&cpy.value));
       
     9  	return *this;
       
    10      }
       
    11 -    PKCS11Attribute() { CKYBuffer_InitEmpty(&value); }
       
    12 +    PKCS11Attribute() : type(0){ CKYBuffer_InitEmpty(&value); }
       
    13      PKCS11Attribute(CK_ATTRIBUTE_TYPE type_, const CKYBuffer *value_)
       
    14          : type(type_) { CKYBuffer_InitFromCopy(&value, value_); }
       
    15      ~PKCS11Attribute() { CKYBuffer_FreeData(&value); }
       
    16 @@ -57,6 +57,11 @@
       
    17  
       
    18  class PKCS11Object {
       
    19    public:
       
    20 +    enum KeyType {
       
    21 +        rsa,
       
    22 +        ecc,
       
    23 +        unknown
       
    24 +    };
       
    25  
       
    26      typedef list<PKCS11Attribute> AttributeList;
       
    27      typedef AttributeList::iterator AttributeIter;
       
    28 @@ -75,18 +80,20 @@
       
    29      PKCS11Object &operator=(PKCS11Object &cpy) { return *this; } //Disallow
       
    30  
       
    31    protected :
       
    32 -    CKYBuffer pubKey; 
       
    33      char *name;
       
    34 +    KeyType keyType;
       
    35 +    CKYBuffer pubKey;
       
    36  
       
    37    public:
       
    38      PKCS11Object(unsigned long muscleObjID, CK_OBJECT_HANDLE handle);
       
    39      PKCS11Object(unsigned long muscleObjID, const CKYBuffer *data,
       
    40          CK_OBJECT_HANDLE handle);
       
    41 -    ~PKCS11Object() { delete label; delete name; CKYBuffer_FreeData(&pubKey); }
       
    42 +    ~PKCS11Object() { delete label; delete name; CKYBuffer_FreeData(&pubKey);
       
    43 +			attributes.clear(); }
       
    44  
       
    45      PKCS11Object(const PKCS11Object& cpy) :
       
    46          attributes(cpy.attributes), muscleObjID(cpy.muscleObjID),
       
    47 -        handle(cpy.handle), label(NULL),  name(NULL) { 
       
    48 +        handle(cpy.handle), label(NULL),  name(NULL), keyType(cpy.keyType) { 
       
    49  			CKYBuffer_InitFromCopy(&pubKey,&cpy.pubKey); }
       
    50  
       
    51  
       
    52 @@ -116,14 +123,15 @@
       
    53      const CKYBuffer *getPubKey(void) const {
       
    54  	return &pubKey;
       
    55      }
       
    56 +
       
    57 +    KeyType getKeyType() const { return keyType;}
       
    58 +    void setKeyType(KeyType theType) { keyType = theType; }
       
    59  };
       
    60  
       
    61  class Key : public PKCS11Object {
       
    62 -
       
    63    public:
       
    64      Key(unsigned long muscleObjID, const CKYBuffer *data, CK_OBJECT_HANDLE handle);
       
    65      void completeKey(const PKCS11Object &cert);
       
    66 -	
       
    67  };
       
    68  
       
    69  class Cert : public PKCS11Object {
       
    70 @@ -134,17 +142,17 @@
       
    71  
       
    72  class CACPrivKey : public PKCS11Object {
       
    73    public:
       
    74 -    CACPrivKey(CKYByte instance, const PKCS11Object &cert);
       
    75 +    CACPrivKey(CKYByte instance, const PKCS11Object &cert, bool isPIV);
       
    76  };
       
    77  
       
    78  class CACPubKey : public PKCS11Object {
       
    79    public:
       
    80 -    CACPubKey(CKYByte instance, const PKCS11Object &cert);
       
    81 +    CACPubKey(CKYByte instance, const PKCS11Object &cert, bool isPIV);
       
    82  };
       
    83  
       
    84  class CACCert : public PKCS11Object {
       
    85    public:
       
    86 -    CACCert(CKYByte instance, const CKYBuffer *derCert);
       
    87 +    CACCert(CKYByte instance, const CKYBuffer *derCert, bool isPIV);
       
    88  };
       
    89  
       
    90  class Reader : public PKCS11Object {
       
    91 @@ -153,6 +161,25 @@
       
    92  		const char *reader, const CKYBuffer *cardATR, bool isCoolkey);
       
    93  };
       
    94  
       
    95 +class SecretKey : public PKCS11Object {
       
    96 +    public: 
       
    97 +      SecretKey(unsigned long muscleObjID, CK_OBJECT_HANDLE handle, CKYBuffer *secretKeyBuffer, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount);
       
    98 +    private:
       
    99 +      void adjustToKeyValueLength(CKYBuffer * secretKeyBuffer,CK_ULONG valueLength);
       
   100 +
       
   101 +};
       
   102 +
       
   103 +class DEREncodedSignature  {
       
   104 +
       
   105 +  protected :
       
   106 +    CKYBuffer derEncodedSignature;
       
   107 +  public:
       
   108 +    DEREncodedSignature(const CKYBuffer *derSig);
       
   109 +    ~DEREncodedSignature();
       
   110 +    int getRawSignature(CKYBuffer *rawSig, unsigned int keySize);
       
   111 +
       
   112 +};
       
   113 +
       
   114  class AttributeMatch {
       
   115  
       
   116    private: