NXP Reader Library  v17.1.0.2535

SAM commands used for MIFARE Plus PICC communication in X-Mode. More...

Collaboration diagram for X Mode:

Functions

phStatus_t phhalHw_SamAV3_Cmd_MFP_Authenticate (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bKeyNo, uint8_t bKeyVer, uint16_t wBlockNo, uint8_t *pPcdCapsIn, uint8_t bPcdCapsInLen, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pPcdCapsOut, uint8_t *pPdCaps, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Authenticate command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MFP_AuthSectorSwitch (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint16_t wSSKeyBNr, uint8_t bSSKeyNo, uint8_t bSSKeyVer, uint8_t bMSKeyNo, uint8_t bMSKeyVer, uint8_t bSectorCount, uint8_t *pKeyBlocks, uint8_t bKeyBlocksLen, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Sector Switch Authenticate command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_PDC_Authenticate (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bKeyNo, uint8_t bKeyVer, uint16_t wUpgradeKey, uint8_t *pUpgradeInfo, uint8_t bLen, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Post Delivery configuration Authenticate command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MFP_CombinedRead (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pReadCmd, uint8_t bReadCmdLen, uint8_t **ppData, uint16_t *pDataLen, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Combined Read command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MFP_CombinedWrite (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pData, uint8_t bDataLen, uint8_t *pTMC, uint8_t *pTMV, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Combined Write command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MFP_ChangeKey (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bCmdCode, uint16_t wBlockNo, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Change Key command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MFP_WritePerso (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Write Perso command in X mode. More...
 

MIFARE Plus instruction codes.

#define PHHAL_HW_SAMAV3_CMD_MFP_AUTHENTICATE_INS   0x70
 Sam AV3 Insturction code for MFP_Authenticate command.
 
#define PHHAL_HW_SAMAV3_CMD_MFP_AUTH_SECTOR_SWITCH_INS   0x72
 Sam AV3 Insturction code for MFP_AuthentSectorSwitch command.
 
#define PHHAL_HW_SAMAV3_CMD_PDC_AUTHENTICATE_INS   0x73
 CMD Byte for MFPEV1_AuthenticatePDC command.
 
#define PHHAL_HW_SAMAV3_CMD_MFP_COMBINED_READ_INS   0x31
 Sam AV3 Insturction code for MFP_CombinedRead command.
 
#define PHHAL_HW_SAMAV3_CMD_MFP_COMBINED_WRITE_INS   0x32
 Sam AV3 Insturction code for MFP_CombinedWrite command.
 
#define PHHAL_HW_SAMAV3_CMD_MFP_CHANGE_KEY_INS   0xA5
 CMD Byte for MFPEV1_ChangeKey command.
 
#define PHHAL_HW_SAMAV3_CMD_MFP_WRITE_PERSO_INS   0xA8
 Sam AV3 Insturction code for MFP_WritePerso command.
 

Detailed Description

SAM commands used for MIFARE Plus PICC communication in X-Mode.

Function Documentation

◆ phhalHw_SamAV3_Cmd_MFP_Authenticate()

phStatus_t phhalHw_SamAV3_Cmd_MFP_Authenticate ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint16_t  wBlockNo,
uint8_t pPcdCapsIn,
uint8_t  bPcdCapsInLen,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pPcdCapsOut,
uint8_t pPdCaps,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Authenticate command in X mode.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bOption[In] Option for Authenticate command.
[in]bKeyNo[In] Key number to be used from Sam keystore.
[in]bKeyVer[In] Key version to be used from Sam keystore.
[in]wBlockNo[In] PICC block number to be used for authentication.
[in]pPcdCapsIn[In] Buffer containing the input PcdCaps.
[in]bPcdCapsInLen[In] Input PCD capabilites to be exchanged.
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInputLen[In] Length of diversification input used to diversify the key.
[out]pPcdCapsOut[Out] Buffer containing the Output PCD capabilities. This will be of 6 bytes.
[out]pPdCaps[Out] Buffer containing the Output PD capabilities. This will be of 6 bytes.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_MFP_AuthSectorSwitch()

phStatus_t phhalHw_SamAV3_Cmd_MFP_AuthSectorSwitch ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint16_t  wSSKeyBNr,
uint8_t  bSSKeyNo,
uint8_t  bSSKeyVer,
uint8_t  bMSKeyNo,
uint8_t  bMSKeyVer,
uint8_t  bSectorCount,
uint8_t pKeyBlocks,
uint8_t  bKeyBlocksLen,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Sector Switch Authenticate command in X mode.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option flag to buffer the payload information.
[in]wSSKeyBNr[In] PICC Sector Switch key block number to be used for authentication.
[in]bSSKeyNo[In] Key number to be used from Sam keystore.
[in]bSSKeyVer[In] Key version to be used from Sam keystore.
[in]bMSKeyNo[In] Key number to be used from Sam keystore if master sector key in enabled.
[in]bMSKeyVer[In] Key version to be used from Sam keystore if master sector key in enabled.
[in]bSectorCount[In] Number of sectors to be switched inside the PICC.
[in]pKeyBlocks[In] Buffer containing the PICC KeyB block number and reference key number and version to be used form Sam keystore.
The format of the buffer should be,
KeyBxBNr_1 + KeyNo_1 + KeyVer_1, KeyBxBNr_2 + KeyNo_2 + KeyVer_2, ..., KeyBxBNr_N + KeyNo_N + KeyVer_N, Where N equal to the SectorCount information.
[in]bKeyBlocksLen[In] Length of bytes available in KeyBlocks buffer. It should be equal to (KeyBxBNr + KeyNo + KeyVer) * SectorCount
[in]pDivInput[In] Buffer containing the diversification inputs to be used for diversifying the key.
The format of the buffer should be,
SSKeyDivLen + SSKeyDivInput + KeyBxDivLen + KeyBxDivInput
[in]bDivInputLen[In] Length of bytes available in DivInput buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_PDC_Authenticate()

phStatus_t phhalHw_SamAV3_Cmd_PDC_Authenticate ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint16_t  wUpgradeKey,
uint8_t pUpgradeInfo,
uint8_t  bLen,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Post Delivery configuration Authenticate command in X mode.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bOption[In] Option to set the P1 information byte.
[in]bKeyNo[In] Key number to be used from Sam keystore.
[in]bKeyVer[In] Key version to be used from Sam keystore.
[in]wUpgradeKey[In] PICC UpgradeKey to be used for authentication.
[in]pUpgradeInfo[In] Upgrade information of the target product state.
[in]bLen[In] Length of bytes available in UpgradeInfo buffer.
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInputLen[In] Length of diversification input used to diversify the key.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_MFP_CombinedRead()

phStatus_t phhalHw_SamAV3_Cmd_MFP_CombinedRead ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pReadCmd,
uint8_t  bReadCmdLen,
uint8_t **  ppData,
uint16_t pDataLen,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Combined Read command in X mode.

This command is used to perform GetVersion, ReadSignature and all Read related operations.

Returns
Status code
Return values
PH_ERR_SUCCESS_CHAININGsuccessfull chaining operation.
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option for receiving the next data chunk if previous status was chaining.
[in]pReadCmd[In] The different types of command to be sent.
GetVersion: GetVersion cmd (1byte)
ReadSig : Read Signature cmd (1byte) + Address (1byte)
Read : Read cmd (1byte) + BlockNr (2byte) + NoBlocks (1byte)
[in]bReadCmdLen[In] Length of bytes available in ReadCmd buffer.
[out]ppData[Out] The information returned by Sam hardware for the mentioned command in ReadCmd buffer.
[out]pDataLen[Out] Length of bytes available in Data buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_MFP_CombinedWrite()

phStatus_t phhalHw_SamAV3_Cmd_MFP_CombinedWrite ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pData,
uint8_t  bDataLen,
uint8_t pTMC,
uint8_t pTMV,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Combined Write command in X mode.

This command performs Write, Increment, Decrement, Transfer, Restore, IncrementTransfer and DecrementTransfer commands of the PICC.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option flag to buffer the payload information.
[in]pData[In] The data to be sent to Sam hardware. Should be one of the following.
For WRITExy : Write Cmd (1byte) + BNR (2byte) + PlainData (N * 16 bytes)
For INCx : Inc Cmd (1byte) + BNR (2byte) + PlainData (4bytes)
For DECx : Dec Cmd (1byte) + BNR (2byte) + PlainData (4bytes)
For INCTx : Inc Transfer Cmd (1byte) + BNR (4byte) + PlainData (4bytes)
For DECTx : Dec Transfer Cmd (1byte) + BNR (4byte) + PlainData (4bytes)
For TRFx : Transfer Cmd (1byte) + BNR (2byte)
For RESx : Restore Cmd (1byte) + BNR (2byte)
[in]bDataLen[In] Length of bytes available in Data buffer.
[out]pTMC[Out] Only available is the block is a TMProtected block. The buffer will have 4 bytes of Transaction MAC counter information.
[out]pTMV[Out] Only available is the block is a TMProtected block. The buffer will have 8 bytes of Transaction MAC value.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_MFP_ChangeKey()

phStatus_t phhalHw_SamAV3_Cmd_MFP_ChangeKey ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bCmdCode,
uint16_t  wBlockNo,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Change Key command in X mode.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bOption[In] Option flag to update the P1 information byte.
[in]bCmdCode[In] The write comamnd code to be used for writting the key. (0xA0 or 0xA1)
[in]wBlockNo[In] PICC block number to be used for changing the key.
[in]bKeyNo[In] Key number to be used from Sam keystore.
[in]bKeyVer[In] Key version to be used from Sam keystore.
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInputLen[In] Length of diversification input used to diversify the key.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_MFP_WritePerso()

phStatus_t phhalHw_SamAV3_Cmd_MFP_WritePerso ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Write Perso command in X mode.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option flag to buffer the payload information.
[in]pBlocks[In] Buffer containing the Block and Data pair to be written to card by Sam hardware.
Should be holding an array of block number and data like BNR_1 + Data, BNR_2 + Data, BNR_3 + Data, ..., BNR_N + Data
BNR_x should be 2 bytes and Data should 16 bytes.
[in]bBlocksLen[In] Length representing the block and data pair available in pBlocks parameter.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.