Skip to content

Commit

Permalink
Fixing legacy auth algorithm from 3K3DES -> 2K3DES (cf. emsec#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxieds committed Feb 12, 2022
1 parent 1644a9e commit 20a6960
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 127 deletions.
171 changes: 71 additions & 100 deletions Firmware/Chameleon-Mini/Application/CryptoTDEA.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,144 +8,115 @@
#include "CryptoTDEA.h"
#include "CryptoAES128.h"

void EncryptDESBuffer(uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoEncryptDEA,
.blockSize = CRYPTO_DES_BLOCK_SIZE
};
uint16_t numBlocks = (Count + CryptoSpec.blockSize - 1) / CryptoSpec.blockSize;
bool dataNeedsPadding = (Count % CryptoSpec.blockSize) != 0;
static void CryptoEncryptCBCBuffer(CryptoTDEA_CBCSpec *CryptoSpec, uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys);
static void CryptoEncryptCBCBuffer(CryptoTDEA_CBCSpec *CryptoSpec, uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
uint16_t numBlocks = (Count + CryptoSpec->blockSize - 1) / CryptoSpec->blockSize;
bool dataNeedsPadding = (Count % CryptoSpec->blockSize) != 0;
uint16_t blockIndex = 0;
uint8_t *ctBuf = (uint8_t *) Ciphertext;
uint8_t inputBlock[CRYPTO_DES_BLOCK_SIZE];
uint8_t IV[CRYPTO_DES_BLOCK_SIZE];
uint8_t inputBlock[CryptoSpec->blockSize];
uint8_t IV[CryptoSpec->blockSize];
if (IVIn == NULL) {
memset(IV, 0x00, CRYPTO_DES_BLOCK_SIZE);
memset(IV, 0x00, CryptoSpec->blockSize);
} else {
memcpy(IV, IVIn, CRYPTO_DES_BLOCK_SIZE);
memcpy(IV, IVIn, CryptoSpec->blockSize);
}
while (blockIndex < numBlocks) {
if (blockIndex == 0) {
memset(inputBlock, 0x00, CRYPTO_DES_BLOCK_SIZE);
memcpy(inputBlock, &Plaintext[0], CRYPTO_DES_BLOCK_SIZE);
CryptoMemoryXOR(IV, inputBlock, CRYPTO_DES_BLOCK_SIZE);
memset(inputBlock, 0x00, CryptoSpec->blockSize);
memcpy(inputBlock, &Plaintext[0], CryptoSpec->blockSize);
CryptoMemoryXOR(IV, inputBlock, CryptoSpec->blockSize);
} else if (dataNeedsPadding && blockIndex + 1 == numBlocks) {
memset(inputBlock, 0x00, CRYPTO_DES_BLOCK_SIZE);
memcpy(inputBlock, &Ciphertext[(blockIndex - 1) * CRYPTO_DES_BLOCK_SIZE], Count % CryptoSpec.blockSize);
CryptoMemoryXOR(&Plaintext[blockIndex * CRYPTO_DES_BLOCK_SIZE], inputBlock, CRYPTO_DES_BLOCK_SIZE);
memset(inputBlock, 0x00, CryptoSpec->blockSize);
memcpy(inputBlock, &Ciphertext[(blockIndex - 1) * CryptoSpec->blockSize], Count % CryptoSpec->blockSize);
CryptoMemoryXOR(&Plaintext[blockIndex * CryptoSpec->blockSize], inputBlock, CryptoSpec->blockSize);
} else {
memcpy(inputBlock, &Ciphertext[(blockIndex - 1) * CRYPTO_DES_BLOCK_SIZE], CRYPTO_DES_BLOCK_SIZE);
CryptoMemoryXOR(&Plaintext[blockIndex * CRYPTO_DES_BLOCK_SIZE], inputBlock, CRYPTO_DES_BLOCK_SIZE);
memcpy(inputBlock, &Ciphertext[(blockIndex - 1) * CryptoSpec->blockSize], CryptoSpec->blockSize);
CryptoMemoryXOR(&Plaintext[blockIndex * CryptoSpec->blockSize], inputBlock, CryptoSpec->blockSize);
}
CryptoSpec.cryptFunc(inputBlock, ctBuf, Keys);
ctBuf += CryptoSpec.blockSize;
CryptoSpec->cryptFunc(inputBlock, ctBuf, Keys);
ctBuf += CryptoSpec->blockSize;
blockIndex++;
}
}

void DecryptDESBuffer(uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoDecryptDEA,
.blockSize = CRYPTO_DES_BLOCK_SIZE
};
uint16_t numBlocks = (Count + CryptoSpec.blockSize - 1) / CryptoSpec.blockSize;
bool dataNeedsPadding = (Count % CryptoSpec.blockSize) != 0;
static void CryptoDecryptCBCBuffer(CryptoTDEA_CBCSpec *CryptoSpec, uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys);
static void CryptoDecryptCBCBuffer(CryptoTDEA_CBCSpec *CryptoSpec, uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
uint16_t numBlocks = (Count + CryptoSpec->blockSize - 1) / CryptoSpec->blockSize;
bool dataNeedsPadding = (Count % CryptoSpec->blockSize) != 0;
uint16_t blockIndex = 0;
uint8_t inputBlock[CRYPTO_DES_BLOCK_SIZE];
uint8_t IV[CRYPTO_DES_BLOCK_SIZE];
uint8_t inputBlock[CryptoSpec->blockSize];
uint8_t IV[CryptoSpec->blockSize];
if (IVIn == NULL) {
memset(IV, 0x00, CRYPTO_DES_BLOCK_SIZE);
memset(IV, 0x00, CryptoSpec->blockSize);
} else {
memcpy(IV, IVIn, CRYPTO_DES_BLOCK_SIZE);
memcpy(IV, IVIn, CryptoSpec->blockSize);
}
while (blockIndex < numBlocks) {
CryptoSpec.cryptFunc(inputBlock, Ciphertext + blockIndex * CRYPTO_DES_BLOCK_SIZE, Keys);
CryptoSpec->cryptFunc(inputBlock, Ciphertext + blockIndex * CryptoSpec->blockSize, Keys);
if (blockIndex == 0 && !dataNeedsPadding) {
memcpy(Plaintext, inputBlock, CRYPTO_DES_BLOCK_SIZE);
CryptoMemoryXOR(IV, Plaintext, CRYPTO_DES_BLOCK_SIZE);
memcpy(Plaintext, inputBlock, CryptoSpec->blockSize);
CryptoMemoryXOR(IV, Plaintext, CryptoSpec->blockSize);
} else if (blockIndex == 0 && dataNeedsPadding && numBlocks == 0x01) {
memcpy(Plaintext, inputBlock, Count % CryptoSpec.blockSize);
CryptoMemoryXOR(IV, Plaintext, Count % CryptoSpec.blockSize);
memcpy(Plaintext, inputBlock, Count % CryptoSpec->blockSize);
CryptoMemoryXOR(IV, Plaintext, Count % CryptoSpec->blockSize);
} else if (dataNeedsPadding && blockIndex + 1 == numBlocks) {
memcpy(Plaintext + blockIndex * CRYPTO_DES_BLOCK_SIZE, inputBlock, Count % CryptoSpec.blockSize);
CryptoMemoryXOR(&Ciphertext[(blockIndex - 1) * CRYPTO_DES_BLOCK_SIZE],
Plaintext + blockIndex * CRYPTO_DES_BLOCK_SIZE, Count % CryptoSpec.blockSize);
memcpy(Plaintext + blockIndex * CryptoSpec->blockSize, inputBlock, Count % CryptoSpec->blockSize);
CryptoMemoryXOR(&Ciphertext[(blockIndex - 1) * CryptoSpec->blockSize],
Plaintext + blockIndex * CryptoSpec->blockSize, Count % CryptoSpec->blockSize);
} else {
memcpy(Plaintext + blockIndex * CRYPTO_DES_BLOCK_SIZE, inputBlock, CRYPTO_DES_BLOCK_SIZE);
CryptoMemoryXOR(&Ciphertext[(blockIndex - 1) * CRYPTO_DES_BLOCK_SIZE],
Plaintext + blockIndex * CRYPTO_DES_BLOCK_SIZE, CRYPTO_DES_BLOCK_SIZE);
memcpy(Plaintext + blockIndex * CryptoSpec->blockSize, inputBlock, CryptoSpec->blockSize);
CryptoMemoryXOR(&Ciphertext[(blockIndex - 1) * CryptoSpec->blockSize],
Plaintext + blockIndex * CryptoSpec->blockSize, CryptoSpec->blockSize);
}
blockIndex++;
}
}

void EncryptDESBuffer(uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoEncryptDEA,
.blockSize = CRYPTO_DES_BLOCK_SIZE
};
CryptoEncryptCBCBuffer(&CryptoSpec, Count, Plaintext, Ciphertext, IVIn, Keys);
}

