NXP Reader Library  v17.1.0.2535
Commands_Miscellaneous

These Components implement the MIFARE DESFire EVx Miscellaneous functions. These are not part of actual DESFire EVx data sheet rather its for internal purpose. More...

Collaboration diagram for Commands_Miscellaneous:

Functions

phStatus_t phalMfdfEVx_GetConfig (void *pDataParams, uint16_t wConfig, uint16_t *pValue)
 Perform a GetConfig command. More...
 
phStatus_t phalMfdfEVx_SetConfig (void *pDataParams, uint16_t wConfig, uint16_t wValue)
 Perform a SetConfig command. More...
 
phStatus_t phalMfdfEVx_ResetAuthentication (void *pDataParams)
 Reset the authentication. More...
 
phStatus_t phalMfdfEVx_GenerateDAMEncKey (void *pDataParams, uint16_t wKeyNoDAMEnc, uint16_t wKeyVerDAMEnc, uint16_t wKeyNoAppDAMDefault, uint16_t wKeyVerAppDAMDefault, uint8_t bAppDAMDefaultKeyVer, uint8_t *pDAMEncKey)
 Generates Encrypted Key for Delegated application management. More...
 
phStatus_t phalMfdfEVx_GenerateDAMMAC (void *pDataParams, uint8_t bOption, uint16_t wKeyNoDAMMAC, uint16_t wKeyVerDAMMAC, uint8_t *pAid, uint8_t *pDamParams, uint8_t bKeySettings1, uint8_t bKeySettings2, uint8_t bKeySettings3, uint8_t *pKeySetValues, uint8_t *pISOFileId, uint8_t *pISODFName, uint8_t bISODFNameLen, uint8_t *pEncK, uint8_t *pDAMMAC)
 Generate MAC for Delegated application management. More...
 
phStatus_t phalMfdfEVx_GenerateDAMMACSetConfig (void *pDataParams, uint16_t wKeyNoDAMMAC, uint16_t wKeyVerDAMMAC, uint16_t wOldDFNameLen, uint8_t *pOldISODFName, uint16_t wNewDFNameLen, uint8_t *pNewISODFName, uint8_t *pDAMMAC)
 Generates DAMMAC for Set Configuration with option 0x06 for Delegated Application. More...
 
phStatus_t phalMfdfEVx_CalculateTMV (void *pDataParams, uint16_t wOption, uint16_t wKeyNoTMACKey, uint16_t wKeyVerTMACKey, uint16_t wRamKeyNo, uint16_t wRamKeyVer, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pTMC, uint8_t *pUid, uint8_t bUidLen, uint8_t *pTMI, uint32_t dwTMILen, uint8_t *pTMV)
 Computed the Transaction MAC input as performed on the PICC. More...
 
phStatus_t phalMfdfEVx_DecryptReaderID (void *pDataParams, uint16_t wOption, uint16_t wKeyNoTMACKey, uint16_t wKeyVerTMACKey, uint16_t wRamKeyNo, uint16_t wRamKeyVer, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pTMC, uint8_t *pUid, uint8_t bUidLen, uint8_t *pEncTMRI, uint8_t *pTMRIPrev)
 Decrypted the reader ID as performed on the PICC. More...
 
phStatus_t phalMfdfEVx_ComputeMFCLicenseMAC (void *pDataParams, uint16_t wOption, uint16_t wMFCLicenseMACKeyNo, uint16_t wMFCLicenseMACKeyVer, uint8_t *pInput, uint16_t wInputLen, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pMFCLicenseMAC)
 Compute the MFCLicenseMAC for phalMfdfEVx_CreateMFCMapping and phalMfdfEVx_RestrictMFCUpdate command. More...
 
phStatus_t phalMfdfEVx_CalculateMACSDM (void *pDataParams, uint8_t bSdmOption, uint16_t wSDMMacKeyNo, uint16_t wSDMMacKeyVer, uint16_t wRamKeyNo, uint16_t wRamKeyVer, uint8_t *pUid, uint8_t bUidLen, uint8_t *SDMReadCtr, uint8_t *pInData, uint16_t wInDataLen, uint8_t *pRespMac)
 Calculate MAC SDM While using this command in SAM mode make sure the below points are taken care
SDMMacKeyNo and RamKeyNo should be off Offline_Crypto Keyclass. More...
 
phStatus_t phalMfdfEVx_DecryptSDMENCFileData (void *pDataParams, uint8_t bSdmOption, uint16_t wEncKeyNo, uint16_t wEncKeyVer, uint16_t wRamKeyNo, uint16_t wRamKeyVer, uint8_t *pUid, uint8_t bUidLen, uint8_t *pSDMReadCtr, uint8_t *pEncdata, uint16_t wInDataLen, uint8_t *pPlainData)
 Decrypt SDM enciphered data. More...
 
phStatus_t phalMfdfEVx_DecryptSDMPICCData (void *pDataParams, uint16_t wKeyNo, uint16_t wKeyVer, uint8_t *pEncdata, uint16_t wInDataLen, uint8_t *pPlainData)
 Decrypt SDM PICC Data. More...
 
phStatus_t phalMfdfEVx_SetVCAParams (void *pDataParams, void *pAlVCADataParams)
 This is a utility API which sets the VCA structure in DESFire EVx structure params. More...
 

Options to diversify the key.

#define PHAL_MFDFEVX_DIVERSIFICATION_OFF   0xFFFFU
 Option to disable key diversification.
 
#define PHAL_MFDFEVX_DIVERSIFICATION_ON   0x0000U
 Option to enable key diversification.
 

The configuration to be used for SetConfig / GetConfig.

#define PHAL_MFDFEVX_ADDITIONAL_INFO   0x00A1
 Option for GetConfig/SetConfig to get/set additional info of a generic error or some length exposed by interfaces.
 
#define PHAL_MFDFEVX_WRAPPED_MODE   0x00A2
 Option for GetConfig/SetConfig to get/set current status of command wrapping in ISO 7816-4 APDUs.
 
#define PHAL_MFDFEVX_SHORT_LENGTH_APDU   0x00A3
 Option for GetConfig/SetConfig to get/set current status of Short Length APDU wrapping in ISO 7816-4 APDUs.
 
#define PHAL_MFDFEVX_RETURN_FAB_ID   0x00A4
 Option for GetConfig/SetConfig to get/set Fabrication Identifier of the product. More...
 

The options to be used for GenerateDAMMAC.

#define PHAL_MFDFEVX_GENERATE_DAMMAC_CREATE_APPLICATION   0x00
 Option to indicate the DAMMAC generation is for phalMfdfEVx_CreateDelegatedApplication command.
 
#define PHAL_MFDFEVX_GENERATE_DAMMAC_DELETE_APPLICATION   0x80
 Option to indicate the DAMMAC generation is for phalMfdfEVx_DeleteApplication command.
 

Options for SDM information.

#define PHAL_MFDFEVX_VCUID_PRESENT   0x80U
 Only VCUID is considred for SDM Session key calculation.
 
#define PHAL_MFDFEVX_RDCTR_PRESENT   0x40U
 Only RDCTR is considred for SDM Session key calculation.
 

Detailed Description

These Components implement the MIFARE DESFire EVx Miscellaneous functions. These are not part of actual DESFire EVx data sheet rather its for internal purpose.

Macro Definition Documentation

◆ PHAL_MFDFEVX_RETURN_FAB_ID

#define PHAL_MFDFEVX_RETURN_FAB_ID   0x00A4

Option for GetConfig/SetConfig to get/set Fabrication Identifier of the product.

This will be utilized while performing GetVersion command.

Function Documentation

◆ phalMfdfEVx_GetConfig()

phStatus_t phalMfdfEVx_GetConfig ( void *  pDataParams,
uint16_t  wConfig,
uint16_t pValue 
)

Perform a GetConfig command.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wConfig[In] Configuration to read. Will be one of the below values.
[out]pValue[Out] The value for the mentioned configuration.

◆ phalMfdfEVx_SetConfig()

phStatus_t phalMfdfEVx_SetConfig ( void *  pDataParams,
uint16_t  wConfig,
uint16_t  wValue 
)

Perform a SetConfig command.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wConfig[In] Configuration to set. Will be one of the below values.
[in]wValue[In] The value for the mentioned configuration.

◆ phalMfdfEVx_ResetAuthentication()

phStatus_t phalMfdfEVx_ResetAuthentication ( void *  pDataParams)

Reset the authentication.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.

◆ phalMfdfEVx_GenerateDAMEncKey()

