Skip to content

Commit 81bd2a9

Browse files
committed
tests: Add missing usage attributes
Signed-off-by: Jakub Jelen <[email protected]>
1 parent 1941a69 commit 81bd2a9

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

cryptoki/tests/basic.rs

+25-6
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ fn sign_verify() -> TestResult {
4646
Attribute::Private(false),
4747
Attribute::PublicExponent(public_exponent),
4848
Attribute::ModulusBits(modulus_bits.into()),
49+
Attribute::Verify(true),
4950
];
5051

5152
// priv key template
52-
let priv_key_template = vec![Attribute::Token(true)];
53+
let priv_key_template = vec![
54+
Attribute::Token(true),
55+
Attribute::Sign(true),
56+
];
5357

5458
// generate a key pair
5559
let (public, private) =
@@ -93,7 +97,10 @@ fn sign_verify_eddsa() -> TestResult {
9397
]),
9498
];
9599

96-
let priv_key_template = vec![Attribute::Token(true)];
100+
let priv_key_template = vec![
101+
Attribute::Token(true),
102+
Attribute::Sign(true),
103+
];
97104

98105
let (public, private) =
99106
session.generate_key_pair(&mechanism, &pub_key_template, &priv_key_template)?;
@@ -136,7 +143,10 @@ fn sign_verify_eddsa_with_ed25519_schemes() -> TestResult {
136143
]),
137144
];
138145

139-
let priv_key_template = vec![Attribute::Token(true)];
146+
let priv_key_template = vec![
147+
Attribute::Token(true),
148+
Attribute::Sign(true),
149+
];
140150

141151
let (public, private) =
142152
session.generate_key_pair(&mechanism, &pub_key_template, &priv_key_template)?;
@@ -186,7 +196,10 @@ fn sign_verify_eddsa_with_ed448_schemes() -> TestResult {
186196
]),
187197
];
188198

189-
let priv_key_template = vec![Attribute::Token(true)];
199+
let priv_key_template = vec![
200+
Attribute::Token(true),
201+
Attribute::Sign(true),
202+
];
190203

191204
let (public, private) =
192205
session.generate_key_pair(&mechanism, &pub_key_template, &priv_key_template)?;
@@ -1339,9 +1352,10 @@ fn rsa_pkcs_oaep_empty() -> TestResult {
13391352
let session = pkcs11.open_rw_session(slot)?;
13401353
session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into())))?;
13411354

1342-
let pub_key_template = [Attribute::ModulusBits(2048.into())];
1355+
let pub_key_template = [Attribute::ModulusBits(2048.into()), Attribute::Encrypt(true)];
1356+
let priv_key_template = [Attribute::Decrypt(true)];
13431357
let (pubkey, privkey) =
1344-
session.generate_key_pair(&Mechanism::RsaPkcsKeyPairGen, &pub_key_template, &[])?;
1358+
session.generate_key_pair(&Mechanism::RsaPkcsKeyPairGen, &pub_key_template, &priv_key_template)?;
13451359
let oaep = PkcsOaepParams::new(
13461360
MechanismType::SHA1,
13471361
PkcsMgfType::MGF1_SHA1,
@@ -1509,6 +1523,7 @@ fn sign_verify_sha1_hmac() -> TestResult {
15091523
Attribute::Private(true),
15101524
Attribute::Sensitive(true),
15111525
Attribute::Sign(true),
1526+
Attribute::Verify(true),
15121527
Attribute::KeyType(KeyType::GENERIC_SECRET),
15131528
Attribute::Class(ObjectClass::SECRET_KEY),
15141529
Attribute::ValueLen(256.into()),
@@ -1538,6 +1553,7 @@ fn sign_verify_sha224_hmac() -> TestResult {
15381553
Attribute::Private(true),
15391554
Attribute::Sensitive(true),
15401555
Attribute::Sign(true),
1556+
Attribute::Verify(true),
15411557
Attribute::KeyType(KeyType::GENERIC_SECRET),
15421558
Attribute::Class(ObjectClass::SECRET_KEY),
15431559
Attribute::ValueLen(256.into()),
@@ -1567,6 +1583,7 @@ fn sign_verify_sha256_hmac() -> TestResult {
15671583
Attribute::Private(true),
15681584
Attribute::Sensitive(true),
15691585
Attribute::Sign(true),
1586+
Attribute::Verify(true),
15701587
Attribute::KeyType(KeyType::GENERIC_SECRET),
15711588
Attribute::Class(ObjectClass::SECRET_KEY),
15721589
Attribute::ValueLen(256.into()),
@@ -1596,6 +1613,7 @@ fn sign_verify_sha384_hmac() -> TestResult {
15961613
Attribute::Private(true),
15971614
Attribute::Sensitive(true),
15981615
Attribute::Sign(true),
1616+
Attribute::Verify(true),
15991617
Attribute::KeyType(KeyType::GENERIC_SECRET),
16001618
Attribute::Class(ObjectClass::SECRET_KEY),
16011619
Attribute::ValueLen(256.into()),
@@ -1625,6 +1643,7 @@ fn sign_verify_sha512_hmac() -> TestResult {
16251643
Attribute::Private(true),
16261644
Attribute::Sensitive(true),
16271645
Attribute::Sign(true),
1646+
Attribute::Verify(true),
16281647
Attribute::KeyType(KeyType::GENERIC_SECRET),
16291648
Attribute::Class(ObjectClass::SECRET_KEY),
16301649
Attribute::ValueLen(256.into()),

0 commit comments

Comments
 (0)