mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 15:56:21 +08:00
lrp cmac protocol level
This commit is contained in:
parent
e55c8f969a
commit
8bd14245c6
|
@ -668,6 +668,24 @@ void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool
|
|||
DesfireCryptoCMACEx(&ctx, DCOMainKey, xiv, 16, 0, sessionkey);
|
||||
}
|
||||
|
||||
int DesfireLRPCalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *mac) {
|
||||
uint8_t mdata[1050] = {0};
|
||||
size_t mdatalen = 0;
|
||||
|
||||
mdata[0] = cmd;
|
||||
Uint2byteToMemLe(&mdata[1], ctx->cmdCntr);
|
||||
memcpy(&mdata[3], ctx->TI, 4);
|
||||
if (data != NULL && datalen > 0)
|
||||
memcpy(&mdata[7], data, datalen);
|
||||
mdatalen = 1 + 2 + 4 + datalen;
|
||||
|
||||
LRPContext lctx = {0};
|
||||
LRPSetKey(&lctx, ctx->sessionKeyMAC, 0, true);
|
||||
LRPCMAC8(&lctx, mdata, mdatalen, mac);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int desfire_get_key_length(DesfireCryptoAlgorythm key_type) {
|
||||
switch (key_type) {
|
||||
case T_DES:
|
||||
|
|
|
@ -144,6 +144,8 @@ 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 DesfireLRPCalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *mac);
|
||||
|
||||
int desfire_get_key_length(DesfireCryptoAlgorythm key_type);
|
||||
size_t desfire_get_key_block_length(DesfireCryptoAlgorythm key_type);
|
||||
size_t padded_data_length(const size_t nbytes, const size_t block_size);
|
||||
|
|
Loading…
Reference in a new issue