NXP Reader Library  v17.1.0.2535

SAM commands used for MIFARE Classic X communication. More...

Collaboration diagram for X Mode:

Functions

phStatus_t phhalHw_SamAV3_Cmd_MF_Authenticate (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pMFUID, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t bKeyType, uint8_t bMFBlockNo, uint8_t bDivBlockNo)
 Perform a MIFARE Classic Authenticate command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_Read (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppData, uint16_t *pDataLen)
 Perform a MIFARE Classic Read command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_Write (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pData, uint8_t bDataLen, uint8_t **ppTMData, uint16_t *pTMDataLen)
 Perform a MIFARE Classic Write command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_ValueWrite (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppTMData, uint16_t *pTMDataLen)
 Perform a MIFARE Classic Write Value command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_Increment (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppTMData, uint16_t *pTMDataLen)
 Perform a MIFARE Classic Increment command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_Decrement (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppTMData, uint16_t *pTMDataLen)
 Perform a MIFARE Classic Decrement command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_Restore (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppTMData, uint16_t *pTMDataLen)
 Perform a MIFARE Classic Restore command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_AuthenticatedRead (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pMFUid, uint8_t bCmdSettings, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t bKeyType, uint8_t bAuthBlockNo, uint8_t bDivBlockNo, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppData, uint16_t *pDataLen)
 Perform a MIFARE Authenticate followed by a MIFARE Read command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_AuthenticatedWrite (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pMFUid, uint8_t bCmdSettings, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t bKeyType, uint8_t bAuthBlockNo, uint8_t bDivBlockNo, uint8_t *pBlocks, uint8_t bBlocksLen, uint8_t **ppTMData, uint16_t *pTMDataLen)
 Perform a MIFARE Authenticate followed by a MIFARE Write command in X mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_MF_ChangeKey (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bKeyNo, uint8_t bKeyVerA, uint8_t bKeyVerB, uint8_t bMFBlockNo, uint8_t *pAccCond, uint8_t *pMFUID, uint8_t bDivBlockNo)
 Performs the MIFARE Classic key change in X mode. More...
 

Sam AV3 command code for MIFARE Classic X features.

#define PHHAL_HW_SAMAV3_CMD_MF_AUTHENTICATE_INS   0x0C
 Sam AV3 Instruction code for Cmd.MF_Authenticate command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_READ_INS   0x30
 Sam AV3 Instruction code for Cmd.MF_Read command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_WRITE_INS   0xA0
 Sam AV3 Instruction code for Cmd.MF_Write command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_VALUE_WRITE_INS   0xA2
 Sam AV3 Instruction code for Cmd.MF_ValueWtire command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_INCREMENT_INS   0xC3
 Sam AV3 Instruction code for Cmd.MF_Increment command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_DECREMENT_INS   0xC0
 Sam AV3 Instruction code for Cmd.MF_Decrement command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_RESTORE_INS   0xC2
 Sam AV3 Instruction code for Cmd.MF_Restore command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTHENTICATED_READ_INS   0x3A
 Sam AV3 Instruction code for Cmd.MF_AuthenticatedRead command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTHENTICATED_WRITE_INS   0xAA
 Sam AV3 Instruction code for Cmd.MF_AuthenticatedWrite command.
 
#define PHHAL_HW_SAMAV3_CMD_MF_CHANGE_KEY_INS   0xA1
 Sam AV3 Instruction code for Cmd.MF_ChangeKey command.
 

Option macros for Sam AV3 MIFARE Classic Write command in X mode communication.

#define PHHAL_HW_SAMAV3_CMD_MF_WRITE_CLASSIC   0x00
 Option mask for writting data to MIFARE Classic product.
 
#define PHHAL_HW_SAMAV3_CMD_MF_WRITE_ULTRALIGHT   0x01
 Option mask for writting data to MIFARE Ultralight product.
 
#define PHHAL_HW_SAMAV3_CMD_MF_WRITE_TMDATA_NOT_RETURNED   0x00
 Option mask for not exchanging the LE byte to SAM.
 
