Skip to content

Commit 0e831d0

Browse files
author
Grant Sowards
committed
pkcs11/_pkcs11.pyx: rename p_auth -> use_protected_auth, use_pap -> use_protected_auth; types.py: add use_protected_auth to signature and doc string"
1 parent 7f62768 commit 0e831d0

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

pkcs11/_pkcs11.pyx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Slot(types.Slot):
225225
class Token(types.Token):
226226
"""Extend Token with implementation."""
227227

228-
def open(self, rw=False, user_pin=None, so_pin=None, p_auth=False):
228+
def open(self, rw=False, user_pin=None, so_pin=None, use_protected_auth=False):
229229
cdef CK_SESSION_HANDLE handle
230230
cdef CK_FLAGS flags = CKF_SERIAL_SESSION
231231
cdef CK_USER_TYPE user_type
@@ -235,11 +235,11 @@ class Token(types.Token):
235235

236236
if user_pin is not None and so_pin is not None:
237237
raise ArgumentsBad("Set either `user_pin` or `so_pin`")
238-
elif user_pin is not None and use_pap:
239-
raise ArgumentsBad("Set either `user_pin` or `p_auth`")
240-
elif so_pin is not None and use_pap:
241-
raise ArgumentsBad("Set either `so_pin` or `p_auth`")
242-
elif p_auth:
238+
elif user_pin is not None and use_protected_auth:
239+
raise ArgumentsBad("Set either `user_pin` or `use_protected_auth`")
240+
elif so_pin is not None and use_protected_auth:
241+
raise ArgumentsBad("Set either `so_pin` or `use_protected_auth`")
242+
elif use_protected_auth:
243243
pin = None
244244
user_type = CKU_USER
245245
elif user_pin is not None:
@@ -254,11 +254,11 @@ class Token(types.Token):
254254

255255
assertRV(_funclist.C_OpenSession(self.slot.slot_id, flags, NULL, NULL, &handle))
256256

257-
if p_auth:
257+
if use_protected_auth:
258258
if self.flags & TokenFlag.PROTECTED_AUTHENTICATION_PATH:
259-
assertRV(_funclist.C_Login(handle, user_type, NULL, < CK_ULONG > 0))
259+
assertRV(_funclist.C_Login(handle, user_type, NULL, <CK_ULONG> 0))
260260
else:
261-
raise ArgumentsBad('Protected authentication is not supported by loaded module')
261+
raise ArgumentsBad("Protected authentication is not supported by loaded module")
262262
elif pin is not None:
263263
assertRV(_funclist.C_Login(handle, user_type, pin, <CK_ULONG> len(pin)))
264264

pkcs11/types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def __init__(self, slot,
200200
def __eq__(self, other):
201201
return self.slot == other.slot
202202

203-
def open(self, rw=False, user_pin=None, so_pin=None):
203+
def open(self, rw=False, user_pin=None, so_pin=None, use_protected_auth=False):
204204
"""
205205
Open a session on the token and optionally log in as a user or
206206
security officer (pass one of `user_pin` or `so_pin`).
@@ -217,6 +217,7 @@ def open(self, rw=False, user_pin=None, so_pin=None):
217217
:param bytes user_pin: Authenticate to this session as a user.
218218
:param bytes so_pin: Authenticate to this session as a
219219
security officer.
220+
:param use_protected_auth: True to use protected authentication on a token
220221
221222
:rtype: Session
222223
"""

0 commit comments

Comments
 (0)