File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -877,8 +877,8 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
877877 )
878878 } ;
879879 let types: Vec < MechanismType > = val
880- . to_vec ( )
881- . into_iter ( )
880+ . iter ( )
881+ . copied ( )
882882 . map ( |t| t. try_into ( ) )
883883 . collect :: < Result < Vec < MechanismType > > > ( ) ?;
884884 Ok ( Attribute :: AllowedMechanisms ( types) )
@@ -908,7 +908,7 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
908908 }
909909 AttributeType :: StartDate => {
910910 if val. is_empty ( ) {
911- Ok ( Attribute :: EndDate ( Date :: new_empty ( ) ) )
911+ Ok ( Attribute :: StartDate ( Date :: new_empty ( ) ) )
912912 } else {
913913 let date = val. as_ptr ( ) as * const CK_DATE ;
914914 unsafe {
Original file line number Diff line number Diff line change @@ -706,8 +706,20 @@ fn aes_key_attributes_test() -> Result<()> {
706706 // generate a key pair
707707 let key = session. generate_key ( & mechanism, & key_template) ?;
708708
709- let _attributes_result =
709+ let mut attributes_result =
710710 session. get_attributes ( key, & [ AttributeType :: EndDate , AttributeType :: StartDate ] ) ?;
711711
712+ if let Some ( Attribute :: StartDate ( date) ) = attributes_result. pop ( ) {
713+ assert ! ( date. is_empty( ) ) ;
714+ } else {
715+ panic ! ( "Last attribute was not a start date" ) ;
716+ }
717+
718+ if let Some ( Attribute :: EndDate ( date) ) = attributes_result. pop ( ) {
719+ assert ! ( date. is_empty( ) ) ;
720+ } else {
721+ panic ! ( "First attribute was not an end date" ) ;
722+ }
723+
712724 Ok ( ( ) )
713725}
You can’t perform that action at this time.
0 commit comments