FreeRTOS: PKCS11
PKCS11 Cryptoki Library
Return to main page ↑
iot_pkcs11_pal.h File Reference

Port Specific File Access functions for PKCS #11. More...

Go to the source code of this file.

Functions

CK_RV PKCS11_PAL_Initialize (void)
 Initializes the PKCS #11 PAL. More...
 
CK_OBJECT_HANDLE PKCS11_PAL_SaveObject (CK_ATTRIBUTE_PTR pxLabel, CK_BYTE_PTR pucData, CK_ULONG ulDataSize)
 Saves an object in non-volatile storage. More...
 
CK_RV PKCS11_PAL_DestroyObject (CK_OBJECT_HANDLE xHandle)
 Delete an object from NVM. More...
 
CK_OBJECT_HANDLE PKCS11_PAL_FindObject (CK_BYTE_PTR pxLabel, CK_ULONG usLength)
 Translates a PKCS #11 label into an object handle. More...
 
CK_RV PKCS11_PAL_GetObjectValue (CK_OBJECT_HANDLE xHandle, CK_BYTE_PTR *ppucData, CK_ULONG_PTR pulDataSize, CK_BBOOL *pIsPrivate)
 Gets the value of an object in storage, by handle. More...
 
void PKCS11_PAL_GetObjectValueCleanup (CK_BYTE_PTR pucData, CK_ULONG ulDataSize)
 Cleanup after PKCS11_GetObjectValue(). More...
 

Detailed Description

Port Specific File Access functions for PKCS #11.

Function Documentation

◆ PKCS11_PAL_Initialize()

CK_RV PKCS11_PAL_Initialize ( void  )

Initializes the PKCS #11 PAL.

This is always called first in C_Initialize if the module is not already initialized.

Returns
CKR_OK on success. CKR_FUNCTION_FAILED on failure.

◆ PKCS11_PAL_SaveObject()

CK_OBJECT_HANDLE PKCS11_PAL_SaveObject ( CK_ATTRIBUTE_PTR  pxLabel,
CK_BYTE_PTR  pucData,
CK_ULONG  ulDataSize 
)

Saves an object in non-volatile storage.

Port-specific file write for cryptographic information.

Parameters
[in]pxLabelAttribute containing label of the object to be stored.
[in]pucDataThe object data to be saved.
[in]ulDataSizeSize (in bytes) of object data.
Returns
The object handle if successful. eInvalidHandle = 0 if unsuccessful.

◆ PKCS11_PAL_DestroyObject()

CK_RV PKCS11_PAL_DestroyObject ( CK_OBJECT_HANDLE  xHandle)

Delete an object from NVM.

Parameters
[in]xHandleHandle to a PKCS #11 object.

◆ PKCS11_PAL_FindObject()

CK_OBJECT_HANDLE PKCS11_PAL_FindObject ( CK_BYTE_PTR  pxLabel,
CK_ULONG  usLength 
)

Translates a PKCS #11 label into an object handle.

Port-specific object handle retrieval.

Parameters
[in]pxLabelPointer to the label of the object who's handle should be found.
[in]usLengthThe length of the label, in bytes.
Returns
The object handle if operation was successful. Returns eInvalidHandle if unsuccessful.

◆ PKCS11_PAL_GetObjectValue()

CK_RV PKCS11_PAL_GetObjectValue ( CK_OBJECT_HANDLE  xHandle,
CK_BYTE_PTR *  ppucData,
CK_ULONG_PTR  pulDataSize,
CK_BBOOL *  pIsPrivate 
)

Gets the value of an object in storage, by handle.

Port-specific file access for cryptographic information.

This call dynamically allocates the buffer which object value data is copied into. PKCS11_PAL_GetObjectValueCleanup() should be called after each use to free the dynamically allocated buffer.

See also
PKCS11_PAL_GetObjectValueCleanup
Parameters
[in]xHandleThe PKCS #11 object handle of the object to get the value of.
[out]ppucDataPointer to buffer for file data.
[out]pulDataSizeSize (in bytes) of data located in file.
[out]pIsPrivateBoolean indicating if value is private (CK_TRUE) or exportable (CK_FALSE)
Returns
CKR_OK if operation was successful. CKR_KEY_HANDLE_INVALID if no such object handle was found, CKR_DEVICE_MEMORY if memory for buffer could not be allocated, CKR_FUNCTION_FAILED for device driver error.

◆ PKCS11_PAL_GetObjectValueCleanup()

void PKCS11_PAL_GetObjectValueCleanup ( CK_BYTE_PTR  pucData,
CK_ULONG  ulDataSize 
)

Cleanup after PKCS11_GetObjectValue().

Parameters
[in]pucDataThe buffer to free. (*ppucData from PKCS11_PAL_GetObjectValue())
[in]ulDatasizeThe length of the buffer to free. (*pulDataSize from PKCS11_PAL_GetObjectValue())