mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 14:23:50 -07:00
test session keys
This commit is contained in:
parent
707f436cac
commit
9e79326eed
2 changed files with 19 additions and 0 deletions
|
@ -619,6 +619,24 @@ int DesfireEV2CalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t d
|
|||
return aes_cmac8(NULL, ctx->sessionKeyMAC, mdata, mac, mdatalen);
|
||||
}
|
||||
|
||||
void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey) {
|
||||
uint8_t xiv[CRYPTO_AES_BLOCK_SIZE] = {0};
|
||||
|
||||
if (forMAC) {
|
||||
xiv[0] = 0x5a;
|
||||
} else {
|
||||
xiv[0] = 0xa5;
|
||||
}
|
||||
xiv[2] = 0x01;
|
||||
xiv[4] = 0x80;
|
||||
Uint4byteToMemLe(&xiv[5], trCntr + 1);
|
||||
memcpy(&xiv[9], uid, 7);
|
||||
|
||||
DesfireContext ctx = {0};
|
||||
DesfireSetKey(&ctx, 0, T_AES, key);
|
||||
DesfireCryptoCMACEx(&ctx, DCOMainKey, xiv, 16, 0, sessionkey);
|
||||
}
|
||||
|
||||
int desfire_get_key_length(DesfireCryptoAlgorythm key_type) {
|
||||
switch (key_type) {
|
||||
case T_DES:
|
||||
|
|
|
@ -137,6 +137,7 @@ void DesfireGenSessionKeyEV1(const uint8_t rnda[], const uint8_t rndb[], Desfire
|
|||
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);
|
||||
int DesfireEV2CalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *mac);
|
||||
void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey);
|
||||
|
||||
int desfire_get_key_length(DesfireCryptoAlgorythm key_type);
|
||||
size_t desfire_get_key_block_length(DesfireCryptoAlgorythm key_type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue