C API for BALTECH SDK

§ brp_Desfire_ChangeExtKey()

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.

The key length has to be set according to the desired encryption algorithm:

  • DES encryption uses keys of 8 Byte.
  • 3DES and AES encryption uses keys of 16 Byte.
  • 3K3DES encryption uses keys of 24 Byte.
Parameters
[in]protocolused to execute the command
[in]MasterKeyTypeThese bits must only be set if the card's Master Key is changed. They specify the type of the new card's Master Key.
[in]IsKeySetOnly needed for Desfire EV2 with multiple Keysets. If true ,the reader executes the Desfire "ChangeKeyEV2" command instead of the Desfire "ChangeKey" command.
[in]IsAesKeyHas to be set if the new key is an AES key.
[in]IsVersionHas to be set if the NewKeyVersion parameter is present.
[in]IsChangeKeyHas to be set if the key used to authenticate the card is the key that needs to be changed (as specified in KeyNo). In this case, the parameter OldKey has to be omitted.
[in]KeyNoNumber of key (0-13) to modify. Has to be 0 if the application Master Key is changed.
[in]KeyVersionVersion of the new key. Remarks: * If this value is not available (i.e. if IsVersion is not set), 0 will be assumed as NewKeyVersion.
[in]NewKeyNew key (16 bytes).
[in]NewKey_len
[in]OldKeyCurrent key (16 bytes).
[in]OldKey_len
[in]KeySetspecifies KeySet needed for multiple keysets (EV2 extension).