Skip to content

PIN Handling #50

Closed
Closed
@mike-boquard

Description

This issue is opened to continue the discussion started in #49 in regards to how user PINs are handled by the cryptoki library wrapper.

Currently, when a user wishes to login, they must first call set_pin in the Pkcs11 struct which stores the pin in a HashMap, keyed to the Slot. Then the user may call login on the created Session object.

Any other function that directly handles pins (those that expose the C_InitToken, C_InitPIN and C_SetPIN functionality) wraps the provided PIN within a Secret structure and passes a pointer to the appropriate PKCS#11 function. Upon completion of the function, the Secret structure will drop and zeroize the memory.

My first proposition is to drop the pins HashMap member in the Pkcs11 struct and provide a pins parameter to Session::login

First, if the user wishes to change which user is logged in (say going from CKU_USER to CKU_SO) the must call set_pin to change the pin and then call login. This requires the implementer to track which pin is currently being stored by the library to ensure they are logging in with the correct pin.

Secondly, and this is a personal preference thing, I do not believe the library should be storing the user's passwords. I believe the user should be the one that controls where their sensitive data is stored and be responsible for it, rather than ourselves.

Thirdly, and this is one of those weird PKCS#11 corner cases, there are situations where you may not want to provide a password to C_Login. For example, if the flag CKF_PROTECTED_AUTHENTICATION_PATH is set in token flags, that indicates there's a separate way of logging into the token (e.g. finger print reader, smart card reader, etc). In this situation, you must pass a NULL_PTR to C_Login to take advantage of that alternative authentication path.

My second proposition is to drop Secret and instead just pass the pointer from the provided str slice to the appropriate C_ function. If this isn't possible, then anytime a pin is provided and needs to be copied somewhere on the stack that is controlled by the library, then use Secret.

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions