SamAV3 implementation of the phSam interface. More...

Data Structures | |
| struct | phKeyStore_SamAV3_DataParams_t |
| Sam parameter structure. More... | |
| struct | phKeyStore_SamAV3_KeyEntry_t |
| SamAV3 Key Entry Structure. More... | |
Macros | |
| #define | PH_KEYSTORE_SAMAV3_AV2_MODE 0x02U |
| Define the AV2 mode of the KeyStore. | |
| #define | PH_KEYSTORE_SAMAV3_AV3_MODE 0x03U |
| Define the AV3 mode of the KeyStore. | |
DES Key Options | |
| #define | PH_KEYSTORE_SAMAV3_DES_OPTION_DESFIRE4 0x00U |
| DESFire 4 compatibility mode. | |
| #define | PH_KEYSTORE_SAMAV3_DES_OPTION_ISO_CRC16 0x01U |
| ISO 10116 mode with CRC16 protection and 4 bytes MAC. | |
| #define | PH_KEYSTORE_SAMAV3_DES_OPTION_ISO_CRC32 0x02U |
| ISO 10116 mode with CRC32 protection and 8 bytes MAC. | |
Key Classes. Should be used to set the ExtSET information. | |
| #define | PH_KEYSTORE_SAMAV3_KEY_CLASS_HOST 0x00U |
| Configuring key entry as Host. | |
| #define | PH_KEYSTORE_SAMAV3_KEY_CLASS_PICC 0x01U |
| Configuring key entry as PICC. | |
| #define | PH_KEYSTORE_SAMAV3_KEY_CLASS_OFFLINE_CHANGE 0x02U |
| Configuring key entry as Offline Change. | |
| #define | PH_KEYSTORE_SAMAV3_KEY_CLASS_OFFLINE_CRYPTO 0x04U |
| Configuring key entry as Offline Crypto. | |
| #define | PH_KEYSTORE_SAMAV3_KEY_CLASS_OFFLINE_UPLOAD 0x05U |
| Configuring key entry as Offline Upload. | |
| #define | PH_KEYSTORE_SAMAV3_KEY_CLASS_OFFLINE_PERSO 0x06U |
| Configuring key entry as Offline Perso. | |
KeyStore Configs for SET configurations. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_ALLOW_DUMP_SESSION_KEY 0x0000U |
| Enable or Disable SAM_ChangeKeyMIFARE and SAM_DumpSessionKey command. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEEP_IV 0x0001U |
| Enable or Disable the reset of init vector after a crypto command. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_PL_KEY 0x0002U |
| Enable or Disable the Host key type to provide permissions for Cmd.PLExec execution. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_AUTH_KEY 0x0003U |
| Enable or Disable Host Authentication with key other that MasterKey. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DISABLE_KEY_ENTRY 0x0004U |
| Enable or Disable Key Entry. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_LOCK_KEY 0x0005U |
| Enable or Disable LockUnlock. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DISABLE_CHANGE_KEY_PICC 0x0006U |
| Enable or Disable writing the key to a PICC. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DISABLE_DECRYPTION 0x0007U |
| Enable or Disable SAM_DecipherData command. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DISABLE_ENCRYPTION 0x0008U |
| Enable or Disable SAM_EncipherData command. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DISABLE_VERIFY_MAC 0x0009U |
| Enable or Disable SAM_VerifyMAC command. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DISABLE_GENERATE_MAC 0x000AU |
| Enable or Disable SAM_GenerateMAC command. | |
KeyStore Configs for ExtSET configurations. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYCLASS 0x000BU |
| Key Class used in key store. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_ALLOW_DUMP_SECRET_KEY 0x000CU |
| Enable or Disable SAM_DumpSecretKey command. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_MANDATE_KEY_DIVERSIFICATION 0x000DU |
| Mandate or not key diversification. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_RESERVED_SAM_PRESONALIZATION 0x000EU |
| Enable or disable the Key Entry for Sam Personalization. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEY_USAGE_INT_HOST 0x000FU |
| Enable or disable the Key Entry usage by Internal Host. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEY_CHANGE_INT_HOST 0x0010U |
| Enable or disable the Key Entry change by Internal Host. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_SESSION_KEY_USAGE_INT_HOST 0x0011U |
| Enable or disable the Session Key usage by Internal Host. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_ALLOW_DUMP_SECRET_KEY_INT_HOST 0x0012U |
| Enable or disable the dumping of Secret Key by Internal Host. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_ALLOW_DUMP_SESSION_KEY_INT_HOST 0x0013U |
| Enable or disable the dumping of Session Key by Internal Host. | |
KeyStore Configs for SAM Key Storage Table's Key Entry. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DF_AID 0x0014U |
| DESFire application ID. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DF_KEY_NO 0x0015U |
| DESFire key number. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_CEK 0x0016U |
| Key Number of Change Entry key. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYV_CEK 0x0017U |
| Key Version of Change Entry key. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_REF_NO_KUC 0x0018U |
| Reference number of key usage counter. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_AEK 0x0019U |
| Key Number of Access Entry key. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYV_AEK 0x001AU |
| Key Version of Access Entry key. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_CKUC 0x001BU |
| Key Number of Change KUC. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYV_CKUC 0x001CU |
| Key Version of Change KUC. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_DES_KEY_OPTION 0x001DU |
| Option for single DES and 2 Key Triple DES keys. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_A 0x001EU |
| Key Number used for MIFARE key A diversification. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_A 0x001FU |
| Key Version used for MIFARE key A diversification. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_B 0x0020U |
| Key Number used for MIFARE key B diversification. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_B 0x0021U |
| Key Version used for MIFARE key B diversification. | |
| #define | PH_KEYSTORE_SAMAV3_CONFIG_ENABLE_LRP 0x0022U |
| The AES key to be used is for LRP algorithm. | |
SamAV3 implementation of the phSam interface.
| phStatus_t phKeyStore_SamAV3_Init | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wSizeOfDataParams, | ||
| phhalHw_SamAV3_DataParams_t * | pHalDataParams | ||
| ) |
Initializes the KeyStore component as SAM AV3 component.
| PH_ERR_SUCCESS | Operation successful. |
| [in] | pDataParams | [In] Pointer to this layer's parameter structure. |
| [in] | wSizeOfDataParams | [In] Specifies the size of the data parameter structure. |
| [in] | pHalDataParams | [In] Pointer to the parameter structure of the underlying layer. |
| phStatus_t phKeyStore_SamAV3_FormatKeyEntry | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wKeyNo, | ||
| uint16_t | wKeyType | ||
| ) |
Format a key entry to a new KeyType.
The function changes a symmetric key entry of the SAM to a new key type. First the command phhalHw_SamAV3_Cmd_SAM_GetKeyEntry is executed to get the current change key number of the key entry. Afterwards a new key entry is written by the phhalHw_SamAV3_Cmd_SAM_ChangeKeyEntry command. The keys and key versions, of this new entry are set to zero. DF_Aid, DFKeyNo, RefNoKUC, SET, ExtSET, KeyNoCEK, KeyVCEK, KeyNoAEK and KeyVAEK are set according to the configuration parameters.
In case of a MIFARE key entry the diversification keys for key A and key B of all key versions are set according to the configuration parameters. These parameters can be accessd via PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_A and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_A resp. PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_B and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_B.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wKeyNo | [In] KeyEntry number to be formatted. |
| [in] | wKeyType | [In] New key type of the KeyEntry (predefined type of KeyType). |
| phStatus_t phKeyStore_SamAV3_SetKey | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wKeyNo, | ||
| uint16_t | wKeyVer, | ||
| uint16_t | wKeyType, | ||
| uint8_t * | pNewKey, | ||
| uint16_t | wNewKeyVer | ||
| ) |
Change a key entry at a given version.
First the command phhalHw_SamAV3_Cmd_SAM_GetKeyEntry is executed to get the information about the current key entry. If the current key type does not match with wKeyType or if the selected key version wKeyVer is not part of the current key entry the function is aborted. Otherwise the key with the given version is set to pKey and its version is set to wNewKeyVer by the phhalHw_SamAV3_Cmd_SAM_ChangeKeyEntry. DF_Aid, DFKeyNo, RefNoKUC, SET, ExtSET, KeyNoCEK, KeyVCEK, KeyNoAEK and KeyVAEK are set according to the configuration parameters.
In case of a MIFARE key entry the diversification keys for key A and key B of all key versions are set according to the configuration parameters. These parameters can be accessd via PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_A and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_A resp. PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_B and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_B.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wKeyNo | [In] Key number of the key to be loaded. |
| [in] | wKeyVer | [In] Key version of the key to be loaded. |
| [in] | wKeyType | [In] New key type of the KeyEntry (predefined type of KeyType). |
| [in] | pNewKey | [In] The key information to be updated. |
| [in] | wNewKeyVer | [In] New Key version of the key to be updated. |
| phStatus_t phKeyStore_SamAV3_SetKeyAtPos | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wKeyNo, | ||
| uint16_t | wPos, | ||
| uint16_t | wKeyType, | ||
| uint8_t * | pKey, | ||
| uint16_t | wKeyVer | ||
| ) |
Change a key entry at the specified position.
First the command phhalHw_SamAV3_Cmd_SAM_GetKeyEntry is executed to get the information about the current key entry. If the current key type does not match with wKeyType or if the selected key position is wrong the function is aborted. Otherwise the key at position wPos (00h to 02h) is set to pKey and its version is set to wKeyVer by the phhalHw_SamAV3_Cmd_SAM_ChangeKeyEntry. DF_Aid, DFKeyNo, RefNoKUC, SET, ExtSET, KeyNoCEK, KeyVCEK, KeyNoAEK and KeyVAEK are set according to the configuration parameters.
In case of a MIFARE key entry the diversification keys for key A and key B of all key versions are set according to the configuration parameters. These parameters can be accessd via PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_A and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_A resp. PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_B and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_B.
| PH_ERR_SUCCESS | Operation successful. |
| PH_ERR_INVALID_PARAMETER | KeyType missmatch or wrong wPos. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wKeyNo | [In] Key number of the key to be loaded. |
| [in] | wPos | [In] Key position to be updated. |
| [in] | wKeyType | [In] New key type of the KeyEntry (predefined type of KeyType). |
| [in] | pKey | [In] The key information to be loaded. |
| [in] | wKeyVer | [In] Key version of the key to be updated. |
| phStatus_t phKeyStore_SamAV3_SetKUC | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wKeyNo, | ||
| uint16_t | wRefNoKUC | ||
| ) |
Change the KUC of a key entry.
First the command phhalHw_SamAV3_Cmd_SAM_GetKeyEntry is executed to get the change key of the current key entry. Afterwards the reference number of the KUC is set to wRefNoKUC via the phhalHw_SamAV3_Cmd_SAM_ChangeKeyEntry command.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wKeyNo | [In] Key number of the key to be loaded. |
| [in] | wRefNoKUC | [In] Reference Number of the key usage counter used together with that key. |
| phStatus_t phKeyStore_SamAV3_SetFullKeyEntry | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wNoOfKeys, | ||
| uint16_t | wKeyNo, | ||
| uint16_t | wNewRefNoKUC, | ||
| uint16_t | wNewKeyType, | ||
| uint8_t * | pNewKeys, | ||
| uint16_t * | pNewKeyVerList | ||
| ) |
Change a full key entry.
First the command phhalHw_SamAV3_Cmd_SAM_GetKeyEntry is executed to get the information about the current key entry. If the current key type does not match with wKeyType also all keys of the entry have to be updated. If wNoOfKeys is 01h key A is changed to pKeys, if it is 02h key A and B are changed to pKeys and if it is 03h key A, B and C are changed to pKeys via the phhalHw_SamAV3_Cmd_SAM_ChangeKeyEntry command. If a key is changed also its version is changed to the value listed in pKeyVerList. Keys which are not provided by pKeys are set to zero togheter with its versions. If wNoOfKeys is set to 0 key and version update is skiped. The fields DF_Aid, DFKeyNo, SET, ExtSET, KeyNoCEK, KeyVCEK, KeyNoAEK and KeyVAEK are set according to the configuration parameters.
In case of a MIFARE key entry the diversification keys for key A and key B of all key versions are set according to the configuration parameters. These parameters can be accessd via PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_A and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_A resp. PH_KEYSTORE_SAMAV3_CONFIG_KEYNO_MF_DIV_B and PH_KEYSTORE_SAMAV3_CONFIG_KEYV_MF_DIV_B.
| PH_ERR_SUCCESS | Operation successful. |
| PH_ERR_INVALID_PARAMETER | KeyType missmatch or wrong wNoOfKeys. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wNoOfKeys | [In] Number of keys in pNewKeys. |
| [in] | wKeyNo | [In] Number of the keys to be changed in the entry. |
| [in] | wNewRefNoKUC | [In] Reference number of the key usage counter to be used. |
| [in] | wNewKeyType | [In] Key type of the new key. |
| [in] | pNewKeys | [In] Buffer containing the Keys to be updated. This buffer has to be wNoOfKeys * keylength bytes long. |
| [in] | pNewKeyVerList | [In] KeyVersionList of the key to be loaded. This buffer has to be wNoOfKeys * 2 bytes long. |
| phStatus_t phKeyStore_SamAV3_GetKeyEntry | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wKeyNo, | ||
| uint16_t * | pKeyVer, | ||
| uint16_t * | pKeyVerLen, | ||
| uint16_t * | pKeyType | ||
| ) |
Get a key entry information block.
The function returns the key type and all key versions of a key entry. This information is retrieved by the phhalHw_SamAV3_Cmd_SAM_GetKeyEntry command. All additional information which is returned by the phhalHw_SamAV3_Cmd_SAM_GetKeyEntry command is stored in the configuration parameters of this layer. To access these values the function phKeyStore_SamAV3_GetConfig has to be used.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wKeyNo | [In] Key number of the key entry of interest. |
| [out] | pKeyVer | [Out] Array for version information. |
| [out] | pKeyVerLen | [Out] Length of valid data in wKeyVer. |
| [out] | pKeyType | [Out] Type of the key. |
| phStatus_t phKeyStore_SamAV3_GetKey | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wKeyNo, | ||
| uint16_t | wKeyVer, | ||
| uint8_t | bKeyBufSize, | ||
| uint8_t * | pKey, | ||
| uint16_t * | pKeyType | ||
| ) |
Get a key.
The function returns a key selected by its key version:
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wKeyNo | [In] Key number of the key to be retrieved. |
| [in] | wKeyVer | [In] Key version of the key to be retrieved. |
| [in] | bKeyBufSize | [In] Size of the key buffer. |
| [out] | pKey | [Out] Pointer to the key itself. |
| [out] | pKeyType | [Out] Type of the key. |
| phStatus_t phKeyStore_SamAV3_SetConfig | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wConfig, | ||
| uint16_t | wValue | ||
| ) |
Set configuration parameter.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wConfig | [In] Configuration Identifier |
| [in] | wValue | [In] Configuration Value |
| phStatus_t phKeyStore_SamAV3_SetConfigStr | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wConfig, | ||
| uint8_t * | pBuffer, | ||
| uint16_t | wBufferLen | ||
| ) |
Set the Desfire Application Identifier.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wConfig | [In] Configuration Identifier, mainly PH_KEYSTORE_SAMAV3_CONFIG_DF_AID. |
| [in] | pBuffer | [In] Buffer containing the Defire Application Identifier. |
| [in] | wBufferLen | [In] Length of data available in pBuffer. |
| phStatus_t phKeyStore_SamAV3_GetConfig | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wConfig, | ||
| uint16_t * | pValue | ||
| ) |
Get configuration parameter.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wConfig | [In] Configuration Identifier |
| [out] | pValue | [Out] Configuration Value |
| phStatus_t phKeyStore_SamAV3_GetConfigStr | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wConfig, | ||
| uint8_t ** | ppBuffer, | ||
| uint16_t * | pBufferLen | ||
| ) |
Get the Desfire Application Identifier.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wConfig | [In] Configuration Identifier, mainly PH_KEYSTORE_SAMAV3_CONFIG_DF_AID |
| [out] | ppBuffer | [Out] Buffer containing the Defire Application Identifier. |
| [out] | pBufferLen | [Out] Length of data available in pBuffer. |
| phStatus_t phKeyStore_SamAV3_ChangeKUC | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wRefNoKUC, | ||
| uint32_t | dwLimit | ||
| ) |
Change a key usage counter entry.
The function changes the KUC by using the phhalHw_SamAV3_Cmd_SAM_ChangeKUCEntry command. KeyNoCKUC and KeyVCKUC are set to according to the configuration parameters.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wRefNoKUC | [In] Number of the key usage counter. |
| [in] | dwLimit | [In] Limit of the Key Usage Counter. |
| phStatus_t phKeyStore_SamAV3_GetKUC | ( | phKeyStore_SamAV3_DataParams_t * | pDataParams, |
| uint16_t | wRefNoKUC, | ||
| uint32_t * | pdwLimit, | ||
| uint32_t * | pdwCurVal | ||
| ) |
Obtain a key usage counter entry.
The function returns the KUC entry retrieved by the phhalHw_SamAV3_Cmd_SAM_GetKUCEntry command. KeyNoCKUC and KeyVCKUC are stored in the configuration parameters and can be accessed via the phKeyStore_SamAV3_GetConfig function.
| PH_ERR_SUCCESS | Operation successful. |
| Other | Depending on implementation and underlaying component. |
| [in] | pDataParams | [In] Pointer to this layers parameter structure. |
| [in] | wRefNoKUC | [In] Number of the key usage counter to be looked at (00h to 0Fh) |
| [out] | pdwLimit | [Out] Currently set Limit in the KUC. |
| [out] | pdwCurVal | [Out] Currently value in the KUC. |