#define PHHAL_HW_SAMAV3_CMD_MF_WRITE_TMDATA_RETURNED   0x80
 Option mask for exchanging the LE byte to SAM for retrieval of TMC and TMV information.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTH_RW_KEY_INFO_AVAILABLE   0x00
 Option mask to include the key information for authentication block.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTH_RW_KEY_INFO_NOT_AVAILABLE   0x01
 Option mask to exclude the key information for authentication block.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTH_RW_CMD_SET_DIV_OFF   0x00
 Option mask to disable the key diversification.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTH_RW_CMD_SET_DIV_ON   0x02
 Option mask to enable the key diversification.
 

Option macros for Sam AV3 MIFARE Classic ValueWrite command in X mode communication.

#define PHHAL_HW_SAMAV3_CMD_MF_VALUE_WRITE_TMDATA_NOT_RETURNED   0x00
 Option mask for not exchanging the LE byte to SAM.
 
#define PHHAL_HW_SAMAV3_CMD_MF_VALUE_WRITE_TMDATA_RETURNED   0x80
 Option mask for exchanging the LE byte to SAM for retrieval of TMC and TMV information.
 

Option macros for Sam AV3 MIFARE Classic Increment command in X mode communication.

#define PHHAL_HW_SAMAV3_CMD_MF_INCREMENT_TMDATA_NOT_RETURNED   0x00
 Option mask for not exchanging the LE byte to SAM.
 
#define PHHAL_HW_SAMAV3_CMD_MF_INCREMENT_TMDATA_RETURNED   0x80
 Option mask for exchanging the LE byte to SAM for retrieval of TMC and TMV information.
 

Option macros for Sam AV3 MIFARE Classic Decrement command in X mode communication.

#define PHHAL_HW_SAMAV3_CMD_MF_DECREMENT_TMDATA_NOT_RETURNED   0x00
 Option mask for not exchanging the LE byte to SAM.
 
#define PHHAL_HW_SAMAV3_CMD_MF_DECREMENT_TMDATA_RETURNED   0x80
 Option mask for exchanging the LE byte to SAM for retrieval of TMC and TMV information.
 

Option macros for Sam AV3 MIFARE Classic Restore command in X mode communication.

#define PHHAL_HW_SAMAV3_CMD_MF_RESTORE_TMDATA_NOT_RETURNED   0x00
 Option mask for not exchanging the LE byte to SAM.
 
#define PHHAL_HW_SAMAV3_CMD_MF_RESTORE_TMDATA_RETURNED   0x80
 Option mask for exchanging the LE byte to SAM for retrieval of TMC and TMV information.
 

Option macros for Sam AV3 MIFARE Classic AuthenticateWrite command in X mode communication.

#define PHHAL_HW_SAMAV3_CMD_MF_AUTH_WRITE_TMDATA_NOT_RETURNED   0x0000
 Option mask for not exchanging the LE byte to SAM.
 
#define PHHAL_HW_SAMAV3_CMD_MF_AUTH_WRITE_TMDATA_RETURNED   0x0080
 Option mask for exchanging the LE byte to SAM for retrieval of TMC and TMV information.
 

Detailed Description

SAM commands used for MIFARE Classic X communication.

Function Documentation

◆ phhalHw_SamAV3_Cmd_MF_Authenticate()

phStatus_t phhalHw_SamAV3_Cmd_MF_Authenticate ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pMFUID,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t  bKeyType,
uint8_t  bMFBlockNo,
uint8_t  bDivBlockNo 
)

Perform a MIFARE Classic 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] Specify whether diversification block number should be exchanged or not.
[in]pMFUID[In] MIFARE classic UID. Here the last four bytes of the UID should be passed regardless of 4 or 7 byte UID.
[in]bKeyNo[In] Key number of MIFARE key available in Sam keystore.
[in]bKeyVer[In] Key Version of MIFARE key available in Sam keystore.
[in]bKeyType[In] Type of key to be used.
[in]bMFBlockNo[In] MIFARE block number used for authentication.
[in]bDivBlockNo[In] Block number to be used for Key diversification in Sam.

◆ phhalHw_SamAV3_Cmd_MF_Read()

phStatus_t phhalHw_SamAV3_Cmd_MF_Read ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppData,
uint16_t pDataLen 
)

Perform a MIFARE Classic Read 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]pBlocks[In] The block numbers from where the data should be read.
Should be holding an array of block numbers like
BNR_1, BNR_2, BNR_3, ..., BNR_N
[in]bBlocksLen[In] Length representing the blocks available in pBlocks parameter.
[out]ppData[Out] Data returned by Sam hardware.
[out]pDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_Write()

