uFCoder 2.58
Loading...
Searching...
No Matches
PKI infrastructure and digital signature support

Functions

UFR_STATUS DL_API JCAppSelectByAid (IN const uint8_t *aid, uint8_t aid_len, OUT uint8_t selection_response[16])
 
UFR_STATUS DL_API JCAppPutPrivateKey (uint8_t key_type, uint8_t key_index, IN const uint8_t *key, uint16_t key_bit_len, const IN uint8_t *key_param, uint16_t key_parm_len)
 
UFR_STATUS DL_API JCAppSignatureBegin (uint8_t cipher, uint8_t digest, uint8_t padding, uint8_t key_index, IN const uint8_t *chunk, uint16_t chunk_len, IN const uint8_t *alg_param, uint16_t alg_parm_len)
 
UFR_STATUS DL_API JCAppSignatureUpdate (IN const uint8_t *chunk, uint16_t chunk_len)
 
UFR_STATUS DL_API JCAppSignatureEnd (VAR uint16_t *sig_len)
 
UFR_STATUS DL_API JCAppGenerateSignature (uint8_t cipher, uint8_t digest, uint8_t padding, uint8_t key_index, IN const uint8_t *plain_data, uint16_t plain_data_len, VAR uint16_t *sig_len, IN const uint8_t *alg_param, uint16_t alg_parm_len)
 
UFR_STATUS DL_API JCAppGetSignature (OUT uint8_t *sig, uint16_t sig_len)
 
UFR_STATUS DL_API JCAppPutObj (uint8_t obj_type, uint8_t obj_index, IN uint8_t *obj, int16_t obj_size, IN uint8_t *id, uint8_t id_size)
 
UFR_STATUS DL_API JCAppPutObjSubject (uint8_t obj_type, uint8_t obj_index, IN uint8_t *subject, uint8_t size)
 
UFR_STATUS DL_API JCAppInvalidateCert (uint8_t obj_type, uint8_t obj_index)
 
UFR_STATUS DL_API JCAppGetObjId (uint8_t obj_type, uint8_t obj_index, OUT uint8_t *id, VAR uint16_t *id_size)
 
UFR_STATUS DL_API JCAppGetObjSubject (uint8_t obj_type, uint8_t obj_index, OUT uint8_t *subject, VAR uint16_t *size)
 
UFR_STATUS DL_API JCAppGetObj (uint8_t obj_type, uint8_t obj_index, OUT uint8_t *obj, int16_t size)
 

Detailed Description

Function Documentation

◆ JCAppSelectByAid()

UFR_STATUS DL_API JCAppSelectByAid ( IN const uint8_t * aid,
uint8_t aid_len,
OUT uint8_t selection_response[16] )

Using this function you can select the appropriate application on the card. For the DLSigner JCApp AID should be 'F0 44 4C 6F 67 69 63 00 01'. For the DLStorage JCApp AID should be 'F0 44 4C 6F 67 69 63 01 01'. Before calling this function, the NFC tag must be in ISO 14443-4 mode. For entering ISO 14443-4 mode use the SetISO14443_4_Mode() or SetISO14443_4_Mode_GetATS() function.

Parameters
aidPointer to array containing AID (Application ID) i.e: "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01" for the DLSigner or "\xF0\x44\x4C\x6F\x67\x69\x63\x01\x01" for the DLStorage JCApp.
aid_lenLength of the AID in bytes (9 for the DLSigner or DLStorage JCApps).
selection_responseOn Application successful selection, the card returns 16 bytes. In the current version only the first of those bytes (i.e. byte with index 0) is relevant and contains JCApp card type which is 0xA0 for actual revision.
Returns
Operation status

◆ JCAppPutPrivateKey()

UFR_STATUS DL_API JCAppPutPrivateKey ( uint8_t key_type,
uint8_t key_index,
IN const uint8_t * key,
uint16_t key_bit_len,
const IN uint8_t * key_param,
uint16_t key_parm_len )

In JCApp cards you can put two types of asymmetric crypto keys. Those are RSA and ECDSA private keys, three of each. Before you can use a JCApp card for digital signing you have to put an appropriate private key in it. There is no way to read out private keys from the card. Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". This feature is disabled in the regular DLSigner JCApp. To acquire cards with this feature enabled you have to contact your supplier with a special request. Prior to calling this function you have to be logged in with an SO PIN code.

Parameters
key_type0 for RSA private key and 1 for ECDSA private key.
key_indexFor each of the card types there are 3 different private keys that you can set. Their indexes are from 0 to 2.
keyPointer to array containing key bytes.
key_bit_lenKey length in bits.
key_paramReserved for future use (RFU). Use null for this parameter.
key_parm_lenReserved for future use (RFU). Use 0 for this parameter.
Returns
Operation status

