22// SPDX-License-Identifier: Apache-2.0
33mod common;
44
5- use crate :: common:: { get_pkcs11, SO_PIN , USER_PIN } ;
5+ use crate :: common:: { get_pkcs11, is_softhsm , SO_PIN , USER_PIN } ;
66use common:: init_pins;
77use cryptoki:: context:: Function ;
88use cryptoki:: error:: { Error , RvError } ;
@@ -411,7 +411,7 @@ fn import_export() -> TestResult {
411411fn get_token_info ( ) -> TestResult {
412412 let ( pkcs11, slot) = init_pins ( ) ;
413413 let info = pkcs11. get_token_info ( slot) ?;
414- assert_eq ! ( "SoftHSM project " , info. manufacturer_id( ) ) ;
414+ assert_ne ! ( "" , info. manufacturer_id( ) ) ;
415415
416416 Ok ( ( ) )
417417}
@@ -698,9 +698,14 @@ fn get_info_test() -> TestResult {
698698 let ( pkcs11, _) = init_pins ( ) ;
699699 let info = pkcs11. get_library_info ( ) ?;
700700
701- assert_eq ! ( info. cryptoki_version( ) . major( ) , 2 ) ;
702- assert_eq ! ( info. cryptoki_version( ) . minor( ) , 40 ) ;
703- assert_eq ! ( info. manufacturer_id( ) , String :: from( "SoftHSM" ) ) ;
701+ assert_ne ! ( "" , info. manufacturer_id( ) ) ;
702+ if is_softhsm ( ) {
703+ assert_eq ! ( info. cryptoki_version( ) . major( ) , 2 ) ;
704+ assert_eq ! ( info. cryptoki_version( ) . minor( ) , 40 ) ;
705+ } else {
706+ assert_eq ! ( info. cryptoki_version( ) . major( ) , 3 ) ;
707+ assert_eq ! ( info. cryptoki_version( ) . minor( ) , 0 ) ;
708+ }
704709 Ok ( ( ) )
705710}
706711
@@ -712,7 +717,7 @@ fn get_slot_info_test() -> TestResult {
712717 assert ! ( slot_info. token_present( ) ) ;
713718 assert ! ( !slot_info. hardware_slot( ) ) ;
714719 assert ! ( !slot_info. removable_device( ) ) ;
715- assert_eq ! ( slot_info. manufacturer_id( ) , String :: from ( "SoftHSM project" ) ) ;
720+ assert_ne ! ( "" , slot_info. manufacturer_id( ) ) ;
716721 Ok ( ( ) )
717722}
718723
@@ -1286,9 +1291,13 @@ fn gcm_param_graceful_failure() -> TestResult {
12861291
12871292#[ test]
12881293#[ serial]
1289- // Currently empty AAD crashes SoftHSM, see: https://github.com/opendnssec/SoftHSMv2/issues/605
1290- #[ ignore]
12911294fn aes_gcm_no_aad ( ) -> TestResult {
1295+ // Currently empty AAD crashes SoftHSM, see: https://github.com/opendnssec/SoftHSMv2/issues/605
1296+ if is_softhsm ( ) {
1297+ /* return Ignore(); */
1298+ return Ok ( ( ) ) ;
1299+ }
1300+
12921301 // Encrypt two blocks of zeros with AES-128-GCM
12931302 let key = vec ! [ 0 ; 16 ] ;
12941303 let mut iv = [ 0 ; 12 ] ;
@@ -1384,8 +1393,13 @@ fn rsa_pkcs_oaep_empty() -> TestResult {
13841393
13851394#[ test]
13861395#[ serial]
1387- #[ ignore] // it's not clear why the test with data specified fails
13881396fn rsa_pkcs_oaep_with_data ( ) -> TestResult {
1397+ /* SoftHSM does not support additional OAEP Source */
1398+ if is_softhsm ( ) {
1399+ /* return Ignore(); */
1400+ return Ok ( ( ) ) ;
1401+ }
1402+
13891403 let ( pkcs11, slot) = init_pins ( ) ;
13901404 let session = pkcs11. open_rw_session ( slot) ?;
13911405 session. login ( UserType :: User , Some ( & AuthPin :: new ( USER_PIN . into ( ) ) ) ) ?;
@@ -1418,11 +1432,16 @@ fn rsa_pkcs_oaep_with_data() -> TestResult {
14181432#[ test]
14191433#[ serial]
14201434fn get_slot_event ( ) -> TestResult {
1421- // Not implemented in SoftHSMv2
1422- // https://github.com/opendnssec/SoftHSMv2/issues/370
14231435 let ( pkcs11, _slot) = init_pins ( ) ;
1424- let event = pkcs11. get_slot_event ( ) ?;
1425- assert_eq ! ( None , event) ;
1436+ if is_softhsm ( ) {
1437+ // Not implemented in SoftHSMv2
1438+ // https://github.com/opendnssec/SoftHSMv2/issues/370
1439+ let event = pkcs11. get_slot_event ( ) ?;
1440+ assert_eq ! ( None , event) ;
1441+ } else {
1442+ // Not implemented in Kryoptic
1443+ pkcs11. get_slot_event ( ) . unwrap_err ( ) ;
1444+ }
14261445 Ok ( ( ) )
14271446}
14281447
0 commit comments