mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-09 03:00:07 -04:00
ev1 gen session keys
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user