NXP Reader Library  v17.1.0.2535

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

Collaboration diagram for S Mode:

Functions

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticateMFP_Part1 (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t *pPDChal, uint8_t bPDChalLen, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t **ppPCDChalResp, uint16_t *pPCDChalRespLen)
 Perform a MFP Authenticate command part1. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticateMFP_Part2 (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bPiccErrCode, uint8_t *pPDResp, uint8_t bPDRespLen, uint8_t **ppPDCap2, uint8_t **ppPCDCap2, uint8_t *pPiccReturnCode)
 Perform a MFP Authenticate command part2. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthSectorSwitchMFP_Part1 (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pPDChal, uint8_t bPDChalLen, 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 **ppPCDChalResp, uint16_t *pPCDChalRespLen)
 Perform a MFP Sector Switch Authenticate command part1. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthSectorSwitchMFP_Part2 (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bPiccErrCode, uint8_t *pPDResp, uint8_t bPDRespLen, uint8_t *pPiccReturnCode)
 Perform a MFP Sector Switch Authenticate Authenticate command part2. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticatePDC_Part1 (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t *pPDChal, uint8_t bPDChalLen, uint8_t *pUpgradeInfo, uint8_t bLen, uint8_t *pDivInput, uint8_t bDivInputLen, uint8_t **ppPCDChalResp, uint16_t *pPCDChalRespLen)
 Perform a Post delivery configuration Authenticate command part1. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticatePDC_Part2 (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bPiccErrCode, uint8_t *pPDResp, uint8_t bPDRespLen, uint8_t *pPiccReturnCode)
 Perform a Post delivery configuration Authenticate command part2. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_CombinedReadMFP (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bLFI, uint16_t wOption, uint8_t *pData, uint8_t bDataLen, uint8_t **ppOutput, uint16_t *pOutputLen, uint8_t *pPiccReturnCode)
 Perform a MIFARE Plus Combined Read command. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_CombinedWriteMFP (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pData, uint8_t bDataLen, uint8_t **ppOutput, uint16_t *pOutputLen, uint8_t *pPiccReturnCode)
 Perform a MFP CombinedWrite command. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_ChangeKeyMFP (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pData, uint8_t bDataLen, uint8_t **ppProtectedData, uint16_t *pProtectedDataLen, uint8_t *pPiccReturnCode)
 Prepare the MFP Change Key command. More...
 

MIFARE Plus command for SAM AV3 hardware.

#define PHHAL_HW_SAMAV3_CMD_AUTHENTICATE_MFP_INS   0xA3
 CMD Byte for SAM_AuthenticateMFP command.
 
#define PHHAL_HW_SAMAV3_CMD_AUTH_SECTOR_SWITCH_MFP_INS   0x38
 CMD Byte for SAM_AuthSectorSwitchMFP command.
 
#define PHHAL_HW_SAMAV3_CMD_AUTHENTICATE_PDC_INS   0xAC
 CMD Byte for SAM_AuthenticatePDC command.
 
#define PHHAL_HW_SAMAV3_CMD_COMBINED_READ_MFP_INS   0x33
 CMD Byte for SAM_CombinedReadMFP command.
 
#define PHHAL_HW_SAMAV3_CMD_COMBINED_WRITE_MFP_INS   0x34
 CMD Byte for SAM_CombinedWriteMFP command.
 
#define PHHAL_HW_SAMAV3_CMD_CHANGE_KEY_MFP_INS   0x35
 CMD Byte for SAM_ChangeKeyMFP command.
 
#define PHHAL_HW_CMD_SAMAV3_TMRI_COMMIT_READER_ID_INS   0x37
 Sam AV3 X mode Instruction code for CommitReaderID command.
 

MIFARE Plus options macros for differentiating between command and response for Cmd.SAM_CombinedReadMFP command.

#define PHHAL_HW_SAMAV3_OPTION_COMBINED_READ_MFP_COMMAND   0x0000
 Option value for Combined Read - Command.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_READ_MFP_RESPONSE   0x0001
 Option value for Combined Read - Response.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_READ_MFP_BOTH   0x0002
 Option value for Combined Read - Both Command and Response.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_READ_MASK   0x0003
 Option mask for Combined Read.
 

MIFARE Plus options macros for differentiating between command and response for Cmd.SAM_CombinedWriteMFP command.

