mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 22:33:48 -07:00
ev1 gen session keys
This commit is contained in:
parent
d80656ef53
commit
dd74ec9523
2 changed files with 30 additions and 0 deletions
|
@ -389,6 +389,35 @@ uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode comm_mode) {
|
|||
return fmode;
|
||||
}
|
||||
|
||||
void DesfireGenSessionKeyEV1(const uint8_t rnda[], const uint8_t rndb[], DesfireCryptoAlgorythm keytype, uint8_t *key) {
|
||||
switch (keytype) {
|
||||
case T_DES:
|
||||
memcpy(key, rnda, 4);
|
||||
memcpy(key + 4, rndb, 4);
|
||||
break;
|
||||
case T_3DES:
|
||||
memcpy(key, rnda, 4);
|
||||
memcpy(key + 4, rndb, 4);
|
||||
memcpy(key + 8, rnda + 4, 4);
|
||||
memcpy(key + 12, rndb + 4, 4);
|
||||
break;
|
||||
case T_3K3DES:
|
||||
memcpy(key, rnda, 4);
|
||||
memcpy(key + 4, rndb, 4);
|
||||
memcpy(key + 8, rnda + 6, 4);
|
||||
memcpy(key + 12, rndb + 6, 4);
|
||||
memcpy(key + 16, rnda + 12, 4);
|
||||
memcpy(key + 20, rndb + 12, 4);
|
||||
break;
|
||||
case T_AES:
|
||||
memcpy(key, rnda, 4);
|
||||
memcpy(key + 4, rndb, 4);
|
||||
memcpy(key + 8, rnda + 12, 4);
|
||||
memcpy(key + 12, rndb + 12, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.nxp.com/docs/en/application-note/AN12343.pdf
|
||||
// page 35
|
||||
void DesfireGenSessionKeyEV2(uint8_t *key, uint8_t *rndA, uint8_t *rndB, bool enckey, uint8_t *sessionkey) {
|
||||
|
|
|
@ -108,6 +108,7 @@ uint8_t DesfireDESKeyGetVersion(uint8_t *key);
|
|||
DesfireCommunicationMode DesfireFileCommModeToCommMode(uint8_t file_comm_mode);
|
||||
uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode comm_mode);
|
||||
|
||||
void DesfireGenSessionKeyEV1(const uint8_t rnda[], const uint8_t rndb[], DesfireCryptoAlgorythm keytype, uint8_t *key);
|
||||
void DesfireGenSessionKeyEV2(uint8_t *key, uint8_t *rndA, uint8_t *rndB, bool enckey, uint8_t *sessionkey);
|
||||
void DesfireEV2FillIV(DesfireContext *ctx, bool ivforcommand, uint8_t *iv);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue