@@ -46,10 +46,11 @@ fn sign_verify() -> TestResult {
46
46
Attribute :: Private ( false ) ,
47
47
Attribute :: PublicExponent ( public_exponent) ,
48
48
Attribute :: ModulusBits ( modulus_bits. into( ) ) ,
49
+ Attribute :: Verify ( true ) ,
49
50
] ;
50
51
51
52
// priv key template
52
- let priv_key_template = vec ! [ Attribute :: Token ( true ) ] ;
53
+ let priv_key_template = vec ! [ Attribute :: Token ( true ) , Attribute :: Sign ( true ) ] ;
53
54
54
55
// generate a key pair
55
56
let ( public, private) =
@@ -93,7 +94,7 @@ fn sign_verify_eddsa() -> TestResult {
93
94
] ) ,
94
95
] ;
95
96
96
- let priv_key_template = vec ! [ Attribute :: Token ( true ) ] ;
97
+ let priv_key_template = vec ! [ Attribute :: Token ( true ) , Attribute :: Sign ( true ) ] ;
97
98
98
99
let ( public, private) =
99
100
session. generate_key_pair ( & mechanism, & pub_key_template, & priv_key_template) ?;
@@ -136,7 +137,7 @@ fn sign_verify_eddsa_with_ed25519_schemes() -> TestResult {
136
137
] ) ,
137
138
] ;
138
139
139
- let priv_key_template = vec ! [ Attribute :: Token ( true ) ] ;
140
+ let priv_key_template = vec ! [ Attribute :: Token ( true ) , Attribute :: Sign ( true ) ] ;
140
141
141
142
let ( public, private) =
142
143
session. generate_key_pair ( & mechanism, & pub_key_template, & priv_key_template) ?;
@@ -186,7 +187,7 @@ fn sign_verify_eddsa_with_ed448_schemes() -> TestResult {
186
187
] ) ,
187
188
] ;
188
189
189
- let priv_key_template = vec ! [ Attribute :: Token ( true ) ] ;
190
+ let priv_key_template = vec ! [ Attribute :: Token ( true ) , Attribute :: Sign ( true ) ] ;
190
191
191
192
let ( public, private) =
192
193
session. generate_key_pair ( & mechanism, & pub_key_template, & priv_key_template) ?;
@@ -1353,9 +1354,16 @@ fn rsa_pkcs_oaep_empty() -> TestResult {
1353
1354
let session = pkcs11. open_rw_session ( slot) ?;
1354
1355
session. login ( UserType :: User , Some ( & AuthPin :: new ( USER_PIN . into ( ) ) ) ) ?;
1355
1356
1356
- let pub_key_template = [ Attribute :: ModulusBits ( 2048 . into ( ) ) ] ;
1357
- let ( pubkey, privkey) =
1358
- session. generate_key_pair ( & Mechanism :: RsaPkcsKeyPairGen , & pub_key_template, & [ ] ) ?;
1357
+ let pub_key_template = [
1358
+ Attribute :: ModulusBits ( 2048 . into ( ) ) ,
1359
+ Attribute :: Encrypt ( true ) ,
1360
+ ] ;
1361
+ let priv_key_template = [ Attribute :: Decrypt ( true ) ] ;
1362
+ let ( pubkey, privkey) = session. generate_key_pair (
1363
+ & Mechanism :: RsaPkcsKeyPairGen ,
1364
+ & pub_key_template,
1365
+ & priv_key_template,
1366
+ ) ?;
1359
1367
let oaep = PkcsOaepParams :: new (
1360
1368
MechanismType :: SHA1 ,
1361
1369
PkcsMgfType :: MGF1_SHA1 ,
@@ -1380,9 +1388,16 @@ fn rsa_pkcs_oaep_with_data() -> TestResult {
1380
1388
let session = pkcs11. open_rw_session ( slot) ?;
1381
1389
session. login ( UserType :: User , Some ( & AuthPin :: new ( USER_PIN . into ( ) ) ) ) ?;
1382
1390
1383
- let pub_key_template = [ Attribute :: ModulusBits ( 2048 . into ( ) ) ] ;
1384
- let ( pubkey, privkey) =
1385
- session. generate_key_pair ( & Mechanism :: RsaPkcsKeyPairGen , & pub_key_template, & [ ] ) ?;
1391
+ let pub_key_template = [
1392
+ Attribute :: ModulusBits ( 2048 . into ( ) ) ,
1393
+ Attribute :: Encrypt ( true ) ,
1394
+ ] ;
1395
+ let priv_key_template = vec ! [ Attribute :: Decrypt ( true ) ] ;
1396
+ let ( pubkey, privkey) = session. generate_key_pair (
1397
+ & Mechanism :: RsaPkcsKeyPairGen ,
1398
+ & pub_key_template,
1399
+ & priv_key_template,
1400
+ ) ?;
1386
1401
let oaep = PkcsOaepParams :: new (
1387
1402
MechanismType :: SHA1 ,
1388
1403
PkcsMgfType :: MGF1_SHA1 ,
@@ -1523,6 +1538,7 @@ fn sign_verify_sha1_hmac() -> TestResult {
1523
1538
Attribute :: Private ( true ) ,
1524
1539
Attribute :: Sensitive ( true ) ,
1525
1540
Attribute :: Sign ( true ) ,
1541
+ Attribute :: Verify ( true ) ,
1526
1542
Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
1527
1543
Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
1528
1544
Attribute :: ValueLen ( 256 . into( ) ) ,
@@ -1552,6 +1568,7 @@ fn sign_verify_sha224_hmac() -> TestResult {
1552
1568
Attribute :: Private ( true ) ,
1553
1569
Attribute :: Sensitive ( true ) ,
1554
1570
Attribute :: Sign ( true ) ,
1571
+ Attribute :: Verify ( true ) ,
1555
1572
Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
1556
1573
Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
1557
1574
Attribute :: ValueLen ( 256 . into( ) ) ,
@@ -1581,6 +1598,7 @@ fn sign_verify_sha256_hmac() -> TestResult {
1581
1598
Attribute :: Private ( true ) ,
1582
1599
Attribute :: Sensitive ( true ) ,
1583
1600
Attribute :: Sign ( true ) ,
1601
+ Attribute :: Verify ( true ) ,
1584
1602
Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
1585
1603
Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
1586
1604
Attribute :: ValueLen ( 256 . into( ) ) ,
@@ -1610,6 +1628,7 @@ fn sign_verify_sha384_hmac() -> TestResult {
1610
1628
Attribute :: Private ( true ) ,
1611
1629
Attribute :: Sensitive ( true ) ,
1612
1630
Attribute :: Sign ( true ) ,
1631
+ Attribute :: Verify ( true ) ,
1613
1632
Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
1614
1633
Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
1615
1634
Attribute :: ValueLen ( 256 . into( ) ) ,
@@ -1639,6 +1658,7 @@ fn sign_verify_sha512_hmac() -> TestResult {
1639
1658
Attribute :: Private ( true ) ,
1640
1659
Attribute :: Sensitive ( true ) ,
1641
1660
Attribute :: Sign ( true ) ,
1661
+ Attribute :: Verify ( true ) ,
1642
1662
Attribute :: KeyType ( KeyType :: GENERIC_SECRET ) ,
1643
1663
Attribute :: Class ( ObjectClass :: SECRET_KEY ) ,
1644
1664
Attribute :: ValueLen ( 256 . into( ) ) ,
0 commit comments