phStatus_t phhalHw_SamAV3_Cmd_MF_Write ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pData,
uint8_t  bDataLen,
uint8_t **  ppTMData,
uint16_t pTMDataLen 
)

Perform a MIFARE Classic Write 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] One of the below options.
For Updating the P1 information byte.
[in]pData[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
Data could be 4 bytes or 16 bytes depending on the option specified.
[in]bDataLen[In] Length representing the block and data pair available in pBlocks parameter.
[out]ppTMData[Out] The Transaction Mac Value and Counter of each block returned by MIFARE Classic PICC if
its a TMProtected block. Null in case of Ultralight or not a TMProtected block in case
of Classic.
[out]pTMDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_ValueWrite()

phStatus_t phhalHw_SamAV3_Cmd_MF_ValueWrite ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppTMData,
uint16_t pTMDataLen 
)

Perform a MIFARE Classic Write Value 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] For exchanging the LE byte.
[in]pBlocks[In] Buffer containing the Block, Value and Address pair to be written to card by Sam hardware.
Should be holding an array of block number, value and address like
BNR_1 + Value + Address, BNR_2 + Value + Address, ..., BNR_N + Value + Address
[in]bBlocksLen[In] Length of the pBlocks buffer.
[out]ppTMData[Out] The Transaction Mac Value and Counter of each block returned by MIFARE Classic PICC if
its a TMProtected block. Null in case of not a TMProtected block.
[out]pTMDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_Increment()

phStatus_t phhalHw_SamAV3_Cmd_MF_Increment ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppTMData,
uint16_t pTMDataLen 
)

Perform a MIFARE Classic Increment 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] For exchanging the LE byte.
[in]pBlocks[In] Buffer containing the Source Block, Destination Block and Value pair to be
written to card by Sam hardware. Should be holding an array of source block number,
destination block number and value like
SRC_BNR_1 + DST_BNR_1 + Value, SRC_BNR_2 + DST_BNR_2 + Value, ..., SRC_BNR_N + DST_BNR_N + Value
[in]bBlocksLen[In] Length of the pBlocks buffer.
[out]ppTMData[Out] The Transaction Mac Value and Counter of each block returned by MIFARE Classic PICC if
its a TMProtected block. Null in case of not a TMProtected block.
[out]pTMDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_Decrement()

phStatus_t phhalHw_SamAV3_Cmd_MF_Decrement ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppTMData,
uint16_t pTMDataLen 
)

Perform a MIFARE Classic Decrement 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] For exchanging the LE byte.
[in]pBlocks[In] Buffer containing the Source Block, Destination Block and Value pair to be
written to card by Sam hardware. Should be holding an array of source block number,
destination block number and value like
SRC_BNR_1 + DST_BNR_1 + Value, SRC_BNR_2 + DST_BNR_2 + Value, ..., SRC_BNR_N + DST_BNR_N + Value
[in]bBlocksLen[In] Length of the pBlocks buffer.
[out]ppTMData[Out] The Transaction Mac Value and Counter of each block returned by MIFARE Classic PICC if
its a TMProtected block. Null in case of not a TMProtected block.
[out]pTMDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_Restore()

phStatus_t phhalHw_SamAV3_Cmd_MF_Restore ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppTMData,
uint16_t pTMDataLen 
)

Perform a MIFARE Classic Restore 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] For exchanging the LE byte.
[in]pBlocks[In] Buffer containing the Source Block and Destination Block pair to be
written to card by Sam hardware. Should be holding an array of source
block number and destination block numbe like
SRC_BNR_1 + DST_BNR_1, SRC_BNR_2 + DST_BNR_2, ..., SRC_BNR_N + DST_BNR_N
[in]bBlocksLen[In] Length of the pBlocks buffer.
[out]ppTMData[Out] The Transaction Mac Value and Counter of each block returned by MIFARE Classic PICC if
its a TMProtected block. Null in case of not a TMProtected block.
[out]pTMDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_AuthenticatedRead()

phStatus_t phhalHw_SamAV3_Cmd_MF_AuthenticatedRead ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pMFUid,
uint8_t  bCmdSettings,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t  bKeyType,
uint8_t  bAuthBlockNo,
uint8_t  bDivBlockNo,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppData,
uint16_t pDataLen 
)