◆ JCAppSignatureBegin()

UFR_STATUS DL_API JCAppSignatureBegin ( uint8_t cipher,
uint8_t digest,
uint8_t padding,
uint8_t key_index,
IN const uint8_t * chunk,
uint16_t chunk_len,
IN const uint8_t * alg_param,
uint16_t alg_parm_len )

Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01".

Parameters
cipher0 for the RSA private key and 1 for the ECDSA.
digest0 for none digest (not supported with ECDSA) and 1 for SHA1
padding0 for none (not supported with RSA) and 1 for pads the digest according to the PKCS#1 (v1.5) scheme.
key_indexFor each of the card types there are 3 different private keys that you can set. Their indexes are from 0 to 2.
chunkPointer to array containing first chunk of data.
chunk_lenLength of the first chunk of data (max. 255).
alg_paramReserved for future use (RFU). Use null for this parameter.
alg_parm_lenReserved for future use (RFU). Use 0 for this parameter.
Returns
Operation status

◆ JCAppSignatureUpdate()

UFR_STATUS DL_API JCAppSignatureUpdate ( IN const uint8_t * chunk,
uint16_t chunk_len )

Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01".

Parameters
chunkPointer to an array containing one of the chunks of data.
chunk_lenLength of the current one of the remaining chunks of data (max. 255).
Returns
Operation status

◆ JCAppSignatureEnd()

UFR_STATUS DL_API JCAppSignatureEnd ( VAR uint16_t * sig_len)

Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01".

Parameters
sig_lenPointer to a 16-bit value in which you will get length of the signature in case of a successful executed chain of function calls, described in the introduction of this topic.
Returns
Operation status

◆ JCAppGenerateSignature()

UFR_STATUS DL_API JCAppGenerateSignature ( uint8_t cipher,
uint8_t digest,
uint8_t padding,
uint8_t key_index,
IN const uint8_t * plain_data,
uint16_t plain_data_len,
VAR uint16_t * sig_len,
IN const uint8_t * alg_param,
uint16_t alg_parm_len )

This function virtually combines three successive calls of functions JCAppSignatureBegin(), JCAppSignatureUpdate() and JCAppSignatureEnd() and can be used in case your data for signing have 255 bytes or less. Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". Prior to calling this function you have to be logged in with a User PIN code.

Parameters
cipher0 for the RSA private key and 1 for the ECDSA.
digest0 for none digest (not supported with ECDSA) and 1 for SHA1
padding0 for none (not supported with RSA) and 1 for pads the digest according to the PKCS#1 (v1.5) scheme.
key_indexFor each of the card types there are 3 different private keys that you can set. Their indexes are from 0 to 2.
plain_dataPointer to array containing data for signing.
plain_data_lenLength of the data for signing (max. 255).
sig_lenPointer to a 16-bit value in which you will get the length of the signature in case of successful execution.
alg_paramReserved for future use (RFU). Use null for this parameter.
alg_parm_lenReserved for future use (RFU). Use 0 for this parameter.
Returns
Operation status

◆ JCAppGetSignature()

UFR_STATUS DL_API JCAppGetSignature ( OUT uint8_t * sig,
uint16_t sig_len )

Finally, to get a signature, you have to call JCAppGetSignature(). Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". Prior calling of this function you have to be logged in with an User PIN code.

Parameters
sigPointer to an array of “sig_len” bytes length. Value of the “sig_len” you've got as a parameter of the JCAppSignatureEnd() or JCAppGenerateSignature() functions. You have to allocate those bytes before calling this function.
sig_lenLength of the allocated bytes in a sig array.
Returns
Operation status

◆ JCAppPutObj()

UFR_STATUS DL_API JCAppPutObj ( uint8_t obj_type,
uint8_t obj_index,
IN uint8_t * obj,
int16_t obj_size,
IN uint8_t * id,
uint8_t id_size )

Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". Prior to calling this function you have to be logged in with an SO PIN code.

Parameters
obj_type0 for certificate containing RSA public key, 1 for certificate containing ECDSA public key and 2 for the CA (certificate authority).
obj_indexFor each of the certificates containing RSA or ECDSA public keys there are 3 different corresponding private keys that should be set before placing the certificates themselves. Their indexes are from 0 to 2. For CA there are 12 memory slots so their indexes can be from 0 to 11.
objPointer to an array containing an object (certificate).
obj_sizeLength of the object (certificate).
idPointer to an array containing object id. Object id is a symbolic value and has to be unique on the card.
id_sizeLength of the object id. Minimum object id length can be 1 and maximum 253.
Returns
Operation status

◆ JCAppPutObjSubject()

UFR_STATUS DL_API JCAppPutObjSubject ( uint8_t obj_type,
uint8_t obj_index,
IN uint8_t * subject,
uint8_t size )

Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". Prior to calling of this function you have to be logged in with an SO PIN code.

