NXP Reader Library  v17.1.0.2535

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

Collaboration diagram for X_Mode:

Modules

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

Functions

phStatus_t phhalHw_Sam_Cmd_MFP_Authenticate (phhalHw_Sam_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)
 The MFP_Authenticate supports the PICC authentication in X-mode. More...
 
phStatus_t phhalHw_Sam_Cmd_MFP_AuthSectorSwitch (phhalHw_Sam_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)
 The MFP_AuthSectorSwitch supports the X-mode procedure to switch the security level of MIFARE Plus sectors on the PICC. More...
 
phStatus_t phhalHw_Sam_Cmd_PDC_Authenticate (phhalHw_Sam_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)
 The PDC_Authenticate supports the X-mode procedure to perform the Post-Delivery configuration on the PICC. More...
 
phStatus_t phhalHw_Sam_Cmd_MFP_CombinedRead (phhalHw_Sam_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_Sam_Cmd_MFP_CombinedWrite (phhalHw_Sam_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_Sam_Cmd_MFP_ChangeKey (phhalHw_Sam_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_Sam_Cmd_MFP_WritePerso (phhalHw_Sam_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t *pPiccReturnCode)
 MFP_WritePerso is a multi-block write command. More...
 

Detailed Description

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

Function Documentation

◆ phhalHw_Sam_Cmd_MFP_Authenticate()

phStatus_t phhalHw_Sam_Cmd_MFP_Authenticate ( phhalHw_Sam_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 
)

The MFP_Authenticate supports the PICC authentication in X-mode.

It performs an authentication with the PICC and upon success generates the session keys.

Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpPcdCapsIn, pDivInput, pPcdCapsOut, pPdCaps and pPiccReturnCode are NULL.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bOption[In] Key diversification & authentication mode selection. Option to update the P1 information. The options can be combined by bitwise oring.
[in]bKeyNo[In] Key number to be used from SAM. One of the following,
  • NVM Key: 0x00 - 0x7F
  • RAM Key: 0xE0 - 0xE3
[in]bKeyVer[In] Key version to be used from SAM.
[in]wBlockNo[In] MIFARE Plus block number of key to be used for authentication.
[in]pPcdCapsIn[In] Buffer containing the Input PCD capabilites.
[in]bPcdCapsInLen[In] Input PCD capabilites Length to be exchanged. One of the following,
[in]pDivInput[In] Diversification Input used to diversify the key.
  • If any of diversification option is set in bOption parameter, then
    • 8 (if AV1 key diversification with DES)
    • 16 (if AV1 key diversification with AES) bytes
    • 1 to 31 bytes (if AV2 key diversification) diversification input
  • NULL otherwise
[in]bDivInputLen[In] Length of bytes available in pDivInput buffer.
[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 Plus PICC. This will of 1 byte in length.

◆ phhalHw_Sam_Cmd_MFP_AuthSectorSwitch()

phStatus_t phhalHw_Sam_Cmd_MFP_AuthSectorSwitch ( phhalHw_Sam_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 
)

The MFP_AuthSectorSwitch supports the X-mode procedure to switch the security level of MIFARE Plus sectors on the PICC.

Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpKeyBlocks, pDivInput and pPiccReturnCode are NULL.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Buffering options and Key diversification selection, for exchanging information to SAM. The options can be combined by bitwise oring.
[in]wSSKeyBNr[In] PICC Sector Switch key block number to be used for authentication.
[in]bSSKeyNo[In] Sector Switch Key number to be used from SAM (that is: Kss selection). One of the following,
  • NVM Key: 0x00 - 0x7F
  • RAM Key: 0xE0 - 0xE3
[in]bSSKeyVer[In] Sector Switch Key version to be used from SAM (that is: Kss selection)
[in]bMSKeyNo[In] Master Key number to be used from SAM One of the following,
  • NVM Key: 0x00 - 0x7F
  • RAM Key: 0xE0 - 0xE3
[in]bMSKeyVer[In] Master Key version to be used from SAM.
[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. Should contain the following,
  • KeyBxBNr: 2 byte Key Block sector number on the PICC (encoded MSB first)
  • KeyNo: If no sector number key diversification, SAM Key Number of the block sector key (that is: Kn selection).
    • NVM Key: 0x00 - 0x7F
    • RAM Key: 0xE0 - 0xE3
  • KeyVer: If no sector number key diversification, SAM Key Version of the block sector key (that is: Kn selection).
  • 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 bSectorCount information.
[in]bKeyBlocksLen[In] Length of bytes available in pKeyBlocks buffer. It should be equal to (KeyBxBNr + [KeyNo] + [KeyVer]) * bSectorCount
[in]pDivInput[In] Buffer containing the diversification inputs to be used for diversifying the key.
  • SSKeyDivLen: Optional, present if Sector Switch Diversification is enabled, Length of the Sector Switch Key DivInput (and of Sector Keys DivInput if using same)
  • SSKeyDivInput: Optional, present if Sector Switch Diversification is enabled, 1 to 31 bytes diversification input for Sector Switch Key (and for Sector Keys if using same)
  • KeyBxDivLen: Optional, present if Sector Diversification is enabled. One of the following,
    • Using same DivInput for Sector Switch Key and Sector Keys: 0x00
    • Using different DivInput for Sector keys: 0x01 - 0x1F
  • KeyBxDivInput: Optional, present if Sector Diversification is enabled and KeyBxDivLen != 0x00. 1 to 31 bytes diversification input for Sector Keys
  • The format of the buffer should be, [[SSKeyDivLen] || [SSKeyDivInput]] || [[KeyBxDivLen] || [KeyBxDivInput]]
[in]bDivInputLen[In] Length of bytes available in pDivInput buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE Plus PICC. This will of 1 byte in length.

◆ phhalHw_Sam_Cmd_PDC_Authenticate()

phStatus_t phhalHw_Sam_Cmd_PDC_Authenticate ( phhalHw_Sam_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 
)

The PDC_Authenticate supports the X-mode procedure to perform the Post-Delivery configuration on the PICC.

Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpUpgradeInfo, pDivInput and pPiccReturnCode are NULL.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bOption[In] Key diversification selection. Option to set the P1 information byte.
  • No derivation
  • Derive UpgradeKey from targeted ICUpgradeKey given UpgradeInfo
  • Diversify the targeted YearUpgradeKey with the given DivInput and then derive the actual UpgradeKey with UpgradeInfo
[in]bKeyNo[In] Key number to be used from SAM. One of the following,
  • NVM Key: 0x00 - 0x7F
  • RAM Key: 0xE0 - 0xE3
[in]bKeyVer[In] Key version to be used from SAM.
[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 pUpgradeInfo buffer.
  • 0x00: No key derivation
  • 0x01 - 0x08: Key derivation involving UpgradeInfo
[in]pDivInput[In] Diversification input for generating KeyID.ICUpgrade Key , ie.: VCUID.
[in]bDivInputLen[In] Length of bytes available in pDivInput buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE Plus PICC. This will of 1 byte in length.

◆ phhalHw_Sam_Cmd_MFP_CombinedRead()

phStatus_t phhalHw_Sam_Cmd_MFP_CombinedRead ( phhalHw_Sam_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.

Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_SUCCESS_CHAININGSuccessfull Chaining operation.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpReadCmd, pDataLen and pPiccReturnCode are NULL.
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 from SAM was chaining.
[in]pReadCmd[In] The different types of command to be sent to MIFARE Plus PICC and received the response.
  • 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 pReadCmd buffer.
[out]ppData[Out] The information returned by SAM for the mentioned command in pReadCmd buffer.
[out]pDataLen[Out] Length of bytes available in ppData buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE Plus PICC. This will of 1 byte in length.

◆ phhalHw_Sam_Cmd_MFP_CombinedWrite()

phStatus_t phhalHw_Sam_Cmd_MFP_CombinedWrite ( phhalHw_Sam_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.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpReadCmd, pDataLen and pPiccReturnCode are NULL.
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 different types of command to be sent to MIFARE Plus PICC and received the response,
  • 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 pData 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 Plus PICC. This will of 1 byte in length.

◆ phhalHw_Sam_Cmd_MFP_ChangeKey()

phStatus_t phhalHw_Sam_Cmd_MFP_ChangeKey ( phhalHw_Sam_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.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpDivInput and pPiccReturnCode are NULL.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bOption[In] The below flags should be for updating the P1 information byte.
[in]bCmdCode[In] The MIFARE Plus Write (Cmd.WRITEEy) command code to be used for writting the key. (0xA0 or 0xA1)
[in]wBlockNo[In] MIFARE Plus Key Block number
  • 0x4000 ... 0x4FFF, 0x8000 ... 0xAFFF, 0xCXX0, 0xCXX1
  • With X any value in 0x0..0xF. Therefore the latter two values cover: 0xC000, 0xC001, 0xC010, 0xC011, 0xC020, 0xC021, ... till 0xCFF0, 0xCFF1
[in]bKeyNo[In] Key number to be used from SAM. One of the following,
  • NVM Key: 0x00 - 0x7F
  • RAM Key: 0xE0 - 0xE3.
[in]bKeyVer[In] Key version to be used from SAM.
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInputLen[In] Length of bytes available in pDivInput buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE Plus PICC. This will of 1 byte in length.

◆ phhalHw_Sam_Cmd_MFP_WritePerso()

phStatus_t phhalHw_Sam_Cmd_MFP_WritePerso ( phhalHw_Sam_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t pPiccReturnCode 
)

MFP_WritePerso is a multi-block write command.

It efficiently performs in X-mode up to 13 MIFARE Plus PICC WritePerso commands targeting one block each. If more than 13 blocks are to be updated, several MFP_WritePerso are to be issued. The blocks are transmitted to the SAM in one MFP_WritePerso , then the SAM shall execute the many required PICC WritePerso commands.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMSpDataParams is NULL.
PH_ERR_INVALID_PARAMETERpBlocks and pPiccReturnCode are NULL.
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 MIFAER Plus PICC by SAM. Should be holding an array of block number and data like,
  • Block Addr: MIFARE Plus Block address (2 bytes)
  • BlockData: MIFARE Plus Block data to be written at the address (16 bytes)
  • Ex: 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 of bytes available in pBlocks buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE Plus PICC. This will of 1 byte in length.