void DecryptDESBuffer(uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoDecryptDEA,
.blockSize = CRYPTO_DES_BLOCK_SIZE
};
CryptoDecryptCBCBuffer(&CryptoSpec, Count, Plaintext, Ciphertext, IVIn, Keys);
}

void Encrypt2K3DESBuffer(uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoEncrypt2KTDEA,
.blockSize = CRYPTO_2KTDEA_BLOCK_SIZE
};
CryptoEncryptCBCBuffer(&CryptoSpec, Count, Plaintext, Ciphertext, IVIn, Keys);
}

void Decrypt2K3DESBuffer(uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoDecrypt2KTDEA,
.blockSize = CRYPTO_2KTDEA_BLOCK_SIZE
};
CryptoDecryptCBCBuffer(&CryptoSpec, Count, Plaintext, Ciphertext, IVIn, Keys);
}

void Encrypt3DESBuffer(uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoEncrypt3KTDEA,
.blockSize = CRYPTO_3KTDEA_BLOCK_SIZE
};
uint16_t numBlocks = (Count + CryptoSpec.blockSize - 1) / CryptoSpec.blockSize;
bool dataNeedsPadding = (Count % CryptoSpec.blockSize) != 0;
uint8_t *ctBuf = (uint8_t *) Ciphertext;
uint16_t blockIndex = 0;
uint8_t inputBlock[CRYPTO_3KTDEA_BLOCK_SIZE];
uint8_t IV[CRYPTO_3KTDEA_BLOCK_SIZE];
if (IVIn == NULL) {
memset(IV, 0x00, CRYPTO_3KTDEA_BLOCK_SIZE);
} else {
memcpy(IV, IVIn, CRYPTO_3KTDEA_BLOCK_SIZE);
}
while (blockIndex < numBlocks) {
if (blockIndex == 0) {
memset(inputBlock, 0x00, CRYPTO_3KTDEA_BLOCK_SIZE);
memcpy(inputBlock, &Plaintext[0], CRYPTO_3KTDEA_BLOCK_SIZE);
CryptoMemoryXOR(IV, inputBlock, CRYPTO_3KTDEA_BLOCK_SIZE);
} else if (dataNeedsPadding && blockIndex + 1 == numBlocks) {
memset(inputBlock, 0x00, CRYPTO_3KTDEA_BLOCK_SIZE);
memcpy(inputBlock, &Ciphertext[(blockIndex - 1) * CRYPTO_3KTDEA_BLOCK_SIZE], Count % CryptoSpec.blockSize);
CryptoMemoryXOR(&Plaintext[blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE], inputBlock, CRYPTO_3KTDEA_BLOCK_SIZE);
} else {
memcpy(inputBlock, &Ciphertext[(blockIndex - 1) * CRYPTO_3KTDEA_BLOCK_SIZE], CRYPTO_3KTDEA_BLOCK_SIZE);
CryptoMemoryXOR(&Plaintext[blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE], inputBlock, CRYPTO_3KTDEA_BLOCK_SIZE);
}
CryptoSpec.cryptFunc(inputBlock, ctBuf, Keys);
ctBuf += CryptoSpec.blockSize;
blockIndex++;
}
CryptoEncryptCBCBuffer(&CryptoSpec, Count, Plaintext, Ciphertext, IVIn, Keys);
}

void Decrypt3DESBuffer(uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IVIn, const uint8_t *Keys) {
CryptoTDEA_CBCSpec CryptoSpec = {
.cryptFunc = &CryptoDecrypt3KTDEA,
.blockSize = CRYPTO_3KTDEA_BLOCK_SIZE
};
uint16_t numBlocks = (Count + CryptoSpec.blockSize - 1) / CryptoSpec.blockSize;
bool dataNeedsPadding = (Count % CryptoSpec.blockSize) != 0;
uint16_t blockIndex = 0;
uint8_t inputBlock[CRYPTO_3KTDEA_BLOCK_SIZE];
uint8_t IV[CRYPTO_3KTDEA_BLOCK_SIZE];
if (IVIn == NULL) {
memset(IV, 0x00, CRYPTO_3KTDEA_BLOCK_SIZE);
} else {
memcpy(IV, IVIn, CRYPTO_3KTDEA_BLOCK_SIZE);
}
while (blockIndex < numBlocks) {
CryptoSpec.cryptFunc(inputBlock, Ciphertext + blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE, Keys);
if (blockIndex == 0 && !dataNeedsPadding) {
memcpy(Plaintext, inputBlock, CRYPTO_3KTDEA_BLOCK_SIZE);
CryptoMemoryXOR(IV, Plaintext, CRYPTO_3KTDEA_BLOCK_SIZE);
} else if (blockIndex == 0 && dataNeedsPadding && numBlocks == 0x01) {
memcpy(Plaintext, inputBlock, Count % CryptoSpec.blockSize);
CryptoMemoryXOR(IV, Plaintext, Count % CryptoSpec.blockSize);
} else if (dataNeedsPadding && blockIndex + 1 == numBlocks) {
memcpy(Plaintext + blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE, inputBlock, Count % CryptoSpec.blockSize);
CryptoMemoryXOR(&Ciphertext[(blockIndex - 1) * CRYPTO_3KTDEA_BLOCK_SIZE],
Plaintext + blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE, Count % CryptoSpec.blockSize);
} else {
memcpy(Plaintext + blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE, inputBlock, CRYPTO_3KTDEA_BLOCK_SIZE);
CryptoMemoryXOR(&Ciphertext[(blockIndex - 1) * CRYPTO_3KTDEA_BLOCK_SIZE],
Plaintext + blockIndex * CRYPTO_3KTDEA_BLOCK_SIZE, CRYPTO_3KTDEA_BLOCK_SIZE);
}
blockIndex++;
}
CryptoDecryptCBCBuffer(&CryptoSpec, Count, Plaintext, Ciphertext, IVIn, Keys);
}
3 changes: 3 additions & 0 deletions Firmware/Chameleon-Mini/Application/CryptoTDEA.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ void DecryptDESBuffer(uint16_t Count, void *Plaintext, const void *Ciphertext, c
void CryptoEncrypt2KTDEA(const void *Plaintext, void *Ciphertext, const uint8_t *Keys);
void CryptoDecrypt2KTDEA(const void *Plaintext, void *Ciphertext, const uint8_t *Keys);

void Encrypt2K3DESBuffer(uint16_t Count, const void *Plaintext, void *Ciphertext, const uint8_t *IV, const uint8_t *Keys);
void Decrypt2K3DESBuffer(uint16_t Count, void *Plaintext, const void *Ciphertext, const uint8_t *IV, const uint8_t *Keys);

void CryptoEncrypt3KTDEA(void *Plaintext, void *Ciphertext, const uint8_t *Keys);
void CryptoDecrypt3KTDEA(void *Plaintext, void *Ciphertext, const uint8_t *Keys);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ This notice must be retained at the top of all source files where indicated.

#define DESFIRE_LITTLE_ENDIAN (1)

#define DESFIRE_PICC_STRUCT_PACKING __attribute__((aligned(4)))
#define DESFIRE_PICC_STRUCT_PACKING __attribute__((aligned(1)))
#define DESFIRE_FIRMWARE_PACKING __attribute__((packed))
#define DESFIRE_FIRMWARE_ALIGNAT __attribute__((aligned(4)))
#define DESFIRE_PICC_ARRAY_ALIGNAT __attribute__((aligned(4)))
#define DESFIRE_FIRMWARE_ARRAY_ALIGNAT __attribute__((aligned(4)))
#define DESFIRE_FIRMWARE_ENUM_PACKING __attribute__((aligned(4)))
#define DESFIRE_FIRMWARE_ALIGNAT __attribute__((aligned(1)))
#define DESFIRE_PICC_ARRAY_ALIGNAT __attribute__((aligned(1)))
#define DESFIRE_FIRMWARE_ARRAY_ALIGNAT __attribute__((aligned(1)))
#define DESFIRE_FIRMWARE_ENUM_PACKING __attribute__((aligned(1)))
#define DESFIRE_FIRMWARE_NOINIT __attribute__ ((section (".noinit")))

/* Some standard boolean interpreted and other values for types and return values: */
Expand Down
32 changes: 21 additions & 11 deletions Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,25 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
}
/* Make sure that this key is AES, and figure out its byte size */
BYTE cryptoKeyType = ReadKeyCryptoType(SelectedApp.Slot, KeyId);
if (!CryptoType3KTDEA(cryptoKeyType)) {
if (!CryptoTypeDES(cryptoKeyType) && !CryptoType2KTDEA(cryptoKeyType)) {
Buffer[0] = STATUS_NO_SUCH_KEY;
return DESFIRE_STATUS_RESPONSE_SIZE;
}

/* Indicate that we are in DES key authentication land */
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_3K3DES);
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_2KTDEA);
Key = SessionKey;
DesfireCommandState.KeyId = KeyId;
DesfireCommandState.CryptoMethodType = CRYPTO_TYPE_3K3DES;
DesfireCommandState.ActiveCommMode = GetCryptoMethodCommSettings(CRYPTO_TYPE_3K3DES);

/* Fetch the key */
ReadAppKey(SelectedApp.Slot, KeyId, Key, keySize);
if (cryptoKeyType == CRYPTO_TYPE_DES) {
ReadAppKey(SelectedApp.Slot, KeyId, Key, CRYPTO_DES_KEY_SIZE);
memcpy(Key + CRYPTO_DES_KEY_SIZE, Key, CRYPTO_DES_KEY_SIZE);
} else {
ReadAppKey(SelectedApp.Slot, KeyId, Key, keySize);
}
LogEntry(LOG_APP_AUTH_KEY, (const void *) Key, keySize);

/* Generate the nonce B (RndB / Challenge response) */
Expand Down Expand Up @@ -488,8 +493,8 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
LogEntry(LOG_APP_NONCE_B, DesfireCommandState.RndB, CRYPTO_CHALLENGE_RESPONSE_BYTES);

/* Encrypt RndB with the selected key and transfer it back to the PCD */
Encrypt3DESBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, DesfireCommandState.RndB,
&Buffer[1], NULL, Key);
Encrypt2K3DESBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, DesfireCommandState.RndB,
&Buffer[1], NULL, Key);

/* Scrub the key */
memset(Key, 0, keySize);
Expand Down Expand Up @@ -519,14 +524,19 @@ uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {
cryptoKeyType = DesfireCommandState.CryptoMethodType;
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_3K3DES);
Key = SessionKey;
ReadAppKey(SelectedApp.Slot, KeyId, Key, keySize);
if (cryptoKeyType == CRYPTO_TYPE_DES) {
ReadAppKey(SelectedApp.Slot, KeyId, Key, CRYPTO_DES_KEY_SIZE);
memcpy(Key + CRYPTO_DES_KEY_SIZE, Key, CRYPTO_DES_KEY_SIZE);
} else {
ReadAppKey(SelectedApp.Slot, KeyId, Key, keySize);
}

