@@ -14,6 +14,8 @@ use std::fmt::Formatter;
1414use std:: mem:: size_of;
1515use std:: ops:: Deref ;
1616
17+ const MAX_CU_ULONG : CK_ULONG = !0 ;
18+
1719#[ derive( Debug , Copy , Clone , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
1820/// Type of an attribute
1921pub enum AttributeType {
@@ -255,7 +257,9 @@ impl AttributeType {
255257 CKA_UNWRAP_TEMPLATE => String :: from ( stringify ! ( CKA_UNWRAP_TEMPLATE ) ) ,
256258 CKA_DERIVE_TEMPLATE => String :: from ( stringify ! ( CKA_DERIVE_TEMPLATE ) ) ,
257259 CKA_ALLOWED_MECHANISMS => String :: from ( stringify ! ( CKA_ALLOWED_MECHANISMS ) ) ,
258- CKA_VENDOR_DEFINED => String :: from ( stringify ! ( CKA_VENDOR_DEFINED ) ) ,
260+ CKA_VENDOR_DEFINED ..=MAX_CU_ULONG => {
261+ format ! ( "{}_{}" , stringify!( CKA_VENDOR_DEFINED ) , val)
262+ }
259263 _ => format ! ( "unknown ({val:08x})" ) ,
260264 }
261265 }
@@ -399,7 +403,7 @@ impl TryFrom<CK_ATTRIBUTE_TYPE> for AttributeType {
399403 CKA_VERIFY_RECOVER => Ok ( AttributeType :: VerifyRecover ) ,
400404 CKA_WRAP => Ok ( AttributeType :: Wrap ) ,
401405 CKA_WRAP_WITH_TRUSTED => Ok ( AttributeType :: WrapWithTrusted ) ,
402- 0x8000_0000 ..=0xffff_ffff => Ok ( AttributeType :: VendorDefined ( attribute_type) ) ,
406+ CKA_VENDOR_DEFINED ..=MAX_CU_ULONG => Ok ( AttributeType :: VendorDefined ( attribute_type) ) ,
403407 attr_type => {
404408 error ! ( "Attribute type {} not supported." , attr_type) ;
405409 Err ( Error :: NotSupported )
@@ -937,7 +941,7 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
937941 ) ?) )
938942 }
939943 }
940- } ,
944+ }
941945 AttributeType :: VendorDefined ( t) => Ok ( Attribute :: VendorDefined ( ( t, val. to_vec ( ) ) ) ) ,
942946 }
943947 }
0 commit comments