C API for BALTECH SDK
desfire.h
Go to the documentation of this file.
1 
14 #ifndef __BRP_BALTECH_API_CMDS_DESFIRE_H__
15 #define __BRP_BALTECH_API_CMDS_DESFIRE_H__
16 #include "../typedefs.h"
20 #define BRP_Desfire_ErrIso14NoTag BRP_ERR_STATUS(0x1B00, 0x01)
21 
29 #define BRP_Desfire_ErrBreak BRP_ERR_STATUS(0x1B00, 0x03)
30 
34 #define BRP_Desfire_ErrIso14Hf BRP_ERR_STATUS(0x1B00, 0x04)
35 
39 #define BRP_Desfire_ErrIso14CardInvalid BRP_ERR_STATUS(0x1B00, 0x05)
40 
45 #define BRP_Desfire_ErrReaderChipCommunication BRP_ERR_STATUS(0x1B00, 0x06)
46 
49 #define BRP_Desfire_ErrIso14ApduCmd BRP_ERR_STATUS(0x1B00, 0x07)
50 
54 #define BRP_Desfire_ErrIso14InvalidResponse BRP_ERR_STATUS(0x1B00, 0x08)
55 
59 #define BRP_Desfire_ErrPcdAuthentication BRP_ERR_STATUS(0x1B00, 0x09)
60 
65 #define BRP_Desfire_ErrIntegrity BRP_ERR_STATUS(0x1B00, 0x0A)
66 
69 #define BRP_Desfire_ErrPcdKey BRP_ERR_STATUS(0x1B00, 0x0B)
70 
74 #define BRP_Desfire_ErrNoChanges BRP_ERR_STATUS(0x1B00, 0x0C)
75 
78 #define BRP_Desfire_ErrPcdParam BRP_ERR_STATUS(0x1B00, 0x0D)
79 
82 #define BRP_Desfire_VcsAndProxCheckError BRP_ERR_STATUS(0x1B00, 0x0F)
83 
86 #define BRP_Desfire_ErrFirmwareNotSupported BRP_ERR_STATUS(0x1B00, 0x10)
87 
92 #define BRP_Desfire_ErrSamCommunication BRP_ERR_STATUS(0x1B00, 0x11)
93 
97 #define BRP_Desfire_ErrSamUnlock BRP_ERR_STATUS(0x1B00, 0x12)
98 
103 #define BRP_Desfire_ErrHardwareNotSupported BRP_ERR_STATUS(0x1B00, 0x13)
104 
109 #define BRP_Desfire_ErrIllegalCmdLegacy BRP_ERR_STATUS(0x1B00, 0x1C)
110 
113 #define BRP_Desfire_ErrLength BRP_ERR_STATUS(0x1B00, 0x20)
114 
118 #define BRP_Desfire_ErrPermissionDenied BRP_ERR_STATUS(0x1B00, 0x21)
119 
122 #define BRP_Desfire_ErrParameter BRP_ERR_STATUS(0x1B00, 0x22)
123 
126 #define BRP_Desfire_ErrAppNotFound BRP_ERR_STATUS(0x1B00, 0x23)
127 
131 #define BRP_Desfire_ErrAppIntegrity BRP_ERR_STATUS(0x1B00, 0x24)
132 
136 #define BRP_Desfire_ErrAuthentication BRP_ERR_STATUS(0x1B00, 0x25)
137 
141 #define BRP_Desfire_ErrBoundary BRP_ERR_STATUS(0x1B00, 0x27)
142 
146 #define BRP_Desfire_ErrPiccIntegrity BRP_ERR_STATUS(0x1B00, 0x28)
147 
151 #define BRP_Desfire_ErrCommandAborted BRP_ERR_STATUS(0x1B00, 0x29)
152 
156 #define BRP_Desfire_ErrPiccDisabled BRP_ERR_STATUS(0x1B00, 0x2A)
157 
161 #define BRP_Desfire_ErrCount BRP_ERR_STATUS(0x1B00, 0x2B)
162 
166 #define BRP_Desfire_ErrDuplicate BRP_ERR_STATUS(0x1B00, 0x2C)
167 
171 #define BRP_Desfire_ErrEeprom BRP_ERR_STATUS(0x1B00, 0x2D)
172 
175 #define BRP_Desfire_ErrFileNotFound BRP_ERR_STATUS(0x1B00, 0x2E)
176 
180 #define BRP_Desfire_ErrFileIntegrity BRP_ERR_STATUS(0x1B00, 0x2F)
181 
184 #define BRP_Desfire_ErrNoSuchKey BRP_ERR_STATUS(0x1B00, 0x30)
185 
189 #define BRP_Desfire_ErrOutOfMemory BRP_ERR_STATUS(0x1B00, 0x32)
190 
193 #define BRP_Desfire_ErrIllegalCmd BRP_ERR_STATUS(0x1B00, 0x33)
194 
198 #define BRP_Desfire_ErrCmdOverflow BRP_ERR_STATUS(0x1B00, 0x34)
199 
222 brp_errcode brp_Desfire_ExecCommand(brp_protocol protocol, unsigned Cmd, brp_buf Header, size_t Header_len, brp_buf Param, size_t Param_len, brp_Desfire_ExecCommand_CryptoMode CryptoMode, unsigned ResponseLen, brp_buf* Resp, size_t* Resp_len, brp_mempool *mempool);
244 brp_errcode brp_Desfire_Authenticate(brp_protocol protocol, brp_Desfire_Authenticate_SecureMessaging SecureMessaging, unsigned DesKeynr, unsigned KeyId, bool KeyHasDivData, brp_Desfire_Authenticate_KeyDivMode KeyDivMode, bool KeyHasExtIdx, brp_buf KeyDivData, size_t KeyDivData_len, unsigned KeyExtIdx);
262 brp_errcode brp_Desfire_AuthExtKey(brp_protocol protocol, brp_Desfire_AuthExtKey_SecureMessaging SecureMessaging, unsigned DesKeyNr, brp_Desfire_AuthExtKey_CryptoMode CryptoMode, brp_buf Key, size_t Key_len);
270 brp_errcode brp_Desfire_SelectApplication(brp_protocol protocol, unsigned AppId);
283 brp_errcode brp_Desfire_ReadData(brp_protocol protocol, unsigned FileId, unsigned Adr, unsigned Len, brp_Desfire_ReadData_Mode Mode, brp_buf* Data, size_t* Data_len, brp_mempool *mempool);
294 brp_errcode brp_Desfire_WriteData(brp_protocol protocol, unsigned FileId, unsigned Adr, brp_buf Data, size_t Data_len, brp_Desfire_WriteData_Mode Mode);
318 brp_errcode brp_Desfire_ChangeExtKey(brp_protocol protocol, brp_Desfire_ChangeExtKey_MasterKeyType MasterKeyType, bool IsKeySet, bool IsAesKey, bool IsVersion, bool IsChangeKey, unsigned KeyNo, unsigned KeyVersion, brp_buf NewKey, size_t NewKey_len, brp_buf OldKey, size_t OldKey_len, unsigned KeySet);
343 brp_errcode brp_Desfire_ChangeKey(brp_protocol protocol, bool IsKeySet, bool IsMasterKey, bool IsChangeKey, unsigned KeyNr, brp_Desfire_ChangeKey_NewKeyDivMode NewKeyDivMode, bool NewKeyHasDivData, bool NewKeyHasExtIdx, unsigned NewKeyIdx, brp_Desfire_ChangeKey_CurKeyDivMode CurKeyDivMode, bool CurKeyHasDivData, bool CurKeyHasExtIdx, unsigned CurKeyIdx, brp_buf NewKeyDivData, size_t NewKeyDivData_len, brp_buf CurKeyDivData, size_t CurKeyDivData_len, unsigned NewKeyExtIdx, unsigned CurKeyExtIdx, unsigned KeySet);
379 brp_errcode brp_Desfire_CreateDam(brp_protocol protocol, unsigned AppId, brp_buf AppParams, size_t AppParams_len, brp_buf EncryptedDefaultDamKey, size_t EncryptedDefaultDamKey_len, brp_buf DamMacKey, size_t DamMacKey_len);
388 brp_errcode brp_Desfire_GetOriginalitySignature(brp_protocol protocol, brp_buf* Signature, size_t* Signature_len, brp_mempool *mempool);
413 brp_errcode brp_Desfire_VirtualCardSelect(brp_protocol protocol, bool ForceVcsAuthentication, bool UseExtVcSelectKeys, unsigned DiversifyMacKey, bool DiversifyEncKey, bool UseVcSelectKeys, brp_buf IID, size_t IID_len, unsigned EncKeyIdx, unsigned MacKeyIdx, brp_buf DivData, size_t DivData_len, brp_buf EncKey, size_t EncKey_len, brp_buf MacKey, size_t MacKey_len, unsigned* FciType, brp_buf* Fci, size_t* Fci_len, brp_mempool *mempool);
428 brp_errcode brp_Desfire_ProxCheck(brp_protocol protocol, unsigned M, bool UseExtProxKey, bool DiversifyProxKey, bool UseProxKey, unsigned ProxKeyIdx, brp_buf DivData, size_t DivData_len, brp_buf ProxKey, size_t ProxKey_len);
439 #endif
440 
brp_Desfire_WriteData_Mode
Communication settings linked to the file.
Definition: typedefs.h:815
brp_errcode brp_Desfire_ChangeKey(brp_protocol protocol, bool IsKeySet, bool IsMasterKey, bool IsChangeKey, unsigned KeyNr, brp_Desfire_ChangeKey_NewKeyDivMode NewKeyDivMode, bool NewKeyHasDivData, bool NewKeyHasExtIdx, unsigned NewKeyIdx, brp_Desfire_ChangeKey_CurKeyDivMode CurKeyDivMode, bool CurKeyHasDivData, bool CurKeyHasExtIdx, unsigned CurKeyIdx, brp_buf NewKeyDivData, size_t NewKeyDivData_len, brp_buf CurKeyDivData, size_t CurKeyDivData_len, unsigned NewKeyExtIdx, unsigned CurKeyExtIdx, unsigned KeySet)
Modifies a DESFire card key defined in the SAM or crypto memory.
brp_errcode brp_Desfire_AuthExtKey(brp_protocol protocol, brp_Desfire_AuthExtKey_SecureMessaging SecureMessaging, unsigned DesKeyNr, brp_Desfire_AuthExtKey_CryptoMode CryptoMode, brp_buf Key, size_t Key_len)
This command authenticates a card with the reader, similarly to the brp_Desfire_Authenticate() comman...
brp_errcode brp_Desfire_ReadData(brp_protocol protocol, unsigned FileId, unsigned Adr, unsigned Len, brp_Desfire_ReadData_Mode Mode, brp_buf *Data, size_t *Data_len, brp_mempool *mempool)
Reads data from a Standard or Backup data file.
brp_errcode brp_Desfire_VirtualCardSelect(brp_protocol protocol, bool ForceVcsAuthentication, bool UseExtVcSelectKeys, unsigned DiversifyMacKey, bool DiversifyEncKey, bool UseVcSelectKeys, brp_buf IID, size_t IID_len, unsigned EncKeyIdx, unsigned MacKeyIdx, brp_buf DivData, size_t DivData_len, brp_buf EncKey, size_t EncKey_len, brp_buf MacKey, size_t MacKey_len, unsigned *FciType, brp_buf *Fci, size_t *Fci_len, brp_mempool *mempool)
This command selects a virtual card.
brp_Desfire_Authenticate_KeyDivMode
Specifies diversification algorithm.
Definition: typedefs.h:735
brp_errcode brp_Desfire_SetFraming(brp_protocol protocol, brp_Desfire_SetFraming_CommMode CommMode)
This command switches the DESFire communication protocol mode to use (std, iso_wrapping).
unsigned int brp_errcode
This type is used library-wide for passing error codes in the return value of functions.
Definition: errorcodes.h:23
brp_errcode brp_Desfire_ResetAuthentication(brp_protocol protocol)
This command resets the reader's authentication state until the next call of the brp_Desfire_Authenti...
brp_errcode brp_Desfire_WriteData(brp_protocol protocol, unsigned FileId, unsigned Adr, brp_buf Data, size_t Data_len, brp_Desfire_WriteData_Mode Mode)
Writes data to a Standard or a Backup data file.
brp_errcode brp_Desfire_ExecCommand(brp_protocol protocol, unsigned Cmd, brp_buf Header, size_t Header_len, brp_buf Param, size_t Param_len, brp_Desfire_ExecCommand_CryptoMode CryptoMode, unsigned ResponseLen, brp_buf *Resp, size_t *Resp_len, brp_mempool *mempool)
Generic command to communicate to a DESFire card.
brp_Desfire_SetFraming_CommMode
Defines 14443-4 communication mode to DESFire card.
Definition: typedefs.h:888
struct brp_protocol_t * brp_protocol
This is a generic handle of a protocol.
Definition: protocol.h:34
brp_errcode brp_Desfire_ProxCheck(brp_protocol protocol, unsigned M, bool UseExtProxKey, bool DiversifyProxKey, bool UseProxKey, unsigned ProxKeyIdx, brp_buf DivData, size_t DivData_len, brp_buf ProxKey, size_t ProxKey_len)
This command executes a proximity check of the card.
Definition: typedefs.h:902
brp_errcode brp_Desfire_CreateDam(brp_protocol protocol, unsigned AppId, brp_buf AppParams, size_t AppParams_len, brp_buf EncryptedDefaultDamKey, size_t EncryptedDefaultDamKey_len, brp_buf DamMacKey, size_t DamMacKey_len)
This command creates a delegated application.
brp_Desfire_AuthExtKey_CryptoMode
Sets the encryption algorithm.
Definition: typedefs.h:775
brp_Desfire_ChangeExtKey_MasterKeyType
These bits must only be set if the card's Master Key is changed.
Definition: typedefs.h:834
struct brp_mempool_object_t * brp_mempool
mempool handle.
Definition: mempool.h:27
brp_Desfire_ChangeKey_NewKeyDivMode
Specifies diversification algorithm.
Definition: typedefs.h:852
brp_errcode brp_Desfire_ChangeExtKey(brp_protocol protocol, brp_Desfire_ChangeExtKey_MasterKeyType MasterKeyType, bool IsKeySet, bool IsAesKey, bool IsVersion, bool IsChangeKey, unsigned KeyNo, unsigned KeyVersion, brp_buf NewKey, size_t NewKey_len, brp_buf OldKey, size_t OldKey_len, unsigned KeySet)
This command allows to change any key stored on the card.
brp_errcode brp_Desfire_SelectApplication(brp_protocol protocol, unsigned AppId)
Selects an application of the DESFire card.
brp_Desfire_ReadData_Mode
Communication settings linked to the file.
Definition: typedefs.h:797
brp_errcode brp_Desfire_Authenticate(brp_protocol protocol, brp_Desfire_Authenticate_SecureMessaging SecureMessaging, unsigned DesKeynr, unsigned KeyId, bool KeyHasDivData, brp_Desfire_Authenticate_KeyDivMode KeyDivMode, bool KeyHasExtIdx, brp_buf KeyDivData, size_t KeyDivData_len, unsigned KeyExtIdx)
This command authenticates a card with the reader.
brp_Desfire_AuthExtKey_SecureMessaging
Sets the secure messaging mode.
Definition: typedefs.h:757
brp_errcode brp_Desfire_GetOriginalitySignature(brp_protocol protocol, brp_buf *Signature, size_t *Signature_len, brp_mempool *mempool)
This command returns the NXP originality signature of a desfire card.
brp_errcode brp_Desfire_GetDfNames(brp_protocol protocol, brp_Desfire_GetDfNames_AppNr_Entry **AppNr, size_t *AppNr_len, brp_mempool *mempool)
This command returns the application identifiers together with file IDs and (optionally) DF names of ...
brp_Desfire_ChangeKey_CurKeyDivMode
Specifies diversification algorithm.
Definition: typedefs.h:870
unsigned char * brp_buf
represents a pointer to a protocol data buffer.
Definition: common.h:61
brp_Desfire_ExecCommand_CryptoMode
Type of encryption.
Definition: typedefs.h:699
brp_Desfire_Authenticate_SecureMessaging
Sets the secure messaging mode.
Definition: typedefs.h:717