@@ -14,6 +14,8 @@ use std::fmt::Formatter;
14
14
use std:: mem:: size_of;
15
15
use std:: ops:: Deref ;
16
16
17
+ const MAX_CU_ULONG : CK_ULONG = !0 ;
18
+
17
19
#[ derive( Debug , Copy , Clone , Ord , PartialOrd , Eq , PartialEq , Hash ) ]
18
20
/// Type of an attribute
19
21
pub enum AttributeType {
@@ -255,7 +257,9 @@ impl AttributeType {
255
257
CKA_UNWRAP_TEMPLATE => String :: from ( stringify ! ( CKA_UNWRAP_TEMPLATE ) ) ,
256
258
CKA_DERIVE_TEMPLATE => String :: from ( stringify ! ( CKA_DERIVE_TEMPLATE ) ) ,
257
259
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
+ }
259
263
_ => format ! ( "unknown ({val:08x})" ) ,
260
264
}
261
265
}
@@ -399,7 +403,7 @@ impl TryFrom<CK_ATTRIBUTE_TYPE> for AttributeType {
399
403
CKA_VERIFY_RECOVER => Ok ( AttributeType :: VerifyRecover ) ,
400
404
CKA_WRAP => Ok ( AttributeType :: Wrap ) ,
401
405
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) ) ,
403
407
attr_type => {
404
408
error ! ( "Attribute type {} not supported." , attr_type) ;
405
409
Err ( Error :: NotSupported )
@@ -937,7 +941,7 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
937
941
) ?) )
938
942
}
939
943
}
940
- } ,
944
+ }
941
945
AttributeType :: VendorDefined ( t) => Ok ( Attribute :: VendorDefined ( ( t, val. to_vec ( ) ) ) ) ,
942
946
}
943
947
}
0 commit comments