Customizing access control to the openCryptoki tokens
General access control
To properly configure the system, and to be authorized for performing the openCryptoki processes, for example, running the slot manager pkcsslotd, the pkcs11 group must be defined in file /etc/group of the system. Every openCryptoki user (including the pkcsslotd user running the slot manager, and including the users configuring openCryptoki and its tokens) must be members of this pkcs11 group. Use standard Linux® management operations to create the pkcs11 group if needed, and to add users to this group as required. Normally, the pkcs11 group is automatically created when installing openCryptoki from an RPM or DEB package.
You may also refer to the man page of openCryptoki (man openCryptoki) which has a SECURITY NOTE section that is important from the security perspective.
Individual access control
You can protect a token with its token directories and token objects so that only those users that are a member of a certain token-specific user group are allowed to access the token.
For a user who is a member of such a token specific user group, there are no differences in using openCryptoki. Users that are not a member of a token specific group, have no access to that token. They will not even see that token being available with pkcsconf -t or using the C_GetTokenInfo() function. Users must still be members of the pkcs11 group to be able to use openCryptoki in general. By default, all tokens remain to be owned by the pkcs11 group. If a token shall be access-protected, then an administrator with root access must explicitly configure that. The administrator must create a token-specific user group, add the desired users into it, and then configure openCryptoki and the token directories appropriately, as shown in the following procedure:
- Create a token-specific user group.
- Add all desired users into that group.
Make sure that all those users are also a member of the pkcs11 group.
- Stop the pkcsslotd daemon.
- Edit the opencryptoki.conf file residing in
/etc/opencryptoki and add the keyword
usergroup = <group-name>to the slot definition (also see Figure 1).This allows openCryptoki to set the owners correctly when creating new files (for example, new token objects). It also allows to verify - during startup of the slot daemon, as well as during C_Initialize() done by an application - that the token directory ownership matches the desired token-specific user group. If inconsistencies are detected, they are reported and the startup of the slot daemon fails, or the token is not available for applications.
If the
usergroupkeyword is omitted (which is the default), then the token is owned by the pkcs11 group. - Use the pkcstok_admin utility with the chown command to
change the owner of a token to the specified group (see Customizing token access control - pkcstok_admin utility).
This changes the owner of all directories, files, shared memory segments, and so on, that belong to the token to the specified group. The pkcstok_admin tool must be run by the root user and the pkcsslotd daemon must not be running while the pkcstok_admin tool is used.
- Restart the pkcsslotd daemon.
Besides changing user access of an existing token, you can also add a new token and configure access right away using the pkcstok_admin tool.