#define PHHAL_HW_SAMAV3_OPTION_COMBINED_WRITE_MFP_COMMAND   0x00
 Option value for Combined Write - Command.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_WRITE_MFP_RESPONSE   0x01
 Option mask for Combined Write - Response.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_WRITE_MASK   0x01
 Option mask for Combined Write.
 

MIFARE Plus options macros for specifying the Plain data in response information.

#define PHHAL_HW_SAMAV3_OPTION_COMBINED_WRITE_RETURN_PLAIN   0x00
 Option macro to return the plain data in response.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_WRITE_SKIP_PLAIN   0x02
 Option macro to skip the plain data in response.
 
#define PHHAL_HW_SAMAV3_OPTION_COMBINED_WRITE_PLIAN_RESPONSE_MASK   0x02
 Option mask for Combined Write Plain.
 

MIFARE Plus options macros for differentiating between command and response for Cmd.SAM_ChangeKeyMFP command.

#define PHHAL_HW_SAMAV3_OPTION_MFP_CHANGE_KEY_COMMAND   0x00
 Option value for ChangeKey - Command.
 
#define PHHAL_HW_SAMAV3_OPTION_MFP_CHANGE_KEY_RESPONSE   0x01
 Option mask for ChangeKey - Response.
 

Detailed Description

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

Function Documentation

◆ phhalHw_SamAV3_Cmd_SAM_AuthenticateMFP_Part1()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticateMFP_Part1 ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t pPDChal,
uint8_t  bPDChalLen,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t **  ppPCDChalResp,
uint16_t pPCDChalRespLen 
)

Perform a MFP Authenticate command part1.

This command will generate a 16 byte random number with the one received from card and return an 32 byte encrypted data which will be sent to card.

Returns
Status code
Return values
PH_ERR_SUCCESS_CHAININGsuccessfull chaining operation.
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]pPDChal[In] Buffer containing the challange generated by the card.
[in]bPDChalLen[In] Length of bytes available in PDChal buffer.
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInputLen[In] Length of diversification input used to diversify the key.
[out]ppPCDChalResp[Out] Buffer containing the PCD challenge response to be sent to card.
[out]pPCDChalRespLen[Out] Length bytes available in PCD challange response buffer.

◆ phhalHw_SamAV3_Cmd_SAM_AuthenticateMFP_Part2()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticateMFP_Part2 ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bPiccErrCode,
uint8_t pPDResp,
uint8_t  bPDRespLen,
uint8_t **  ppPDCap2,
uint8_t **  ppPCDCap2,
uint8_t pPiccReturnCode 
)

Perform a MFP Authenticate command part2.

This command will decrypt the response received from card and will return the PC capabilities and PCD capabilites.

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]bPiccErrCode[In] Error Code sent by the MFP card. For success it should be 0x90.
[in]pPDResp[In] Buffer containing the input received from card.
[in]bPDRespLen[In] Length of bytes available in PDResp buffer.
[out]ppPDCap2[Out] Buffer containing the Output PCD capabilities. This will be of 6 bytes.
[out]ppPCDCap2[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_SAM_AuthSectorSwitchMFP_Part1()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthSectorSwitchMFP_Part1 ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pPDChal,
uint8_t  bPDChalLen,
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 **  ppPCDChalResp,
uint16_t pPCDChalRespLen 
)

Perform a MFP Sector Switch Authenticate command part1.

This command will generate a 16 byte random number with the one received from card and return an 32 byte encrypted data which will be sent to card.

Returns
Status code
Return values
PH_ERR_SUCCESS_CHAININGsuccessfull chaining operation.
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 bytes.
[in]pPDChal[In] Buffer containing the challange generated by the card.
[in]bPDChalLen[In] Length of bytes available in PDChal buffer.
[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]ppPCDChalResp[Out] Buffer containing the PCD challenge response to be sent to card.
[out]pPCDChalRespLen[Out] Length of PCD challange response.

◆ phhalHw_SamAV3_Cmd_SAM_AuthSectorSwitchMFP_Part2()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthSectorSwitchMFP_Part2 ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bPiccErrCode,
uint8_t pPDResp,
uint8_t  bPDRespLen,
uint8_t pPiccReturnCode 
)

Perform a MFP Sector Switch Authenticate Authenticate command part2.

