@@ -2183,12 +2183,18 @@ fn sign_verify_sha1_hmac() -> TestResult {
2183
2183
Attribute :: Sensitive ( true ) ,
2184
2184
Attribute :: Sign ( true ) ,
2185
2185
Attribute :: Verify ( true ) ,
2186
- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2187
- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
2188
2186
Attribute :: ValueLen ( 256 . into( ) ) ,
2189
2187
] ;
2190
2188
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
+ ) ?;
2192
2198
2193
2199
let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
2194
2200
@@ -2213,12 +2219,18 @@ fn sign_verify_sha224_hmac() -> TestResult {
2213
2219
Attribute :: Sensitive ( true ) ,
2214
2220
Attribute :: Sign ( true ) ,
2215
2221
Attribute :: Verify ( true ) ,
2216
- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2217
- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
2218
2222
Attribute :: ValueLen ( 256 . into( ) ) ,
2219
2223
] ;
2220
2224
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
+ ) ?;
2222
2234
2223
2235
let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
2224
2236
@@ -2243,12 +2255,18 @@ fn sign_verify_sha256_hmac() -> TestResult {
2243
2255
Attribute :: Sensitive ( true ) ,
2244
2256
Attribute :: Sign ( true ) ,
2245
2257
Attribute :: Verify ( true ) ,
2246
- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2247
- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
2248
2258
Attribute :: ValueLen ( 256 . into( ) ) ,
2249
2259
] ;
2250
2260
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
+ ) ?;
2252
2270
2253
2271
let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
2254
2272
@@ -2273,12 +2291,18 @@ fn sign_verify_sha384_hmac() -> TestResult {
2273
2291
Attribute :: Sensitive ( true ) ,
2274
2292
Attribute :: Sign ( true ) ,
2275
2293
Attribute :: Verify ( true ) ,
2276
- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2277
- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
2278
2294
Attribute :: ValueLen ( 256 . into( ) ) ,
2279
2295
] ;
2280
2296
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
+ ) ?;
2282
2306
2283
2307
let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
2284
2308
@@ -2303,12 +2327,18 @@ fn sign_verify_sha512_hmac() -> TestResult {
2303
2327
Attribute :: Sensitive ( true ) ,
2304
2328
Attribute :: Sign ( true ) ,
2305
2329
Attribute :: Verify ( true ) ,
2306
- Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
2307
- Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
2308
2330
Attribute :: ValueLen ( 256 . into( ) ) ,
2309
2331
] ;
2310
2332
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
+ ) ?;
2312
2342
2313
2343
let data = vec ! [ 0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF ] ;
2314
2344
0 commit comments