Go to the documentation of this file.
26 #ifndef _IOT_PKCS11_H_
27 #define _IOT_PKCS11_H_
32 #pragma pack(push, cryptoki, 1)
60 #define CK_DEFINE_FUNCTION( returnType, name ) returnType name
66 #define CK_DECLARE_FUNCTION( returnType, name ) returnType name
72 #define CK_DECLARE_FUNCTION_POINTER( returnType, name ) returnType( CK_PTR name )
78 #define CK_CALLBACK_FUNCTION( returnType, name ) returnType( CK_PTR name )
83 #define pkcs11SHA256_DIGEST_LENGTH 32UL
90 #define pkcs11ECDSA_P256_SIGNATURE_LENGTH 64UL
95 #define pkcs11ECDSA_P256_KEY_BITS 256UL
100 #define pkcs11RSA_PUBLIC_EXPONENT { 0x01, 0x00, 0x01 }
106 #define pkcs11RSA_2048_MODULUS_BITS 2048UL
111 #define pkcs11RSA_2048_SIGNATURE_LENGTH ( pkcs11RSA_2048_MODULUS_BITS / 8UL )
119 #define pkcs11RSA_SIGNATURE_INPUT_LENGTH 51UL
125 #define pkcs11ELLIPTIC_CURVE_NISTP256 "1.2.840.10045.3.1.7"
130 #define pkcs11MAX_LABEL_LENGTH 32UL
135 #define pkcs11DER_ENCODED_OID_P256 { 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07 }
143 #ifndef pkcs11configIMPORT_PRIVATE_KEYS_SUPPORTED
144 #define pkcs11configIMPORT_PRIVATE_KEYS_SUPPORTED 1
166 #define pkcs11STUFF_APPENDED_TO_RSA_SIG { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 }
171 #if defined( __PASTE ) && defined( __CC_ARM )
181 typedef struct PKCS11_CertificateTemplate
258 CK_ULONG * pxSlotCount );
303 CK_OBJECT_CLASS xClass,
304 CK_OBJECT_HANDLE_PTR pxHandle );
328 uint8_t * puc51ByteHashOidBuffer );
332 #pragma pack(pop, cryptoki)
CK_ATTRIBUTE xObjectClass
CKA_CLASS, set to CKO_CERTIFICATE.
Definition: iot_pkcs11.h:183
Certificate Template The object class must be the first attribute in the array.
Definition: iot_pkcs11.h:182
Definition: pkcs11t.h:565
CK_RV xInitializePkcs11Token(void)
Initializes a PKCS #11 module and token.
CK_ATTRIBUTE xTokenObject
CKA_TOKEN.
Definition: iot_pkcs11.h:188
CK_ATTRIBUTE xLabel
CKA_LABEL.
Definition: iot_pkcs11.h:187
CK_RV vAppendSHA256AlgorithmIdentifierSequence(const uint8_t *puc32ByteHashedMessage, uint8_t *puc51ByteHashOidBuffer)
Appends digest algorithm sequence to SHA-256 hash for RSA signatures.
CK_RV xInitializePKCS11(void)
Initializes a PKCS #11 session.
CK_RV xGetSlotList(CK_SLOT_ID **ppxSlotId, CK_ULONG *pxSlotCount)
Get a list of available PKCS #11 slots.
CK_ATTRIBUTE xCertificateType
CKA_CERTIFICATE_TYPE, set to CKC_X_509.
Definition: iot_pkcs11.h:185
CK_RV xInitializePkcs11Session(CK_SESSION_HANDLE *pxSession)
Initializes the PKCS #11 module and opens a session.
CK_ATTRIBUTE xValue
CKA_VALUE, the DER byte array of the certificate contents.
Definition: iot_pkcs11.h:186
CK_ATTRIBUTE xSubject
CKA_SUBJECT, this parameter is required by the PKCS #11 standard.
Definition: iot_pkcs11.h:184
CK_RV xFindObjectWithLabelAndClass(CK_SESSION_HANDLE xSession, char *pcLabelName, CK_OBJECT_CLASS xClass, CK_OBJECT_HANDLE_PTR pxHandle)
Searches for an object with a matching label and class provided.