@@ -1770,24 +1770,19 @@ class UnwrapMixin(types.UnwrapMixin):
17701770 self .key_type , DEFAULT_WRAP_MECHANISMS ,
17711771 mechanism , mechanism_param )
17721772
1773- # Build attributes
1774- template_ = {
1775- Attribute .CLASS : object_class ,
1776- Attribute .KEY_TYPE : key_type ,
1777- Attribute .ID : id or b'' ,
1778- Attribute .LABEL : label or '' ,
1779- Attribute .TOKEN : store ,
1780- # Capabilities
1781- Attribute .ENCRYPT : MechanismFlag .ENCRYPT & capabilities ,
1782- Attribute .DECRYPT : MechanismFlag .DECRYPT & capabilities ,
1783- Attribute .WRAP : MechanismFlag .WRAP & capabilities ,
1784- Attribute .UNWRAP : MechanismFlag .UNWRAP & capabilities ,
1785- Attribute .SIGN : MechanismFlag .SIGN & capabilities ,
1786- Attribute .VERIFY : MechanismFlag .VERIFY & capabilities ,
1787- Attribute .DERIVE : MechanismFlag .DERIVE & capabilities ,
1788- }
1789-
17901773 cdef Session session = self .session
1774+
1775+ # Build attributes
1776+ template_ = session .attribute_mapper .generic_key_template (
1777+ {
1778+ Attribute .CLASS : object_class ,
1779+ Attribute .KEY_TYPE : key_type ,
1780+ },
1781+ id_ = id ,
1782+ label = label ,
1783+ store = store ,
1784+ capabilities = capabilities ,
1785+ )
17911786 cdef AttributeList attrs = session .make_attribute_list (merge_templates (template_ , template ))
17921787 cdef CK_MECHANISM * mech_data = mech .data
17931788 cdef CK_OBJECT_HANDLE unwrapping_key = self .handle
@@ -1831,27 +1826,13 @@ class DeriveMixin(types.DeriveMixin):
18311826 self .key_type , DEFAULT_DERIVE_MECHANISMS ,
18321827 mechanism , mechanism_param )
18331828
1834- # Build attributes
1835- template_ = {
1836- Attribute .CLASS : ObjectClass .SECRET_KEY ,
1837- Attribute .KEY_TYPE : key_type ,
1838- Attribute .ID : id or b'' ,
1839- Attribute .LABEL : label or '' ,
1840- Attribute .TOKEN : store ,
1841- Attribute .VALUE_LEN : key_length // 8 , # In bytes
1842- Attribute .PRIVATE : True ,
1843- Attribute .SENSITIVE : True ,
1844- # Capabilities
1845- Attribute .ENCRYPT : MechanismFlag .ENCRYPT & capabilities ,
1846- Attribute .DECRYPT : MechanismFlag .DECRYPT & capabilities ,
1847- Attribute .WRAP : MechanismFlag .WRAP & capabilities ,
1848- Attribute .UNWRAP : MechanismFlag .UNWRAP & capabilities ,
1849- Attribute .SIGN : MechanismFlag .SIGN & capabilities ,
1850- Attribute .VERIFY : MechanismFlag .VERIFY & capabilities ,
1851- Attribute .DERIVE : MechanismFlag .DERIVE & capabilities ,
1852- }
1853-
18541829 cdef Session session = self .session
1830+
1831+ template_ = session .attribute_mapper .secret_key_template (
1832+ capabilities = capabilities , id_ = id , label = label , store = store ,
1833+ )
1834+ template_ [Attribute .KEY_TYPE ] = key_type
1835+ template_ [Attribute .VALUE_LEN ] = key_length // 8 # In bytes
18551836 cdef AttributeList attrs = session .make_attribute_list (merge_templates (template_ , template ))
18561837 cdef CK_MECHANISM * mech_data = mech .data
18571838 cdef CK_OBJECT_HANDLE src_key = self .handle
0 commit comments