phStatus_t phalMfdfEVx_GenerateDAMEncKey ( void *  pDataParams,
uint16_t  wKeyNoDAMEnc,
uint16_t  wKeyVerDAMEnc,
uint16_t  wKeyNoAppDAMDefault,
uint16_t  wKeyVerAppDAMDefault,
uint8_t  bAppDAMDefaultKeyVer,
uint8_t pDAMEncKey 
)

Generates Encrypted Key for Delegated application management.

While using this command in SAM mode make sure the below points are taken care
KeyNoAppDAMDefault should have AllowDumpSecretKey enabled.
KeyNoDAMEnc should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]wKeyNoDAMEnc[In] Key number in key store of DAM Encryption key.
[in]wKeyVerDAMEnc[In] Key version in key store of DAM Encryption key.
[in]wKeyNoAppDAMDefault[In] Key number in key store of DAM default key.
[in]wKeyVerAppDAMDefault[In] Key version in key store of DAM default key.
[in]bAppDAMDefaultKeyVer[In] DAM Default Key version. Value should be valid for AES key. Ignored for other key types.
[out]pDAMEncKey[Out] Encrypted DAM Default key data.

◆ phalMfdfEVx_GenerateDAMMAC()

phStatus_t phalMfdfEVx_GenerateDAMMAC ( void *  pDataParams,
uint8_t  bOption,
uint16_t  wKeyNoDAMMAC,
uint16_t  wKeyVerDAMMAC,
uint8_t pAid,
uint8_t pDamParams,
uint8_t  bKeySettings1,
uint8_t  bKeySettings2,
uint8_t  bKeySettings3,
uint8_t pKeySetValues,
uint8_t pISOFileId,
uint8_t pISODFName,
uint8_t  bISODFNameLen,
uint8_t pEncK,
uint8_t pDAMMAC 
)

Generate MAC for Delegated application management.

While using this command in SAM mode make sure the below points are taken care
KeyNoDAMMAC should be off Offline_Crypto KeyClass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]bOption[In] Option to represent the present of ISO information.
[in]wKeyNoDAMMAC[In] Key number in key store of DAM MAC key.
[in]wKeyVerDAMMAC[In] Key version in key store of DAM MAC key.
[in]pAid[In] The application identifier to be used. Will be of 3 bytes with LSB first. If application 01 need to be created then the Aid will be 01 00 00.
[in]pDamParams[In] The DAM information. Should as mentioned below.
Byte0 = DAM Slot No [LSB]
Byte1 = DAM Slot No [MSB]
Byte2 = DAM Slot Version
Byte3 = Quota Limit [LSB]
Byte4 = Quota Limit [MSB]
[in]bKeySettings1[In] Application Key settings.
[in]bKeySettings2[In] Additional key settings.
[in]bKeySettings3[In] Additional key settings.
[in]pKeySetValues[In] The Key set values for the application. Should as mentioned below.
Byte0 = AKS ver
Byte1 = Number of KeySets
Byte2 = MaxKeysize
Byte3 = Application KeySet Settings.
[in]pISOFileId[In] ISO File ID to be used. Will be two bytes.
[in]pISODFName[In] ISO DF Name to be used. Will be 16 bytes and can also be NULL based on the option.
[in]bISODFNameLen[In] Length of bytes available in ISODFName buffer.
[in]pEncK[In] Encrypted initial application key. 32 bytes long.
[out]pDAMMAC[Out] 8 byte DAMMAC.

◆ phalMfdfEVx_GenerateDAMMACSetConfig()

phStatus_t phalMfdfEVx_GenerateDAMMACSetConfig ( void *  pDataParams,
uint16_t  wKeyNoDAMMAC,
uint16_t  wKeyVerDAMMAC,
uint16_t  wOldDFNameLen,
uint8_t pOldISODFName,
uint16_t  wNewDFNameLen,
uint8_t pNewISODFName,
uint8_t pDAMMAC 
)

Generates DAMMAC for Set Configuration with option 0x06 for Delegated Application.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]wKeyNoDAMMAC[In] Key number in key store of DAM MAC Key
[in]wKeyVerDAMMAC[In] Key version in key store of DAM MAC Key
[in]wOldDFNameLen[In] Length of existing DF Name
[in]pOldISODFName[In] This means already created delegated app ISO DF Name. Maximum 16 bytes
[in]wNewDFNameLen[In] Length of new DF Name
[in]pNewISODFName[In] This means new delegated app ISO DF Name which will replace the existing one. Maximum 16 bytes
[out]pDAMMAC[Out] Generated 8 bytes DAM MAC for setconfig option 0x06

