PKCS#11 v2.20 specifications, pag. 95 states:
CKR_KEY_FUNCTION_NOT_PERMITTED: An attempt has been made to use a
key for a cryptographic purpose that the key’s attributes are not set to allow it to do.
For example, to use a key for performing encryption, that key must have its
CKA_ENCRYPT attribute set to CK_TRUE (the fact that the key must have a
CKA_ENCRYPT attribute implies that the key cannot be a private key). This return
value has lower priority than CKR_KEY_TYPE_INCONSISTENT.
When do you get error 6 (FUNCTION_FAILED)?