Parameters
obj_type0 for certificate containing RSA public key, 1 for certificate containing ECDSA public key and 2 for the CA (certificate authority).
obj_indexFor each of the certificates containing RSA or ECDSA public keys there are 3 different corresponding private keys that should be set before placing the certificates themselves. Their indexes are from 0 to 2. For CA there are 12 memory slots so their indexes can be from 0 to 11.
subjectPointer to an array containing subject. Subject is a symbolic value linked to an appropriate certificate by the same obj_type and index.
sizeLength of the subject. Maximum subject length is 255.
Returns
Operation status

◆ JCAppInvalidateCert()

UFR_STATUS DL_API JCAppInvalidateCert ( uint8_t obj_type,
uint8_t obj_index )

Using this function you can delete certificate objects from a card. This includes subjects linked to a certificate. Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". Prior to calling this function you have to be logged in with an SO PIN code.

Parameters
obj_type0 for certificate containing RSA public key, 1 for certificate containing ECDSA public key and 2 for the CA (certificate authority).
obj_indexFor each of the certificates containing RSA or ECDSA public keys there are 3 different corresponding private keys that should be set before placing the certificates themselves. Their indexes are from 0 to 2. For CA there are 12 memory slots so their indexes can be from 0 to 11.
Returns
Operation status

◆ JCAppGetObjId()

UFR_STATUS DL_API JCAppGetObjId ( uint8_t obj_type,
uint8_t obj_index,
OUT uint8_t * id,
VAR uint16_t * id_size )

This function you always have to call 2 times. Before the first call you have to set parameter id to null and you will get the id_size of the obj_type at obj_index. Before the second call you have to allocate an array of the returned id_size bytes and pass that array using parameter id. Before second call, *id_size should be set to a value of the exact bytes allocated. Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". This function does not require to be logged in with any of the PIN codes.

Parameters
obj_type0 for certificate containing RSA public key, 1 for certificate containing ECDSA public key and 2 for the CA (certificate authority).
obj_indexFor each of the certificates containing RSA or ECDSA public keys there are 3 different corresponding private keys that should be set before placing the certificates themselves. Their indexes are from 0 to 2. For CA there are 12 memory slots so their indexes can be from 0 to 11.
idWhen id == NULL, the function returns id_size.
id_sizeBefore second call, *id_size should be set to a value of the exact bytes allocated.
Returns
Operation status

◆ JCAppGetObjSubject()

UFR_STATUS DL_API JCAppGetObjSubject ( uint8_t obj_type,
uint8_t obj_index,
OUT uint8_t * subject,
VAR uint16_t * size )

This function you always have to call 2 times. Before the first call you have to set the parameter subject to null and you will get the size of the obj_type at obj_index. Before the second call you have to allocate an array of returned size bytes and pass that array using parameter subject. Before second call, *size should be set to a value of the exact bytes allocated. Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". This function does not require to be logged in with any of the PIN codes.

Parameters
obj_type0 for certificate containing RSA public key, 1 for certificate containing ECDSA public key and 2 for the CA (certificate authority).
obj_indexFor each of the certificates containing RSA or ECDSA public keys there are 3 different corresponding private keys that should be set before placing the certificates themselves. Their indexes are from 0 to 2. For CA there are 12 memory slots so their indexes can be from 0 to 11.
subjectWhen subject == NULL, function returns size.
sizeBefore second call, *size should be set to a value of the exact bytes allocated.
Returns
Operation status

◆ JCAppGetObj()

UFR_STATUS DL_API JCAppGetObj ( uint8_t obj_type,
uint8_t obj_index,
OUT uint8_t * obj,
int16_t size )

This function you always have to call 2 times. Before the first call you have to set parameter id to null and you will get the id_size of the obj_type at obj_index. Before the second call you have to allocate an array of the returned id_size bytes and pass that array using parameter id. Before second call, *id_size should be set to a value of the exact bytes allocated. Before calling this function, NFC tag must be in ISO 14443-4 mode and JCApp should be selected using JCAppSelectByAid() with AID = "\xF0\x44\x4C\x6F\x67\x69\x63\x00\x01". This function does not require to be logged in with any of the PIN codes.

Parameters
obj_type0 for certificate containing RSA public key, 1 for certificate containing ECDSA public key and 2 for the CA (certificate authority).
obj_indexFor each of the certificates containing RSA or ECDSA public keys there are 3 different corresponding private keys that should be set before placing the certificates themselves. Their indexes are from 0 to 2. For CA there are 12 memory slots so their indexes can be from 0 to 11.
objWhen obj == NULL, function returns size.
sizeBefore second call, *size should be set to a value of the exact bytes allocated.
Returns
Operation status