Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ repos:
- "--py39-plus"

- repo: "https://github.com/psf/black-pre-commit-mirror"
rev: "25.12.0"
rev: "26.3.1"
hooks:
- id: "black"

- repo: "https://github.com/pycqa/isort"
rev: "7.0.0"
rev: "8.0.1"
hooks:
- id: "isort"
args: ["--profile", "black", "--filter-files"]

- repo: "https://github.com/python-jsonschema/check-jsonschema"
rev: "0.36.0"
rev: "0.37.1"
hooks:
- id: "check-github-workflows"

- repo: "https://github.com/rhysd/actionlint"
rev: "v1.7.10"
rev: "v1.7.12"
hooks:
- id: "actionlint"
1 change: 0 additions & 1 deletion samples/destroy_by_ID.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import PyKCS11

# the CKA_ID of the objects to destroy
Expand Down
2 changes: 1 addition & 1 deletion samples/ec_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
(PyKCS11.CKA_ID, key_id),
]

(pub_key, priv_key) = session.generateKeyPair(
pub_key, priv_key = session.generateKeyPair(
ec_public_tmpl, ec_priv_tmpl, mecha=PyKCS11.MechanismECGENERATEKEYPAIR
)

Expand Down
1 change: 0 additions & 1 deletion samples/ec_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import binascii

import PyKCS11
Expand Down
1 change: 0 additions & 1 deletion samples/encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import binascii

import PyKCS11
Expand Down
1 change: 0 additions & 1 deletion samples/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import getinfo

import PyKCS11
Expand Down
2 changes: 1 addition & 1 deletion samples/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(PyKCS11.CKA_ID, key_id),
]

(pubKey, privKey) = session.generateKeyPair(pubTemplate, privTemplate)
pubKey, privKey = session.generateKeyPair(pubTemplate, privTemplate)

# logout
session.logout()
Expand Down
1 change: 0 additions & 1 deletion samples/getinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import getopt
import platform
import sys
Expand Down
1 change: 0 additions & 1 deletion samples/modulus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import binascii

from PyKCS11 import (
Expand Down
2 changes: 1 addition & 1 deletion samples/rsa_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(PyKCS11.CKA_ID, (0x43,)),
]

(pubKey, privKey) = session.generateKeyPair(pubTemplate, privTemplate)
pubKey, privKey = session.generateKeyPair(pubTemplate, privTemplate)

PLAINTEXT = "A test string"
mech = PyKCS11.RSAOAEPMechanism(PyKCS11.CKM_SHA_1, PyKCS11.CKG_MGF1_SHA1)
Expand Down
1 change: 0 additions & 1 deletion samples/unblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
"""


import PyKCS11

pin = "1234"
Expand Down
2 changes: 1 addition & 1 deletion src/PyKCS11/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def waitForSlotEvent(self, flags=0):
:rtype: integer
"""
tmp = 0
(rv, slot) = self.lib.C_WaitForSlotEvent(flags, tmp)
rv, slot = self.lib.C_WaitForSlotEvent(flags, tmp)
if rv != CKR_OK:
raise PyKCS11Error(rv)

Expand Down
20 changes: 15 additions & 5 deletions src/PyKCS11/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@
CKA["CKA_VALIDATION_COUNTRY"] = CKA_VALIDATION_COUNTRY
CKA[CKA_VALIDATION_COUNTRY] = "CKA_VALIDATION_COUNTRY"

CKA_VALIDATION_CERTIFICATE_IDENTIFIER = PyKCS11.LowLevel.CKA_VALIDATION_CERTIFICATE_IDENTIFIER
CKA_VALIDATION_CERTIFICATE_IDENTIFIER = (
PyKCS11.LowLevel.CKA_VALIDATION_CERTIFICATE_IDENTIFIER
)
CKA["CKA_VALIDATION_CERTIFICATE_IDENTIFIER"] = CKA_VALIDATION_CERTIFICATE_IDENTIFIER
CKA[CKA_VALIDATION_CERTIFICATE_IDENTIFIER] = "CKA_VALIDATION_CERTIFICATE_IDENTIFIER"

Expand Down Expand Up @@ -1756,11 +1758,15 @@
CKM["CKM_SHA512_T_KEY_DERIVATION"] = CKM_SHA512_T_KEY_DERIVATION
CKM[CKM_SHA512_T_KEY_DERIVATION] = "CKM_SHA512_T_KEY_DERIVATION"

CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE = PyKCS11.LowLevel.CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE
CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE = (
PyKCS11.LowLevel.CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE
)
CKM["CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE"] = CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE
CKM[CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE] = "CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE"

CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH = PyKCS11.LowLevel.CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH
CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH = (
PyKCS11.LowLevel.CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH
)
CKM["CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH"] = CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH
CKM[CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH] = "CKM_TLS12_EXTENDED_MASTER_KEY_DERIVE_DH"

Expand Down Expand Up @@ -2992,7 +2998,9 @@
CKM["CKM_X9_42_DH_PARAMETER_GEN"] = CKM_X9_42_DH_PARAMETER_GEN
CKM[CKM_X9_42_DH_PARAMETER_GEN] = "CKM_X9_42_DH_PARAMETER_GEN"

CKM_DSA_PROBABILISTIC_PARAMETER_GEN = PyKCS11.LowLevel.CKM_DSA_PROBABILISTIC_PARAMETER_GEN
CKM_DSA_PROBABILISTIC_PARAMETER_GEN = (
PyKCS11.LowLevel.CKM_DSA_PROBABILISTIC_PARAMETER_GEN
)
CKM["CKM_DSA_PROBABILISTIC_PARAMETER_GEN"] = CKM_DSA_PROBABILISTIC_PARAMETER_GEN
CKM[CKM_DSA_PROBABILISTIC_PARAMETER_GEN] = "CKM_DSA_PROBABILISTIC_PARAMETER_GEN"

Expand Down Expand Up @@ -3660,7 +3668,9 @@
CKR["CKR_UNWRAPPING_KEY_SIZE_RANGE"] = CKR_UNWRAPPING_KEY_SIZE_RANGE
CKR[CKR_UNWRAPPING_KEY_SIZE_RANGE] = "CKR_UNWRAPPING_KEY_SIZE_RANGE"

CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT = PyKCS11.LowLevel.CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT = (
PyKCS11.LowLevel.CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
)
CKR["CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT"] = CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
CKR[CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT] = "CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT"

Expand Down
2 changes: 1 addition & 1 deletion test/test_asymetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setUp(self):
(PyKCS11.CKA_ID, keyID),
]

(self.pubKey, self.privKey) = self.session.generateKeyPair(
self.pubKey, self.privKey = self.session.generateKeyPair(
pubTemplate, privTemplate
)
self.assertIsNotNone(self.pubKey)
Expand Down
8 changes: 4 additions & 4 deletions test/test_asymetric_ECC.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def setUp(self):
(PyKCS11.CKA_ID, keyID),
]

(self.pubKey, self.privKey) = self.session.generateKeyPair(
self.pubKey, self.privKey = self.session.generateKeyPair(
ec_public_tmpl, ec_priv_tmpl, mecha=PyKCS11.MechanismECGENERATEKEYPAIR
)
self.assertIsNotNone(self.pubKey)
Expand Down Expand Up @@ -176,7 +176,7 @@ def _generate_edwards_key_pair(self, curve):
ec_params = PrivateKeyAlgorithmId(curve).dump()
ec_public_tmpl = self.ec_public_tmpl + [(PyKCS11.CKA_EC_PARAMS, ec_params)]

(pubKey, privKey) = self.session.generateKeyPair(
pubKey, privKey = self.session.generateKeyPair(
ec_public_tmpl,
self.ec_priv_tmpl,
mecha=PyKCS11.Mechanism(PyKCS11.CKM_EC_EDWARDS_KEY_PAIR_GEN, None),
Expand All @@ -192,7 +192,7 @@ def _generate_edwards_key_pair(self, curve):
def test_sign_integer(self):
toSign = 1234567890
mecha = PyKCS11.EDDSA_Mechanism()
(pubKey, privKey) = self._generate_edwards_key_pair("ed25519")
pubKey, privKey = self._generate_edwards_key_pair("ed25519")

# sign/verify
with self.assertRaises(PyKCS11.PyKCS11Error) as cm:
Expand Down Expand Up @@ -225,7 +225,7 @@ def test_sign_text(self):
for curve, phflag, context in schemes:
with self.subTest(curve=curve, phflag=phflag, context=context):
mech = self._get_eddsa_mechanism(phflag, context)
(pubKey, privKey) = self._generate_edwards_key_pair(curve)
pubKey, privKey = self._generate_edwards_key_pair(curve)
# sign/verify
signature = self.session.sign(privKey, toSign, mech)

Expand Down
2 changes: 1 addition & 1 deletion test/test_asymetric_gost.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_gost(self):
# test generate gost key pair
gen_mechanism = PyKCS11.Mechanism(PyKCS11.CKM_GOSTR3410_KEY_PAIR_GEN, None)
try:
(self.pubKey, self.privKey) = self.session.generateKeyPair(
self.pubKey, self.privKey = self.session.generateKeyPair(
pubTemplate, privTemplate, gen_mechanism
)
except PyKCS11.PyKCS11Error as e:
Expand Down