diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2018-05-23 22:31:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-05-23 22:31:41 +0000 |
commit | a1e6976c77fdc088a574e3b58cb18d57ddfd2498 (patch) | |
tree | 7fb1f0a63d47d533817c24471b05566fc35cac6b /SoftHSMv2/src/lib/P11Attributes.cpp | |
parent | 4c727ecb7cf150a2c054e7581f3d135cecccf296 (diff) | |
parent | 57c7ad1aa0e485b5594f27f1ab501ff0306fe2fc (diff) |
Merge "Added a new Attribute to store TPM key handle"
Diffstat (limited to 'SoftHSMv2/src/lib/P11Attributes.cpp')
-rw-r--r-- | SoftHSMv2/src/lib/P11Attributes.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/SoftHSMv2/src/lib/P11Attributes.cpp b/SoftHSMv2/src/lib/P11Attributes.cpp index 28d0f9b..5a56097 100644 --- a/SoftHSMv2/src/lib/P11Attributes.cpp +++ b/SoftHSMv2/src/lib/P11Attributes.cpp @@ -294,6 +294,10 @@ CK_RV P11Attribute::retrieve(Token *token, bool isPrivate, CK_VOID_PTR pValue, C { attrSize = attr.getAttributeMapValue().size() * sizeof(CK_ATTRIBUTE); } + else if (attr.isUnsignedLongAttribute()) + { + attrSize = sizeof(unsigned long); + } else { // Should be impossible. @@ -2512,3 +2516,33 @@ CK_RV P11AttrAllowedMechanisms::updateAttr(Token* /*token*/, bool /*isPrivate*/, osobject->setAttribute(type, OSAttribute(data)); return CKR_OK; } + + +// Set default value +bool P11AttrPrivateHandle::setDefault() +{ + OSAttribute attr((CK_ULONG)0); + return osobject->setAttribute(type, attr); +} + +// Update the value if allowed +CK_RV P11AttrPrivateHandle::updateAttr(Token* /*token*/, bool /*isPrivate*/, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op) +{ + // Attribute specific checks + if (op != OBJECT_OP_CREATE) + { + return CKR_ATTRIBUTE_READ_ONLY; + } + + if (ulValueLen !=sizeof(CK_ULONG)) + { + return CKR_ATTRIBUTE_VALUE_INVALID; + } + + // Store data + osobject->setAttribute(type, *((CK_ULONG*)pValue)); + + return CKR_OK; +} + + |