copyright | lastupdated | keywords | subcollection | ||
---|---|---|---|---|---|
|
2021-08-12 |
pkcs11 access, pkcs 11 authentication, set up PKCS 11 API, best practice for setting up pkcs11 users |
hs-crypto |
{:shortdesc: .shortdesc} {:codeblock: .codeblock} {:table: .aria-labeledby="caption"} {:pre: .pre} {:screen: .screen} {:tip: .tip} {:note: .note} {:important: .important} {:external: target="_blank" .external}
{: #best-practice-pkcs11-access}
To align with industry-standard security requirements and Permitted object accesses by sessions, it is suggested to set up the PKCS #11 user types in your {{site.data.keyword.hscrypto}} instance when you use the PKCS #11 API. {: shortdesc}
{: #pkcs11-user-types}
The PKCS #11 standard defines two user types: security officer and normal user. If a user does not perform a C_Login
function call, the user is considered as an anonymous user.
In the {{site.data.keyword.hscrypto}} PKCS #11 library configuration file grep11client.yaml
, the following user types are predefined, with each assigned a service ID API key:
-
Security officer (SO): An SO user can be a person who owns the SO API key in an enterprise. This person is able to initialize the PKCS #11 token and delete all key objects in keystores. This person can be the one who sets up the {{site.data.keyword.hscrypto}} instance and the {{site.data.keyword.iamshort}} (IAM) roles. The PKCS #11 application can perform administrative Cryptoki function calls, such as
C_InitToken
, after it logs in as an SO user type. -
Normal user: Normal users are the ones who have access to the normal user API key. The normal user API key needs to be distributed only to a limited group of people, who need access to the keystore where more sensitive keys are stored, such as keys for signing and encrypting contracts. In this case, the PKCS #11 application calls the
C_Login
function by using the normal user API key as the PIN and becomes a normal user to access the keystore. -
Anonymous user: The anonymous user API key can be distributed to anyone in the enterprise so that anonymous users can access the keystore to perform daily work, such as signing a document. The API key is configured in the PKCS #11 library configuration file
grep11client.yaml
and the anonymous user does not need to call theC_Login
function.
A PKCS #11 application works as only one of the three user types at any time, no matter how many sessions are opened. Each user type needs an API key for authentication. To create the API keys, you need to first create two custom IAM roles. And then, create service IDs for the three user types, and map the custom IAM roles to the service IDs.
To perform the following steps, you need to have the Administrator
platform access in your {{site.data.keyword.cloud}} account.
{: tip}
{: #step1-create-custom-roles}
You need to create two custom roles, one for operating keys and one for operating keystores.
{: #create-key-operator}
This role is used to generate and manage keys in the Enterprise PKCS #11 (EP11) keystores. However, this role does not have permissions to manage EP11 keystores.
- In the {{site.data.keyword.cloud_notm}} console, go to Manage > Access (IAM), and select Roles.
- Click Create.
- Enter a name for your role; for example,
key operator
. This name must be unique within the account. Users see this role name in the console when they assign access to the service. - Enter an ID for the role. This ID is used in the CRN, which is used when you assign access by using the API. The role ID must begin with a capital letter and use alphanumeric characters only; for example,
KeyOperator
- Optional: Enter a succinct and helpful description that helps the users who are assigning access know what level of access this role assignment gives a user. This description also shows in the console when a user assigns access to the service.
- From the list of services, select Hyper Protect Crypto Services.
- Select Add for the following actions:
- hs-crypto.crypto.decrypt
- hs-crypto.crypto.derivekey
- hs-crypto.crypto.digest
- hs-crypto.crypto.digestkey
- hs-crypto.crypto.encrypt
- hs-crypto.crypto.generatekey
- hs-crypto.crypto.generatekeypair
- hs-crypto.crypto.generaterandom
- hs-crypto.crypto.getattributevalue
- hs-crypto.crypto.getmechanisminfo
- hs-crypto.crypto.getmechanismlist
- hs-crypto.crypto.rewrapkeyblob
- hs-crypto.crypto.setattributevalue
- hs-crypto.crypto.sign
- hs-crypto.crypto.unwrapkey
- hs-crypto.crypto.verify
- hs-crypto.crypto.wrapkey
- hs-crypto.ep11.use
- hs-crypto.keystore.deletekey
- hs-crypto.keystore.listkeysbyattributes
- hs-crypto.keystore.listkeysbyids
- hs-crypto.keystore.storenewkey
- hs-crypto.keystore.updatekey
- Click Create when you're done adding actions.
{: #create-keystore-operator}
This role is used to create and delete EP11 keystores but does not have permissions to manage keys.
- In the {{site.data.keyword.cloud}} console, go to Manage > Access (IAM), and select Roles.
- Click Create.
- Enter a name for your role; for example,
keystore operator
. This name must be unique within the account. Users see this role name in the console when they assign access to the service. - Enter an ID for the role. This ID is used in the CRN, which is used when you assign access by using the API. The role ID must begin with a capital letter and use alphanumeric characters only; for example,
KeystoreOperator
- Optional: Enter a succinct and helpful description that helps the users who are assigning access know what level of access this role assignment gives a user. This description also shows in the console when a user assigns access to the service.
- From the list of services, select Hyper Protect Crypto Services.
- Select Add for the following actions:
- hs-crypto.keystore.createkeystore
- hs-crypto.keystore.deletekeystore
- hs-crypto.keystore.listkeystoresbyattributes
- hs-crypto.keystore.listkeystoresbyids
- Click Create when you're done adding actions.
For more information about how to create custom roles, see Creating custom roles.
{: #step2-create-service-id-api-key}
{: #create-service-id-api-key-so-user}
To create a service ID for the SO user and the corresponding API key, complete the following steps:
-
In the {{site.data.keyword.cloud_notm}} console, go to Manage > Access (IAM), and select Service IDs.
-
To create the service ID for the SO user, follow these steps:
- Click Create.
- Create a name
SO user
and description for the SO user service ID. - Click Create.
-
To create an API key for the service ID, follow these steps:
- Click the API keys tab on the
SO user
service ID page. - Click Create.
- Add a name and description to easily identify the API key, for example,
SO user API key
. - Click Create.
- Save your API key by copying or downloading it to secure location.
The API key is to be used as the PIN for the SO user logins, and cannot be retrieved. Make sure to make a copy of it in this step. {: important}
- Click the API keys tab on the
{: #create-service-id-api-key-normal-user}
To create a service ID for the normal user and the corresponding API key, complete the following steps:
-
In the {{site.data.keyword.cloud_notm}} console, go to Manage > Access (IAM), and select Service IDs.
-
To create the service ID for the normal user, follow these steps:
- Click Create.
- Create a name
Normal user
and description for the normal user service ID. - Click Create.
-
To create an API key for the service ID, follow these steps:
- Click the API keys tab on the
Normal user
service ID page. - Click Create.
- Add a name and description to easily identify the API key, for example,
Normal user API key
. - Click Create.
- Save your API key by copying or downloading it to secure location.
The API key is to be used as the PIN for the normal user logins, and cannot be retrieved. Make sure to make a copy of it in this step. {: important}
- Click the API keys tab on the
{: #create-service-id-api-key-ananymous-user}
To create a service ID for the anonymous user and the corresponding API key, complete the following steps:
-
In the {{site.data.keyword.cloud_notm}} console, go to Manage > Access (IAM), and select Service IDs.
-
To create the service ID for the anonymous user, follow these steps:
- Click Create.
- Create a name
Anonymous user
and description for the anonymous user service ID. - Click Create.
-
To create an API key for the service ID, follow these steps:
- Click the API keys tab on the
Anonymous user
service ID page. - Click Create.
- Add a name and description to easily identify the API key, for example,
Anonymous user API key
. - Click Create.
- Save your API key by copying or downloading it to secure location.
The API key is to be used as the PIN for the anonymous user logins, and cannot be retrieved. Make sure to make a copy of it in this step. {: important}
- Click the API keys tab on the
For more information about creating services IDs, see Creating and working with service IDs. For detailed instructions on creating service ID API keys, see Managing service ID API keys.
{: #step3-assign-iam-roles}
You can grant access to service IDs within a {{site.data.keyword.hscrypto}} service instance by using the {{site.data.keyword.cloud_notm}} console.
To assign the custom roles that are defined in Step 1 to the SO user service ID, follow these steps:
To assign access to the keystores for the SO user, follow these steps:
- From the menu bar, click Manage > Access (IAM), and select Service IDs to browse the existing service IDs in your account.
- Hover your mouse over the
SO user
service ID, and click the Actions icon to open a list of options. - From the options menu, click Assign access.
- Click Assign service ID additional access, and then click the IAM services button.
- Click No service access under What type of access do you want to assign? and select Hyper Protect Crypto Services.
- Under Service Instance ID, select the {{site.data.keyword.hscrypto}} service instance that you want to grant access to.
- Under Custom access, check the boxes for the following roles:
Keystore operator
Key operator
- Click Add, and then click Assign after confirmation.
To assign the custom roles that are defined in Step 1 to the normal user service ID, follow these steps:
To assign access to the keystores for the normal user, follow these steps:
- From the menu bar, click Manage > Access (IAM), and select Service IDs to browse the existing service IDs in your account.
- Hover your mouse over the
Normal user
service ID, and click the Actions icon to open a list of options. - From the options menu, click Assign access.
- Click Assign service ID additional access, and then click the IAM services button.
- Click No service access under What type of access do you want to assign? and select Hyper Protect Crypto Services.
- Under Service Instance ID, select the {{site.data.keyword.hscrypto}} service instance that you want to grant access to.
- Under Custom access, check the box for
Key operator
. - Click Add, and then click Assign after confirmation.
To assign the custom roles that are defined in Step 1 to the anonymous user service ID, follow these steps:
To assign access to the keystore for the anonymous user, follow these steps:
- From the menu bar, click Manage > Access (IAM), and select Service IDs to browse the existing service IDs in your account.
- Hover your mouse over the
Anonymous user
service ID, and click the Actions icon to open a list of options. - From the options menu, click Assign access.
- Click Assign service ID additional access, and then click the IAM services button.
- Click No service access under What type of access do you want to assign? and select Hyper Protect Crypto Services.
- Under Service Instance ID, select the {{site.data.keyword.hscrypto}} service instance that you want to grant access to.
- Under Custom access, check the box for
Key operator
. - Click Add, and then click Assign after confirmation.
{: #pkcs11-best-practices-next}
Continue to read Performing cryptographic operations with the PKCS #11 API on how to use the PKCS #11 API.