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
@@ -1273,9 +1278,13 @@ fn sha256_digest() -> TestResult {
12731278
12741279#[ test]
12751280#[ serial]
1276- // Currently empty AAD crashes SoftHSM, see: https://github.com/opendnssec/SoftHSMv2/issues/605
1277- #[ ignore]
12781281fn aes_gcm_no_aad ( ) -> TestResult {
1282+ // Currently empty AAD crashes SoftHSM, see: https://github.com/opendnssec/SoftHSMv2/issues/605
1283+ if is_softhsm ( ) {
1284+ /* return Ignore(); */
1285+ return Ok ( ( ) ) ;
1286+ }
1287+
12791288 // Encrypt two blocks of zeros with AES-128-GCM
12801289 let key = vec ! [ 0 ; 16 ] ;
12811290 let mut iv = [ 0 ; 12 ] ;
@@ -1370,8 +1379,13 @@ fn rsa_pkcs_oaep_empty() -> TestResult {
13701379
13711380#[ test]
13721381#[ serial]
1373- #[ ignore] // it's not clear why the test with data specified fails
13741382fn rsa_pkcs_oaep_with_data ( ) -> TestResult {
1383+ /* SoftHSM does not support additional OAEP Source */
1384+ if is_softhsm ( ) {
1385+ /* return Ignore(); */
1386+ return Ok ( ( ) ) ;
1387+ }
1388+
13751389 let ( pkcs11, slot) = init_pins ( ) ;
13761390 let session = pkcs11. open_rw_session ( slot) ?;
13771391 session. login ( UserType :: User , Some ( & AuthPin :: new ( USER_PIN . into ( ) ) ) ) ?;
@@ -1404,11 +1418,16 @@ fn rsa_pkcs_oaep_with_data() -> TestResult {
14041418#[ test]
14051419#[ serial]
14061420fn get_slot_event ( ) -> TestResult {
1407- // Not implemented in SoftHSMv2
1408- // https://github.com/opendnssec/SoftHSMv2/issues/370
14091421 let ( pkcs11, _slot) = init_pins ( ) ;
1410- let event = pkcs11. get_slot_event ( ) ?;
1411- assert_eq ! ( None , event) ;
1422+ if is_softhsm ( ) {
1423+ // Not implemented in SoftHSMv2
1424+ // https://github.com/opendnssec/SoftHSMv2/issues/370
1425+ let event = pkcs11. get_slot_event ( ) ?;
1426+ assert_eq ! ( None , event) ;
1427+ } else {
1428+ // Not implemented in Kryoptic
1429+ pkcs11. get_slot_event ( ) . unwrap_err ( ) ;
1430+ }
14121431 Ok ( ( ) )
14131432}
14141433
0 commit comments