/* Decrypt the challenge sent back to get RndA and a shifted RndB */
BYTE challengeRndAB[2 * CRYPTO_CHALLENGE_RESPONSE_BYTES];
BYTE challengeRndA[CRYPTO_CHALLENGE_RESPONSE_BYTES];
BYTE challengeRndB[CRYPTO_CHALLENGE_RESPONSE_BYTES];
Decrypt3DESBuffer(2 * CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB,
&Buffer[1], NULL, Key);
Decrypt2K3DESBuffer(2 * CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB,
&Buffer[1], NULL, Key);
RotateArrayRight(challengeRndAB + CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndB,
CRYPTO_CHALLENGE_RESPONSE_BYTES);
memcpy(challengeRndA, challengeRndAB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
Expand All @@ -539,11 +549,11 @@ uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {

/* Encrypt and send back the once rotated RndA buffer to the PCD */
RotateArrayLeft(challengeRndA, challengeRndAB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
Encrypt3DESBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB,
&Buffer[1], NULL, Key);
Encrypt2K3DESBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB,
&Buffer[1], NULL, Key);

/* Create the session key based on the previous exchange */
generateSessionKey(SessionKey, challengeRndA, challengeRndB, CRYPTO_TYPE_3K3DES);
generateSessionKey(SessionKey, challengeRndA, challengeRndB, CRYPTO_TYPE_2KTDEA);

/* Now that we have auth'ed with the legacy command, a ChangeKey command will
* allow for subsequent authentication with the ISO or AES routines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This notice must be retained at the top of all source files where indicated.
#define DESFIRE_ISO7816_CLA 0x00

/* Storage allocation constants */
#define DESFIRE_BLOCK_SIZE (4) /* Bytes */
#define DESFIRE_BLOCK_SIZE (1) /* Bytes */
#define DESFIRE_BYTES_TO_BLOCKS(x) ( ((x) + DESFIRE_BLOCK_SIZE - 1) / DESFIRE_BLOCK_SIZE )

#define DESFIRE_UID_SIZE ISO14443A_UID_SIZE_DOUBLE
Expand Down
Loading

0 comments on commit 20a6960

Please sign in to comment.