◆ phalMfdfEVx_CalculateTMV()

phStatus_t phalMfdfEVx_CalculateTMV ( void *  pDataParams,
uint16_t  wOption,
uint16_t  wKeyNoTMACKey,
uint16_t  wKeyVerTMACKey,
uint16_t  wRamKeyNo,
uint16_t  wRamKeyVer,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pTMC,
uint8_t pUid,
uint8_t  bUidLen,
uint8_t pTMI,
uint32_t  dwTMILen,
uint8_t pTMV 
)

Computed the Transaction MAC input as performed on the PICC.

While using this command in SAM mode make sure the below points are taken care
KeyNoTMACKey and RamKeyNo should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]wOption[In] Diversification option.
[in]wKeyNoTMACKey[In] Key number to be used from software KeyStore.
[in]wKeyVerTMACKey[In] Key version to be used from software KeyStore.
[in]wRamKeyNo[In] Key number of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]wRamKeyVer[In] Key version of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]pDivInput[In] Diversification input to diversify TMACKey.
[in]bDivInputLen[In] Length of byte available in DivInput buffer.
[in]pTMC[In] 4 bytes Transaction MAC Counter. It should be 1 time subtracted from the actual value and should be LSB first.
[in]pUid[In] UID of the card.
[in]bUidLen[In] Length of UID supplied.
[in]pTMI[In] Transaction MAC Input.
[in]dwTMILen[In] Length of bytes available in TMI buffer.
[out]pTMV[Out] The computed Transaction MAC Value.

◆ phalMfdfEVx_DecryptReaderID()

phStatus_t phalMfdfEVx_DecryptReaderID ( void *  pDataParams,
uint16_t  wOption,
uint16_t  wKeyNoTMACKey,
uint16_t  wKeyVerTMACKey,
uint16_t  wRamKeyNo,
uint16_t  wRamKeyVer,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pTMC,
uint8_t pUid,
uint8_t  bUidLen,
uint8_t pEncTMRI,
uint8_t pTMRIPrev 
)

Decrypted the reader ID as performed on the PICC.

While using this command in SAM mode make sure the below points are taken care
KeyNoTMACKey and RamKeyNo should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]wOption[In] Diversification option.
[in]wKeyNoTMACKey[In] Key number to be used from software KeyStore.
[in]wKeyVerTMACKey[In] Key version to be used from software KeyStore.
[in]wRamKeyNo[In] Key number of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]wRamKeyVer[In] Key version of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]pDivInput[In] Diversification input to diversify TMACKey.
[in]bDivInputLen[In] Length of byte available in DivInput buffer.
[in]pTMC[In] 4 bytes Transaction MAC Counter. It should be 1 time subtracted from the actual value and shold be LSB first.
[in]pUid[In] UID of the card.
[in]bUidLen[In] Length of UID supplied.
[in]pEncTMRI[In] Encrypted Transaction MAC ReaderID of the latest successful transaction.
[out]pTMRIPrev[Out] Decrypted Reader ID of the last successful transaction.

◆ phalMfdfEVx_ComputeMFCLicenseMAC()

phStatus_t phalMfdfEVx_ComputeMFCLicenseMAC ( void *  pDataParams,
uint16_t  wOption,
uint16_t  wMFCLicenseMACKeyNo,
uint16_t  wMFCLicenseMACKeyVer,
uint8_t pInput,
uint16_t  wInputLen,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pMFCLicenseMAC 
)

Compute the MFCLicenseMAC for phalMfdfEVx_CreateMFCMapping and phalMfdfEVx_RestrictMFCUpdate command.

While using this command in SAM mode make sure the below points are taken care
MFCLicenseMACKeyNo should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]wOption[In] Diversification Option.
[in]wMFCLicenseMACKeyNo[In] Key number in key store for MFCLicenseMAC calculation.
[in]wMFCLicenseMACKeyVer[In] Key version in key store for MFCLicenseMAC calculation.
[in]pInput[In] The input for which the MAC should be computed. Input should be as follows. 0x01 || MFCLicense || MFCSectorSecrets
[in]wInputLen[In] Length of Bytes available in MFCLicenseMACIn buffer.
[in]pDivInput[In] Diversification input to diversify the Key.
[in]bDivInputLen[In] Length of Bytes available in DivInput buffer.
[out]pMFCLicenseMAC[Out] The computed MFCLicense MAC.

