@@ -2183,12 +2183,18 @@ fn sign_verify_sha1_hmac() -> TestResult {
21832183 Attribute :: Sensitive ( true ) ,
21842184 Attribute :: Sign ( true ) ,
21852185 Attribute :: Verify ( true ) ,
2186- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2187- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
21882186 Attribute :: ValueLen ( 256 . into( ) ) ,
21892187 ] ;
21902188
2191- let private = session. generate_key ( & Mechanism :: GenericSecretKeyGen , & priv_key_template) ?;
2189+ let private = session. generate_key (
2190+ // SoftHSM does not yet support SHA-n key gen mechanisms
2191+ if is_softhsm ( ) {
2192+ & Mechanism :: GenericSecretKeyGen
2193+ } else {
2194+ & Mechanism :: Sha1KeyGen
2195+ } ,
2196+ & priv_key_template,
2197+ ) ?;
21922198
21932199 let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
21942200
@@ -2213,12 +2219,18 @@ fn sign_verify_sha224_hmac() -> TestResult {
22132219 Attribute :: Sensitive ( true ) ,
22142220 Attribute :: Sign ( true ) ,
22152221 Attribute :: Verify ( true ) ,
2216- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2217- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
22182222 Attribute :: ValueLen ( 256 . into( ) ) ,
22192223 ] ;
22202224
2221- let private = session. generate_key ( & Mechanism :: GenericSecretKeyGen , & priv_key_template) ?;
2225+ let private = session. generate_key (
2226+ // SoftHSM does not yet support SHA-n key gen mechanisms
2227+ if is_softhsm ( ) {
2228+ & Mechanism :: GenericSecretKeyGen
2229+ } else {
2230+ & Mechanism :: Sha224KeyGen
2231+ } ,
2232+ & priv_key_template,
2233+ ) ?;
22222234
22232235 let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
22242236
@@ -2243,12 +2255,18 @@ fn sign_verify_sha256_hmac() -> TestResult {
22432255 Attribute :: Sensitive ( true ) ,
22442256 Attribute :: Sign ( true ) ,
22452257 Attribute :: Verify ( true ) ,
2246- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2247- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
22482258 Attribute :: ValueLen ( 256 . into( ) ) ,
22492259 ] ;
22502260
2251- let private = session. generate_key ( & Mechanism :: GenericSecretKeyGen , & priv_key_template) ?;
2261+ let private = session. generate_key (
2262+ // SoftHSM does not yet support SHA-n key gen mechanisms
2263+ if is_softhsm ( ) {
2264+ & Mechanism :: GenericSecretKeyGen
2265+ } else {
2266+ & Mechanism :: Sha256KeyGen
2267+ } ,
2268+ & priv_key_template,
2269+ ) ?;
22522270
22532271 let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
22542272
@@ -2273,12 +2291,18 @@ fn sign_verify_sha384_hmac() -> TestResult {
22732291 Attribute :: Sensitive ( true ) ,
22742292 Attribute :: Sign ( true ) ,
22752293 Attribute :: Verify ( true ) ,
2276- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2277- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
22782294 Attribute :: ValueLen ( 256 . into( ) ) ,
22792295 ] ;
22802296
2281- let private = session. generate_key ( & Mechanism :: GenericSecretKeyGen , & priv_key_template) ?;
2297+ let private = session. generate_key (
2298+ // SoftHSM does not yet support SHA-n key gen mechanisms
2299+ if is_softhsm ( ) {
2300+ & Mechanism :: GenericSecretKeyGen
2301+ } else {
2302+ & Mechanism :: Sha384KeyGen
2303+ } ,
2304+ & priv_key_template,
2305+ ) ?;
22822306
22832307 let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
22842308
@@ -2303,12 +2327,18 @@ fn sign_verify_sha512_hmac() -> TestResult {
23032327 Attribute :: Sensitive ( true ) ,
23042328 Attribute :: Sign ( true ) ,
23052329 Attribute :: Verify ( true ) ,
2306- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2307- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
23082330 Attribute :: ValueLen ( 256 . into( ) ) ,
23092331 ] ;
23102332
2311- let private = session. generate_key ( & Mechanism :: GenericSecretKeyGen , & priv_key_template) ?;
2333+ let private = session. generate_key (
2334+ // SoftHSM does not yet support SHA-n key gen mechanisms
2335+ if is_softhsm ( ) {
2336+ & Mechanism :: GenericSecretKeyGen
2337+ } else {
2338+ & Mechanism :: Sha512KeyGen
2339+ } ,
2340+ & priv_key_template,
2341+ ) ?;
23122342
23132343 let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
23142344
0 commit comments