NXP Reader Library  v17.1.0.2535

SAM commands used for host communication and security related configuration. More...

Collaboration diagram for Security and Configuration:

Functions

phStatus_t phhalHw_SamAV3_Cmd_SAM_LockUnlock (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bCmdType, uint16_t wRdKeyNo, uint16_t wRdKeyVer, uint8_t bSamKeyNo, uint8_t bSamKeyVer, uint8_t bUnlockKeyNo, uint8_t bUnlockKeyVer, uint32_t dwMaxChainBlocks)
 Lock or Unlock the SAM. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticateHost (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bHostMode, uint16_t wRdKeyNo, uint16_t wRdKeyV, uint8_t bSamKeyNo, uint8_t bSamKeyV)
 Mutual 3-pass-AV2 or 3-Pass AV3 authentication between Host and SAM. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_GetVersion (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t *pVersion, uint8_t *pVersionLen)
 Get version information from the SAM. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_DisableCrypto (phhalHw_SamAV3_DataParams_t *pDataParams, uint16_t wProMas)
 Disable cryto-related features of the SAM permanently and is irreversible. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_ActivateOfflineKey (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t bKeyNo, uint8_t bKeyVer, uint8_t *pDivInput, uint8_t bDivInputLen)
 Activation of an OfflineCrypto or an OfflineChange Key. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_LoadInitVector (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pData, uint8_t bDataLen)
 Load an Init Vector for the next cryptographic operation into the SAM. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_KillAuthentication (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption)
 Kill all active authentications in this logical channel. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_SelectApplication (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t *pDF_Aid)
 Select an application by the DF_AID. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_GetRandom (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bExpLen, uint8_t *pRnd)
 Gets a random number. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_Sleep (phhalHw_SamAV3_DataParams_t *pDataParams)
 Set the SAM into power down mode. More...
 
phStatus_t phhalHw_SamAV3_Cmd_SAM_SetConfiguration (phhalHw_SamAV3_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pData, uint8_t bDataLen)
 Used to update SAM configuration settings. More...
 

Sam AV3 command code for Sam Security and configuration feature.

#define PHHAL_HW_SAMAV3_CMD_LOCK_UNLOCK_INS   0x10
 Sam AV3 Insturction code for SAM_LockUnlock command.
 
#define PHHAL_HW_SAMAV3_CMD_AUTHENTICATE_HOST_INS   0xA4
 Sam AV3 Insturction code for SAM_AuthenticateHost command.
 
#define PHHAL_HW_SAMAV3_CMD_GET_VERSION_INS   0x60
 Sam AV3 Insturction code for SAM_GetVersion command.
 
#define PHHAL_HW_SAMAV3_CMD_DISABLE_CRYPTO_INS   0xDC
 Sam AV3 Insturction code for SAM_DisableCrypto command.
 
#define PHHAL_HW_SAMAV3_CMD_ACTIVATE_OFFLINE_KEY_INS   0x01
 Sam AV3 Insturction code for SAM_ActivateOfflineKey command.
 
#define PHHAL_HW_SAMAV3_CMD_LOAD_INIT_VECTOR_INS   0x71
 Sam AV3 Insturction code for SAM_LoadInitVector command.
 
#define PHHAL_HW_SAMAV3_CMD_KILL_AUTHENTICATION_INS   0xCA
 Sam AV3 Insturction code for SAM_KillAuthenticate command.
 
#define PHHAL_HW_SAMAV3_CMD_SELECT_APPLICATION_INS   0x5A
 Sam AV3 Insturction code for SAM_SelectApplication command.
 
#define PHHAL_HW_SAMAV3_CMD_GET_CHALLENGE_INS   0X84
 Sam AV3 Insturction code for SAM_GetChallenge command.
 
#define PHHAL_HW_SAMAV3_CMD_SLEEP_INS   0x51
 Sam AV3 Insturction code for SAM_Sleep command.
 
