@@ -1770,24 +1770,19 @@ class UnwrapMixin(types.UnwrapMixin):
1770
1770
self .key_type , DEFAULT_WRAP_MECHANISMS ,
1771
1771
mechanism , mechanism_param )
1772
1772
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
-
1790
1773
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
+ )
1791
1786
cdef AttributeList attrs = session .make_attribute_list (merge_templates (template_ , template ))
1792
1787
cdef CK_MECHANISM * mech_data = mech .data
1793
1788
cdef CK_OBJECT_HANDLE unwrapping_key = self .handle
@@ -1831,27 +1826,13 @@ class DeriveMixin(types.DeriveMixin):
1831
1826
self .key_type , DEFAULT_DERIVE_MECHANISMS ,
1832
1827
mechanism , mechanism_param )
1833
1828
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
-
1854
1829
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
1855
1836
cdef AttributeList attrs = session .make_attribute_list (merge_templates (template_ , template ))
1856
1837
cdef CK_MECHANISM * mech_data = mech .data
1857
1838
cdef CK_OBJECT_HANDLE src_key = self .handle
0 commit comments