PKCS#11 – Sample Application#
PKCS#11 library includes sample application code for customer reference to demonstrate use of the following:
C_GetSlotListto find the slot and token you require.C_GetSlotInfoto print the slot description.C_GetTokenInfoto obtain information about a particular token, token status, and the status of a token’s secure storage.NVIDIA channel extension APIs
C_NVIDIA_InitializeChannel,C_NVIDIA_OpenSession, andC_NVIDIA_FinalizeChannelto:Redirect digest operation and sign and verify operations with
CKM_SHA256_HMACon to a different SHA engine from the default.Redirect large sign and verify operations on random data in a single part with
CKM_AES_GMACon to an AES engine.
C_UnwrapKeyto provision a wrapped key usingCKM_NVIDIA_AES_GCM_KEY_UNWRAP.Wrap and unwrap an ephemeral session key using
CKM_AES_CBCand retrieval of the IV generated during the wrap operation (the same IV is required to successfully unwrap the key).CKM_NVIDIA_AES_CBC_KEY_DATA_WRAPmechanism with aCK_NVIDIA_AES_CBC_KEY_DATA_WRAP_PARAMSmechanism parameter to wrap either one secret key, or a pair of secret keys with custom data interleaved between the two.Commit a key to secure storage using
C_NVIDIA_CommitTokenObjects.Encrypt with
CKM_AES_GCMand retrieval of the IV generated during the encrypt operation withC_NVIDIA_EncryptGetIV.Derive a GCM encrypt and decrypt key using
CKM_TLS12_KEY_SAFE_DERIVEmechanism withCKA_NVIDIA_CALLER_NONCEattribute set to allow the user to supply their own IV.Perform ECDSA sign/verify operation using
CKM_ECDSAmechanism.C_GenerateKeyPairto generate EC key pair usingCKM_EC_KEY_PAIR_GENmechanism, and use the key pair to derive a shared key usingC_DeriveKeywithCKM_ECDH1_DERIVEmechanism.Create a
CKO_DATAobject usingC_CreateObject, retrieve the attribute from the target object handle usingC_GetAttributeValue, and copy the data object usingC_CopyObject.Verify an RSA signature using
CKM_RSA_PKCS_PSS.Perform AES-GCM encryption/decryption using
C_MessageEncryptInit,C_EncryptMessage,C_MessageEncryptFinal, and the decrypt equivalents.Perform encryption/decryption for multipart data using
C_EncryptInit,C_EncryptUpdate,C_EncryptFinal,C_DecryptInit,C_DecryptUpdate, andC_DecryptFinalwith theCKM_AES_CBCmechanism.Sign and verify multipart messages using the message-based API (
C_MessageSignInit,C_SignMessageBegin,C_SignMessageNext,C_MessageSignFinal,C_MessageVerifyInit,C_VerifyMessageBegin,C_VerifyMessageNext,C_MessageVerifyFinal) with theCKM_AES_GMACmechanism.Perform encryption/decryption for multipart data using the message-based API (
C_MessageEncryptInit,C_EncryptMessageBegin,C_EncryptMessageNext,C_MessageEncryptFinal,C_MessageDecryptInit,C_DecryptMessageBegin,C_DecryptMessageNext,C_MessageDecryptFinal) with theCKM_AES_CBCmechanism.Derive an AES key using
CKM_TLS12_KDFand use it to encrypt data with theCKM_AES_CBCmechanism.Perform sign and verify operations with the
CKM_TLS12_MACmechanism.Derive encryption and MAC keys using
CKM_TLS12_KEY_AND_MAC_DERIVE.Encrypt/decrypt with
CKM_AES_CTRand retrieval of the IV generated during the encrypt operation withC_NVIDIA_EncryptGetIV.Perform maximum size in a single part encryption and decryption using
CKM_AES_CBC_PAD.NVIDIA ChannelId extension APIs to discover available channels using
C_NVIDIA_GetChannelIdListand to query per-channel attributes, including maximum buffer size and channel label, usingC_NVIDIA_GetChannelIdAttributeValue.Derive a CMAC key using
CKM_SP800_108_COUNTER_KDFwithCKM_AES_CMACPRF and use it to sign and verify the provided data.Mechanisms:
CKM_EDDSACKM_SP800_108_COUNTER_KDFCKM_SHA256CKM_SHA512CKM_NVIDIA_SP800_56C_TWO_STEPS_KDFCKM_AES_GCMCKM_AES_CMACCKM_AES_CBCCKM_AES_KEY_GENCKM_NVIDIA_AES_CBC_KEY_DATA_WRAPCKM_NVIDIA_AES_GCM_KEY_UNWRAPCKM_TLS12_KEY_SAFE_DERIVECKM_ECDSACKM_EC_KEY_PAIR_GENCKM_ECDH1_DERIVECKM_RSA_PKCS_PSSCKM_AES_GMACCKM_TLS12_KDFCKM_TLS12_MACCKM_TLS12_KEY_AND_MAC_DERIVECKM_AES_CTRCKM_AES_CBC_PAD
Refer to the following README for instructions to build the sample application, pkcs11_reference_application:
samples/nvpkcs11/external/README