Skip to content

Commit 548056a

Browse files
keldoninMatthiasValvekens
authored andcommitted
fix for issue #140
- Adding a default mechanism for `CKK_GENERIC_SECRET` key type - Fixing condition for including `CKA_VALUE_LEN` when generating a secret key. It is now skipped only for those algorithms that do not want it.
1 parent 0f8134e commit 548056a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pkcs11/_pkcs11.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class Session(types.Session):
658658
Attribute.DERIVE: MechanismFlag.DERIVE & capabilities,
659659
}
660660

661-
if key_type is KeyType.AES:
661+
if key_type not in (KeyType.DES2, KeyType.DES3, KeyType.GOST28147, KeyType.SEED):
662662
if key_length is None:
663663
raise ArgumentsBad("Must provide `key_length'")
664664

pkcs11/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
KeyType.RSA: Mechanism.RSA_PKCS_KEY_PAIR_GEN,
2727
KeyType.X9_42_DH: Mechanism.X9_42_DH_KEY_PAIR_GEN,
2828
KeyType.EC_EDWARDS: Mechanism.EC_EDWARDS_KEY_PAIR_GEN,
29+
KeyType.GENERIC_SECRET: Mechanism.GENERIC_SECRET_KEY_GEN,
2930
}
3031
"""
3132
Default mechanisms for generating keys.

0 commit comments

Comments
 (0)