]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-linux/ti-softhsmv2.git/blobdiff - src/lib/P11Attributes.cpp
Secure storage #3
[keystone-linux/ti-softhsmv2.git] / src / lib / P11Attributes.cpp
index 4278a5b82d3ec328bb702c158fcfe687bb77523f..509f56772b40365907abaa914cdc6ae075127fd6 100644 (file)
@@ -54,6 +54,7 @@ P11Attribute::~P11Attribute()
 
 CK_RV P11Attribute::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)op;
        ByteString value;
        if (isPrivate)
        {
@@ -384,6 +385,8 @@ bool P11AttrClass::setDefault()
 // Update the value if allowed
 CK_RV P11AttrClass::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute* attr = NULL;
 
        // Attribute specific checks
@@ -426,6 +429,9 @@ bool P11AttrKeyType::setDefault()
 // Update the value if allowed
 CK_RV P11AttrKeyType::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+
        OSAttribute* attr = NULL;
 
        // Attribute specific checks
@@ -470,6 +476,8 @@ bool P11AttrCertificateType::setDefault()
 // Update the value if allowed
 CK_RV P11AttrCertificateType::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute* attr = NULL;
 
        // Attribute specific checks
@@ -512,6 +520,8 @@ bool P11AttrToken::setDefault()
 // Update the value if allowed
 CK_RV P11AttrToken::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -555,6 +565,8 @@ bool P11AttrPrivate::setDefault()
 // Update the value if allowed
 CK_RV P11AttrPrivate::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -598,6 +610,8 @@ bool P11AttrModifiable::setDefault()
 // Update the value if allowed
 CK_RV P11AttrModifiable::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -652,6 +666,8 @@ bool P11AttrCopyable::setDefault()
 // Update the value if allowed
 CK_RV P11AttrCopyable::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -775,6 +791,8 @@ bool P11AttrTrusted::setDefault()
 // Update the value if allowed
 CK_RV P11AttrTrusted::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -818,6 +836,8 @@ bool P11AttrCertificateCategory::setDefault()
 // Update the value if allowed
 CK_RV P11AttrCertificateCategory::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        // Attribute specific checks
 
        if (op != OBJECT_OP_SET)
@@ -850,6 +870,9 @@ bool P11AttrStartDate::setDefault()
 // Update the value if allowed
 CK_RV P11AttrStartDate::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        // Attribute specific checks
 
        if (ulValueLen !=sizeof(CK_DATE) && ulValueLen !=0)
@@ -877,6 +900,9 @@ bool P11AttrEndDate::setDefault()
 // Update the value if allowed
 CK_RV P11AttrEndDate::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        // Attribute specific checks
 
        if (ulValueLen !=sizeof(CK_DATE) && ulValueLen !=0)
@@ -948,6 +974,8 @@ bool P11AttrJavaMidpSecurityDomain::setDefault()
 // Update the value if allowed
 CK_RV P11AttrJavaMidpSecurityDomain::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        // Attribute specific checks
 
        if (op != OBJECT_OP_SET)
@@ -980,6 +1008,8 @@ bool P11AttrNameHashAlgorithm::setDefault()
 // Update the value if allowed
 CK_RV P11AttrNameHashAlgorithm::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        // Attribute specific checks
 
        if (op != OBJECT_OP_SET)
@@ -1012,6 +1042,9 @@ bool P11AttrDerive::setDefault()
 // Update the value if allowed
 CK_RV P11AttrDerive::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1050,6 +1083,9 @@ bool P11AttrEncrypt::setDefault()
 // Update the value if allowed
 CK_RV P11AttrEncrypt::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1088,6 +1124,9 @@ bool P11AttrVerify::setDefault()
 // Update the value if allowed
 CK_RV P11AttrVerify::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1126,6 +1165,9 @@ bool P11AttrVerifyRecover::setDefault()
 // Update the value if allowed
 CK_RV P11AttrVerifyRecover::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1164,6 +1206,9 @@ bool P11AttrWrap::setDefault()
 // Update the value if allowed
 CK_RV P11AttrWrap::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1202,6 +1247,9 @@ bool P11AttrDecrypt::setDefault()
 // Update the value if allowed
 CK_RV P11AttrDecrypt::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1240,6 +1288,9 @@ bool P11AttrSign::setDefault()
 // Update the value if allowed
 CK_RV P11AttrSign::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1278,6 +1329,9 @@ bool P11AttrSignRecover::setDefault()
 // Update the value if allowed
 CK_RV P11AttrSignRecover::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1316,6 +1370,9 @@ bool P11AttrUnwrap::setDefault()
 // Update the value if allowed
 CK_RV P11AttrUnwrap::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1354,6 +1411,11 @@ bool P11AttrLocal::setDefault()
 // Update the value if allowed
 CK_RV P11AttrLocal::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)pValue;