#define PHHAL_HW_SAMAV3_CMD_SETCONFIGURATION_INS   0x3C
 Sam AV3 Insturction code for SAM_SetConfiguration command.
 

Option macros for Sam AV3 Security and Configuration Cmd.SAM_LockUnlock command.

#define PHHAL_HW_SAMAV3_CMD_SAM_LOCK_UNLOCK_TYPE_UNLOCK   0x00
 Option mask for Sub-command type as unlock.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_LOCK_UNLOCK_TYPE_LOCK_NO_KEY   0x01
 Option mask for Sub-command type as lock without specifying unlock key.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_LOCK_UNLOCK_TYPE_LOCK_KEY   0x02
 Option mask for Sub-command type as lock with specifying unlock key.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_LOCK_UNLOCK_TYPE_ACTIVATE_SAM   0x03
 Option mask for Sub-command type as activate MIFARE SAM to AV3.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_LOCK_UNLOCK_TYPE_UNLOCK_PL   0x04
 Option mask for Sub-command type as unlock PL.
 

Option macros for Sam AV3 Security and Configuration Cmd.SAM_AuthenticateHost command.

#define PHHAL_HW_SAMAV3_CMD_SAM_AUTHENTICATE_HOST_MODE_PLAIN   0x00
 Option mask for protection mode as plain.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_AUTHENTICATE_HOST_MODE_MAC   0x01
 Option mask for protection mode as MAC protection.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_AUTHENTICATE_HOST_MODE_FULL   0x02
 Option mask for protection mode as Full protection.
 

Option macros for Sam AV3 Security and Configuration Cmd.SAM_DisableCrypto command.

#define PHHAL_HW_SAMAV3_CMD_SAM_CRYPTO_DISABLE_NO_CHANGE   0x0000
 Option mask for Disable Crypto with no change for programming mask bit.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_CRYPTO_DISABLE_DES_PICC_CHANGE_KEY   0x0800
 Option mask for Disable Crypto to disable DESFire Key change.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_CRYPTO_DISABLE_DECRYPTION   0x1000
 Option mask for Disable Crypto to disable the decryption of data.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_CRYPTO_DISABLE_ENCRYPTION   0x2000
 Option mask for Disable Crypto to disable encryption of data.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_CRYPTO_DISABLE_MAC_VERIFICATION   0x4000
 Option mask for Disable Crypto to disable verification of MAC.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_CRYPTO_DISABLE_MAC_GENERATION   0x8000
 Option mask for Disable Crypto to disable generation of MAC.
 

Option macros for Sam AV3 Security and Configuration Cmd.SAM_ActivateOffline command.

#define PHHAL_HW_SAMAV3_CMD_SAM_AO_LRP_UPDATE_KEY_RFU   0x00
 Option mask for ActivateOffline with P1 information Bit 1 set to zero in case of non AES_128 LPR keytype.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_AO_LRP_UPDATE_KEY_ONE   0x00
 Option mask for ActivateOffline with LRP Update keys to generate One updated key (KeyID.LRPUpdate).
 
#define PHHAL_HW_SAMAV3_CMD_SAM_AO_LRP_UPDATE_KEY_TWO   0x02
 Option mask for ActivateOffline with LRP Update keys to generate Two updated key (KeyID.LRPMACUpdate and KeyID.LRPENCUpdate).
 

Option macros for Sam AV3 Security and Configuration Cmd.LoadInitVector command.

#define PHHAL_HW_SAMAV3_CMD_SAM_LOAD_IV_MODE_SET_IV   0x00
 Option mask for Load Init Vector to set the IV.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_LOAD_IV_MODE_SET_LRP_ENC_CTR   0x01
 Option mask for Load Init Vector to set the LRP_EncCtr.
 

Option macros for Sam AV3 Security and Configuration Cmd.SAM_KillAuthentication command.