◆ phalMfdfEVx_CalculateMACSDM()

phStatus_t phalMfdfEVx_CalculateMACSDM ( void *  pDataParams,
uint8_t  bSdmOption,
uint16_t  wSDMMacKeyNo,
uint16_t  wSDMMacKeyVer,
uint16_t  wRamKeyNo,
uint16_t  wRamKeyVer,
uint8_t pUid,
uint8_t  bUidLen,
uint8_t SDMReadCtr,
uint8_t pInData,
uint16_t  wInDataLen,
uint8_t pRespMac 
)

Calculate MAC SDM While using this command in SAM mode make sure the below points are taken care
SDMMacKeyNo and RamKeyNo should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]bSdmOption[In] SDM Option to indicate which parameters to be considered.
[in]wSDMMacKeyNo[In] Key number to be used from software or hardware KeyStore.
[in]wSDMMacKeyVer[In] Key version to be used from software or hardware KeyStore.
[in]wRamKeyNo[In] Key number of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]wRamKeyVer[In] Key version of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]pUid[In] UID of the card.
[in]bUidLen[In] Length of bytes available in pUid buffer.
[in]SDMReadCtr[In] SDM Read Counter Input.
[in]pInData[In] Data read out from PICC that is between SDMMacInputoffset until SDMMACOffset.
[in]wInDataLen[In] Length of bytes available in InData buffer.
[out]pRespMac[Out] Computed SDM MAC.

◆ phalMfdfEVx_DecryptSDMENCFileData()

phStatus_t phalMfdfEVx_DecryptSDMENCFileData ( void *  pDataParams,
uint8_t  bSdmOption,
uint16_t  wEncKeyNo,
uint16_t  wEncKeyVer,
uint16_t  wRamKeyNo,
uint16_t  wRamKeyVer,
uint8_t pUid,
uint8_t  bUidLen,
uint8_t pSDMReadCtr,
uint8_t pEncdata,
uint16_t  wInDataLen,
uint8_t pPlainData 
)

Decrypt SDM enciphered data.

While using this command in SAM mode make sure the below points are taken care
EncKeyNo and RamKeyNo should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]bSdmOption[In] SDM Option to indicate which parameters to be considered.
[in]wEncKeyNo[In] Key number to be used from software or hardware KeyStore.
[in]wEncKeyVer[In] Key version to be used from software or hardware KeyStore.
[in]wRamKeyNo[In] Key number of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]wRamKeyVer[In] Key version of Destination Key where the computed session TMAC key will be stored. To be used for SAM AV3 only.
[in]pUid[In] UID of the card.
[in]bUidLen[In] Length of bytes available in pUid buffer.
[in]pSDMReadCtr[In] SDM Read Counter Input.
[in]pEncdata[In] Encrpted NonASCII SDM Encrypted File data.
[in]wInDataLen[In] Length of bytes available in EncData buffer.
[out]pPlainData[Out] The decrypted SDMFile data.

◆ phalMfdfEVx_DecryptSDMPICCData()

phStatus_t phalMfdfEVx_DecryptSDMPICCData ( void *  pDataParams,
uint16_t  wKeyNo,
uint16_t  wKeyVer,
uint8_t pEncdata,
uint16_t  wInDataLen,
uint8_t pPlainData 
)

Decrypt SDM PICC Data.

While using this command in SAM mode make sure the below points are taken care
KeyNo should be off Offline_Crypto Keyclass.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]wKeyNo[In] Key number to be used from software or hardware KeyStore.
[in]wKeyVer[In] Key version to be used from software or hardware KeyStore.
[in]pEncdata[In] Encrpted NonASCII SDM PICC data.
[in]wInDataLen[In] Length of bytes available in EncData buffer.
[out]pPlainData[Out] The decrypted SDM PICC Data.

◆ phalMfdfEVx_SetVCAParams()

phStatus_t phalMfdfEVx_SetVCAParams ( void *  pDataParams,
void *  pAlVCADataParams 
)

This is a utility API which sets the VCA structure in DESFire EVx structure params.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layers parameter structure.
[in]pAlVCADataParams[In] Pointer to VCA AL parameter structure.