ev1 gen session keys
This commit is contained in:
1 parent
d80656ef53
commit
dd74ec9523
2 files changed
+30
No files matched your search
@@ -389,6 +389,35 @@ uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode comm_mode) {
|
|||||||
return fmode;
|
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
|
// https://www.nxp.com/docs/en/application-note/AN12343.pdf
|
||||||
// page 35
|
// page 35
|
||||||
void DesfireGenSessionKeyEV2(uint8_t *key, uint8_t *rndA, uint8_t *rndB, bool enckey, uint8_t *sessionkey) {
|
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);
|
DesfireCommunicationMode DesfireFileCommModeToCommMode(uint8_t file_comm_mode);
|
||||||
uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode 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 DesfireGenSessionKeyEV2(uint8_t *key, uint8_t *rndA, uint8_t *rndB, bool enckey, uint8_t *sessionkey);
|
||||||
void DesfireEV2FillIV(DesfireContext *ctx, bool ivforcommand, uint8_t *iv);
|
void DesfireEV2FillIV(DesfireContext *ctx, bool ivforcommand, uint8_t *iv);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user