#define PHHAL_HW_SAMAV3_CMD_SAM_KILL_AUTHENTICATION_FULL   0x00
 Option mask for killing any authentication on corresponding LC.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_KILL_AUTHENTICATION_PARTIAL   0x01
 Option mask for killing PICC or offline key activation but preserving any Host Authentication.
 

Option macros for Sam AV3 Security and Configuration Cmd.SAM_SetConfiguration command.

#define PHHAL_HW_SAMAV3_CMD_SAM_SET_CONFIGURATION_HISTORICAL_BYTES   0x00
 Option mask for exchanging the historical bytes.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_SET_CONFIGURATION_READER_IC_CONFIG   0x01
 Option mask for exchanging the reader IC configuration.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_SET_CONFIGURATION_I2C_CLOCK_SPEED   0x02
 Option mask for exchanging the I2C processing clock speed configuration.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_SET_CONFIGURATION_EMV_CHANGE_KEYS   0x03
 Option mask for exchanging the Default EMV Change keys configuration.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_SET_CONFIGURATION_FULL_ATR   0x04
 Option mask for exchanging the Full ATR configuration.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_READER_IC_CONFIG_RC512   0x01
 Option mask for exchanging the reader IC configuration as RC512.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_READER_IC_CONFIG_RC523   0x02
 Option mask for exchanging the reader IC configuration as RC523.
 
#define PHHAL_HW_SAMAV3_CMD_SAM_READER_IC_CONFIG_RC663   0x03
 Option mask for exchanging the reader IC configuration as RC663.
 

Detailed Description

SAM commands used for host communication and security related configuration.

Function Documentation

◆ phhalHw_SamAV3_Cmd_SAM_LockUnlock()

phStatus_t phhalHw_SamAV3_Cmd_SAM_LockUnlock ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bCmdType,
uint16_t  wRdKeyNo,
uint16_t  wRdKeyVer,
uint8_t  bSamKeyNo,
uint8_t  bSamKeyVer,
uint8_t  bUnlockKeyNo,
uint8_t  bUnlockKeyVer,
uint32_t  dwMaxChainBlocks 
)

Lock or Unlock the SAM.

Its important to perform Host Authentication after successfull LockUnlock operation to set the new session keys. Host Authentication is required because, LockUnlock interface will utilize the same Cryptoparams which was utilized by Host Authentication interface. Since the Cryptoparams are common, the keys will be updated by LockUnlock interface and the exisiting Host Authentication session keys will not be available.

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]bCmdType[In] Sub Command type.
[in]wRdKeyNo[In] Key reference number to be used in software key store.
[in]wRdKeyVer[In] Key version to be used in software keystore.
[in]bSamKeyNo[In] Key reference number in hardware keytsore.
[in]bSamKeyVer[In] Key version to be used in hardware key store.
[in]bUnlockKeyNo[In] Unlock Key Number to be used in hardware key store (only used when bCmdType = 0x01).
[in]bUnlockKeyVer[In] Unlock Key Version to be used in hardware key store (only used when bCmdType = 0x01).
[in]dwMaxChainBlocks[In] Maximal message size under command chaining in MAC or Full Protection (only used during switch from AV2 to AV3).

◆ phhalHw_SamAV3_Cmd_SAM_AuthenticateHost()

phStatus_t phhalHw_SamAV3_Cmd_SAM_AuthenticateHost ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bHostMode,
uint16_t  wRdKeyNo,
uint16_t  wRdKeyV,
uint8_t  bSamKeyNo,
uint8_t  bSamKeyV 
)

Mutual 3-pass-AV2 or 3-Pass AV3 authentication between Host and SAM.

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]bHostMode[In] Type of Protection mode to be applied.
PHHAL_HW_SAMAV3_CMD_SAM_AUTHENTICATE_HOST_MODE_PLAIN
PHHAL_HW_SAMAV3_CMD_SAM_AUTHENTICATE_HOST_MODE_MAC
PHHAL_HW_SAMAV3_CMD_SAM_AUTHENTICATE_HOST_MODE_FULL
[in]wRdKeyNo[In] Key reference number to be used in software key store.
[in]wRdKeyV[In] Key version to be used in software keystore.
[in]bSamKeyNo[In] Key reference number in hardware keytsore.
[in]bSamKeyV[In] Key version to be used in hardware key store.

◆ phhalHw_SamAV3_Cmd_SAM_GetVersion()

phStatus_t phhalHw_SamAV3_Cmd_SAM_GetVersion ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t pVersion,
uint8_t pVersionLen 
)

Get version information from the SAM.

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.
[out]pVersion[Out] Buffer containing the read version. It has to be 31 bytes long.
[out]pVersionLen[Out] Amount of valid bytes in the version buffer.

◆ phhalHw_SamAV3_Cmd_SAM_DisableCrypto()

phStatus_t phhalHw_SamAV3_Cmd_SAM_DisableCrypto ( phhalHw_SamAV3_DataParams_t pDataParams,
uint16_t  wProMas 
)

Disable cryto-related features of the SAM permanently and is irreversible.

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]wProMas[In] Two byte mask to specify the desired settings for cryptography-related features.

◆ phhalHw_SamAV3_Cmd_SAM_ActivateOfflineKey()

phStatus_t phhalHw_SamAV3_Cmd_SAM_ActivateOfflineKey ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t  bKeyNo,
uint8_t  bKeyVer,
uint8_t pDivInput,
uint8_t  bDivInputLen 
)

Activation of an OfflineCrypto or an OfflineChange Key.

This command is available in both AV2 and AV3 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 update the P1 information if Keytype is AES_128LRP.
[in]bKeyNo[In] Key reference number in hardware keytsore.
[in]bKeyVer[In] Key version to be used in hardware key store.
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInputLen[In] Length of diversification input used to diversify the key.

◆ phhalHw_SamAV3_Cmd_SAM_LoadInitVector()

phStatus_t phhalHw_SamAV3_Cmd_SAM_LoadInitVector ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pData,
uint8_t  bDataLen 
)

Load an Init Vector for the next cryptographic operation into the SAM.

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 option.
[in]pData[In] Data based on the option selected.
If
[in]bDataLen[In] The length of bytes available in Data buffer.

◆ phhalHw_SamAV3_Cmd_SAM_KillAuthentication()

phStatus_t phhalHw_SamAV3_Cmd_SAM_KillAuthentication ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption 
)

Kill all active authentications in this logical channel.

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 type of authentication to be killed.

◆ phhalHw_SamAV3_Cmd_SAM_SelectApplication()

phStatus_t phhalHw_SamAV3_Cmd_SAM_SelectApplication ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t pDF_Aid 
)

Select an application by the DF_AID.

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]pDF_Aid[In] DESFire application identifier (3 bytes).

◆ phhalHw_SamAV3_Cmd_SAM_GetRandom()

phStatus_t phhalHw_SamAV3_Cmd_SAM_GetRandom ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bExpLen,
uint8_t pRnd 
)

Gets a random number.

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]bExpLen[In] The length of random bytes expected form Sam hardware.
[out]pRnd[Out] The random number returned by Sam.

◆ phhalHw_SamAV3_Cmd_SAM_Sleep()

phStatus_t phhalHw_SamAV3_Cmd_SAM_Sleep ( phhalHw_SamAV3_DataParams_t pDataParams)

Set the SAM into power down 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.

◆ phhalHw_SamAV3_Cmd_SAM_SetConfiguration()

phStatus_t phhalHw_SamAV3_Cmd_SAM_SetConfiguration ( phhalHw_SamAV3_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pData,
uint8_t  bDataLen 
)

Used to update SAM configuration settings.

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] Configuration setting ID. Define length and content of the Data parameter.
[in]pData[In] Configuration setting data.
[in]bDataLen[In] Length of Configuration setting data.