Cryptographic Token Interface Standard

PKCS#11


Error code 'gotchas'

Here is a short list of a few particular things about return values that Cryptoki developers might want to be aware of:

  1. As mentioned in Sections 11.1.2 and 11.1.3, a Cryptoki library may not be able to make a distinction between a token being removed before a function invocation and a token being removed during a function invocation.

  2. As mentioned in Section 11.1.2, an application should never count on getting a CKR_SESSION_CLOSED error.

  3. The difference between CKR_DATA_INVALID and CKR_DATA_LEN_RANGE can be somewhat subtle. Unless an application needs to be able to distinguish between these return values, it is best to always treat them equivalently.

  4. Similarly, the difference between CKR_ENCRYPTED_DATA_INVALID and CKR_ENCRYPTED_DATA_LEN_RANGE, and between CKR_WRAPPED_KEY_INVALID and CKR_WRAPPED_KEY_LEN_RANGE, can be subtle, and it may be best to treat these return values equivalently.

  5. Even with the guidance of Section 10.1, it can be difficult for a Cryptoki library developer to know which of CKR_ATTRIBUTE_VALUE_INVALID, CKR_TEMPLATE_INCOMPLETE, or CKR_TEMPLATE_INCONSISTENT to return. When possible, it is recommended that application developers be generous in their interpretations of these error codes.


RSA Security Inc. Public-Key Cryptography Standards - PKCS#11 - v210