Perform a MIFARE Authenticate followed by a MIFARE Read 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 mask for this command. On every call a single data cycle is buffered.
A cycle is one sequence of CmdSettingss | KeyNo | KeyV | KeyType | AuthBlockNo | DivBlockNo| NumBlocks | Blocks
One of the below mentioned options to be used.
[in]pMFUid[In] MIFARE standard UID. Here the last four bytes of the UID should be passed regardless of 4 or 7 byte UID.
This buffer is only used if wOption is set to PH_EXCHANGE_DEFAULT or PH_EXCHANGE_BUFFER_FIRST.
[in]bCmdSettings[In] One of the below mentioned options to be used to update the CmdSettings
[in]bKeyNo[In] Key number of MIFARE key available in Sam keystore.
[in]bKeyVer[In] Key Version of MIFARE key available in Sam keystore.
[in]bKeyType[In] Type of key to be used.
[in]bAuthBlockNo[In] MIFARE block number used for authentication.
[in]bDivBlockNo[In] Block number to be used for Key diversification in Sam.
[in]pBlocks[In] The block numbers from where the data should be read.
[in]bBlocksLen[In] Length representing the blocks available in pBlocks parameter.
[out]ppData[Out] Data returned by Sam hardware.
[out]pDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_AuthenticatedWrite()

phStatus_t phhalHw_SamAV3_Cmd_MF_AuthenticatedWrite ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pMFUid,
uint8_t  bCmdSettings,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t  bKeyType,
uint8_t  bAuthBlockNo,
uint8_t  bDivBlockNo,
uint8_t pBlocks,
uint8_t  bBlocksLen,
uint8_t **  ppTMData,
uint16_t pTMDataLen 
)

Perform a MIFARE Authenticate followed by a MIFARE Write 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 mask for this command. On every call a single data cycle is buffered.
A cycle is one sequence of CmdSettingss | KeyNo | KeyV | KeyType | AuthBlockNo | DivBlockNo| NumBlocks | Blocks
One of the below mentioned blocks to be used.
[in]pMFUid[In] MIFARE standard UID. Here the last four bytes of the UID should be passed regardless of 4 or 7 byte UID.
This buffer is only used if wOption is set to PH_EXCHANGE_DEFAULT or PH_EXCHANGE_BUFFER_FIRST.
[in]bCmdSettings[In] One of the below mentioned options to be used to update the CmdSettings
[in]bKeyNo[In] Key number of MIFARE key available in Sam keystore.
[in]bKeyVer[In] Key Version of MIFARE key available in Sam keystore.
[in]bKeyType[In] Type of key to be used.
[in]bAuthBlockNo[In] MIFARE block number used for authentication.
[in]bDivBlockNo[In] Block number to be used for Key diversification in Sam.
[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
(where Data is of 16 bytes)
[in]bBlocksLen[In] Length representing the block and data pair available in pBlocks parameter.
[out]ppTMData[Out] The Transaction Mac Value and Counter of each block returned by MIFARE Classic PICC if
its a TMProtected block. Null in case of not a TMProtected block.
[out]pTMDataLen[Out] Amount of valid bytes returned by Sam hardware.

◆ phhalHw_SamAV3_Cmd_MF_ChangeKey()

phStatus_t phhalHw_SamAV3_Cmd_MF_ChangeKey ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bKeyNo,
uint8_t  bKeyVerA,
uint8_t  bKeyVerB,
uint8_t  bMFBlockNo,
uint8_t pAccCond,
uint8_t pMFUID,
uint8_t  bDivBlockNo 
)

Performs the MIFARE Classic key change 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] Specify whether diversification block number and UID should be exchanged or not.
[in]bKeyNo[In] Key number of MIFARE key available in Sam keystore.
[in]bKeyVerA[In] Key Version of MIFARE key A available in Sam keystore.
[in]bKeyVerB[In] Key Version of MIFARE key B available in Sam keystore.
[in]bMFBlockNo[In] Block number of the block to store the new key(s)
[in]pAccCond[In] MIFARE classic access conditions.
[in]pMFUID[In] MIFARE classic UID. Here the last four bytes of the UID should be passed regardless of 4 or 7 byte UID.
[in]bDivBlockNo[In] Block number to be used for Key diversification in Sam.