+       (void)ulValueLen;
+       (void)op;
        return CKR_ATTRIBUTE_READ_ONLY;
 }
 
@@ -1371,6 +1433,11 @@ bool P11AttrKeyGenMechanism::setDefault()
 // Update the value if allowed
 CK_RV P11AttrKeyGenMechanism::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)pValue;
+       (void)ulValueLen;
+       (void)op;
        return CKR_ATTRIBUTE_READ_ONLY;
 }
 
@@ -1388,6 +1455,11 @@ bool P11AttrAlwaysSensitive::setDefault()
 // Update the value if allowed
 CK_RV P11AttrAlwaysSensitive::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)pValue;
+       (void)ulValueLen;
+       (void)op;
        return CKR_ATTRIBUTE_READ_ONLY;
 }
 
@@ -1405,6 +1477,11 @@ bool P11AttrNeverExtractable::setDefault()
 // Update the value if allowed
 CK_RV P11AttrNeverExtractable::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
+       (void)pValue;
+       (void)ulValueLen;
+       (void)op;
        return CKR_ATTRIBUTE_READ_ONLY;
 }
 
@@ -1423,6 +1500,8 @@ bool P11AttrSensitive::setDefault()
 // Update the value if allowed
 CK_RV P11AttrSensitive::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1476,6 +1555,8 @@ bool P11AttrExtractable::setDefault()
 // Update the value if allowed
 CK_RV P11AttrExtractable::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1523,6 +1604,8 @@ bool P11AttrWrapWithTrusted::setDefault()
 // Update the value if allowed
 CK_RV P11AttrWrapWithTrusted::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1569,6 +1652,8 @@ bool P11AttrAlwaysAuthenticate::setDefault()
 // Update the value if allowed
 CK_RV P11AttrAlwaysAuthenticate::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)op;
        OSAttribute attrTrue(true);
        OSAttribute attrFalse(false);
 
@@ -1735,6 +1820,8 @@ bool P11AttrModulusBits::setDefault()
 // Update the value if allowed
 CK_RV P11AttrModulusBits::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
 {
+       (void)token;
+       (void)isPrivate;
        // Attribute specific checks
 
        if (op != OBJECT_OP_GENERATE)
@@ -1753,3 +1840,36 @@ CK_RV P11AttrModulusBits::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR p
 
        return CKR_OK;
 }
+
+
+
+/*****************************************
+ * CKA_WRAPPED_PRIVATE_KEY
+ *****************************************/
+
+
+bool P11AttrWrappedPrivateKey::setDefault()
+{
+       OSAttribute attr(ByteString(""));
+       return osobject->setAttribute(type, attr);
+}
+
+CK_RV P11AttrWrappedPrivateKey::updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op)
+{
+       (void)token;
+       (void)isPrivate;
+       // Attribute specific checks
+
+       if (op != OBJECT_OP_GENERATE)
+       {
+               return CKR_ATTRIBUTE_READ_ONLY;
+       }
+
+       ByteString value;
+       value = ByteString((unsigned char*)pValue, ulValueLen);
+       if (value.size() < ulValueLen)
+               return CKR_GENERAL_ERROR;
+       osobject->setAttribute(type, value);
+       return CKR_OK;
+}
+