This command will decrypt the response received from card and will return success status if the challanges matches.

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]bPiccErrCode[In] Error Code sent by the MFP card. For success it should be 0x90.
[in]pPDResp[In] Buffer containing the input received from card.
[in]bPDRespLen[In] Length of bytes available in PDResp buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_SAM_AuthenticatePDC_Part1()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticatePDC_Part1 ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t pPDChal,
uint8_t  bPDChalLen,
uint8_t pUpgradeInfo,
uint8_t  bLen,
uint8_t pDivInput,
uint8_t  bDivInputLen,
uint8_t **  ppPCDChalResp,
uint16_t pPCDChalRespLen 
)

Perform a Post delivery configuration Authenticate command part1.

This command will generate a 16 byte random number with the one received from card and return an 32 byte encrypted data which will be sent to card.

Returns
Status code
Return values
PH_ERR_SUCCESS_CHAININGsuccessfull chaining operation.
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]pPDChal[In] Buffer containing the challange generated by the card.
[in]bPDChalLen[In] Length of bytes available in PDChal buffer.
[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]ppPCDChalResp[Out] Buffer containing the PCD challenge response to be sent to card.
[out]pPCDChalRespLen[Out] Length of PCD challange response.

◆ phhalHw_SamAV3_Cmd_SAM_AuthenticatePDC_Part2()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticatePDC_Part2 ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bPiccErrCode,
uint8_t pPDResp,
uint8_t  bPDRespLen,
uint8_t pPiccReturnCode 
)

Perform a Post delivery configuration Authenticate command part2.

This command will decrypt the response received from card and will return success status if the challanges matches.

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]bPiccErrCode[In] Error Code sent by the MFP card. For success it should be 0x90.
[in]pPDResp[In] Buffer containing the input received from card.
[in]bPDRespLen[In] Length of bytes available in PDResp buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_SAM_CombinedReadMFP()

phStatus_t phhalHw_SamAV3_Cmd_SAM_CombinedReadMFP ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bLFI,
uint16_t  wOption,
uint8_t pData,
uint8_t  bDataLen,
uint8_t **  ppOutput,
uint16_t pOutputLen,
uint8_t pPiccReturnCode 
)

Perform a MIFARE Plus Combined Read command.

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]bLFI[In] Option for updating the P2 information of Sam frame.
[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 Command:
    • For READxyz : Read Cmd (1byte) + BNR (2byte) + No.Of Blocks (1byte)
    • For GetV : GetVersion command (1byte)
    • For Read_Sign: Read_Sign Cmd (1byte) + Address (1btye)
  • For Response:
    • Maced / Encrypted data
    • Error Code
  • For Command + Response:
    • READxyU + BNr + No.Of Blocks + RC + Data + MAC (Optional)
    • RC
[in]bDataLen[In] Length of bytes available in Data buffer.
[out]ppOutput[Out] The complete information received from PICC.
[out]pOutputLen[Out] Length bytes available in Output buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_SAM_CombinedWriteMFP()

phStatus_t phhalHw_SamAV3_Cmd_SAM_CombinedWriteMFP ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pData,
uint8_t  bDataLen,
uint8_t **  ppOutput,
uint16_t pOutputLen,
uint8_t pPiccReturnCode 
)

Perform a MFP CombinedWrite command.

This command is common for Write, WriteValue, Increment, Decrement, IncrementTransfer, DecrementTransfer, Transfer and Restore.

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 Command:
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)

For Response:
RC
RC + MAC
RC + TMC + TMV
RC + TMC + TMV + MAC
[in]bDataLen[In] Length of bytes available in Data buffer.
[out]ppOutput[Out] The complete information received from PICC.
[out]pOutputLen[Out] Length bytes available in Output buffer.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.

◆ phhalHw_SamAV3_Cmd_SAM_ChangeKeyMFP()

phStatus_t phhalHw_SamAV3_Cmd_SAM_ChangeKeyMFP ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pData,
uint8_t  bDataLen,
uint8_t **  ppProtectedData,
uint16_t pProtectedDataLen,
uint8_t pPiccReturnCode 
)

Prepare the MFP Change Key command.

This command will return the protected data to be written to card.

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] The below flags should be for updating the P1 information byte.
[in]pData[In] The information to be exchange to Sam hardware.
For Command : The buffer should contain CmdCode, KeyBNo, KeyNo, KeyVer and DivInput.
For Response: The buffer should contain PICC Status and MAC.
[in]bDataLen[In] Length of bytes available in Data buffer.
[out]ppProtectedData[Out] The protected key data from SAM hardware.
[out]pProtectedDataLen[Out] The length of the protected data.
[out]pPiccReturnCode[Out] Error code returned by MIFARE PICC. This will of 1 byte in length.