Skip to content

Commit

Permalink
Stashing incremental testing release code
Browse files Browse the repository at this point in the history
  • Loading branch information
maxieds committed Jan 31, 2022
1 parent ca0afad commit 7176259
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 6 deletions.
38 changes: 38 additions & 0 deletions Firmware/Chameleon-Mini/Application/CryptoMAC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
The DESFire stack portion of this firmware source
is free software written by Maxie Dion Schmidt (@maxieds):
You can redistribute it and/or modify
it under the terms of this license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The complete source distribution of
this firmware is available at the following link:
https://github.com/maxieds/ChameleonMiniFirmwareDESFireStack.
Based in part on the original DESFire code created by
@dev-zzo (GitHub handle) [Dmitry Janushkevich] available at
https://github.com/dev-zzo/ChameleonMini/tree/desfire.
This notice must be retained at the top of all source files where indicated.
*/

/*
* CryptoMAC.h :
* Maxie D. Schmidt (github.com/maxieds)
*/

#ifndef __CRYPTO_MAC_H__
#define __CRYPTO_MAC_H__

#include "DESFire/DESFireCrypto.h"
#include "CryptoTDEA.h"
#include "CryptoAES128.h"





#endif
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
}

/* Indicate that we are in DES key authentication land */
Key = &SessionKey;
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_3K3DES);
Key = &SessionKey;
DesfireCommandState.KeyId = KeyId;
DesfireCommandState.CryptoMethodType = CRYPTO_TYPE_3K3DES;
DesfireCommandState.ActiveCommMode = GetCryptoMethodCommSettings(CRYPTO_TYPE_3K3DES);
Expand Down Expand Up @@ -510,10 +510,10 @@ uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {
}

/* Reset parameters for authentication from the first exchange */
Key = &SessionKey;
KeyId = DesfireCommandState.KeyId;
cryptoKeyType = DesfireCommandState.CryptoMethodType;
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_3K3DES);
Key = &SessionKey;
ReadAppKey(SelectedApp.Slot, KeyId, *Key, keySize);

/* Decrypt the challenge sent back to get RndA and a shifted RndB */
Expand Down Expand Up @@ -1763,10 +1763,10 @@ uint16_t DesfireCmdAuthenticate3KTDEA2(uint8_t *Buffer, uint16_t ByteCount) {
}

/* Reset parameters for authentication from the first exchange */
Key = &SessionKey;
KeyId = DesfireCommandState.KeyId;
cryptoKeyType = DesfireCommandState.CryptoMethodType;
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_3K3DES);
Key = &SessionKey;
ReadAppKey(SelectedApp.Slot, KeyId, *Key, keySize);

/* Decrypt the challenge sent back to get RndA and a shifted RndB */
Expand Down
39 changes: 39 additions & 0 deletions Firmware/Chameleon-Mini/Application/DESFire/DESFireKeyUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
The DESFire stack portion of this firmware source
is free software written by Maxie Dion Schmidt (@maxieds):
You can redistribute it and/or modify
it under the terms of this license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The complete source distribution of
this firmware is available at the following link:
https://github.com/maxieds/ChameleonMiniFirmwareDESFireStack.
Based in part on the original DESFire code created by
@dev-zzo (GitHub handle) [Dmitry Janushkevich] available at
https://github.com/dev-zzo/ChameleonMini/tree/desfire.
This notice must be retained at the top of all source files where indicated.
*/

/*
* DESFireKeyUtils.h :
* Maxie D. Schmidt (github.com/maxieds)
*/

#ifndef __DESFIRE_KEY_UTILS_H__
#define __DESFIRE_KEY_UTILS_H__

#include "DESFireCrypto.h"

/* TODO: Placeholder for:
* => Key (re)initialization
* => Configuring the session key on the fly
* => CommSettings: PLAIN | MACED | ENCIPHERD
* => Possibly others
*/

#endif
6 changes: 3 additions & 3 deletions Firmware/Chameleon-Mini/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ SETTINGS += -DDESFIRE_DEFAULT_LOGGING_MODE=DEBUGGING
#SETTINGS += -DDESFIRE_DEFAULT_LOGGING_MODE=OFF

#Set a default testing mode setting (0 = OFF, non-NULL = ON):
SETTINGS += -DDESFIRE_DEFAULT_TESTING_MODE=0
#SETTINGS += -DDESFIRE_DEFAULT_TESTING_MODE=1
#SETTINGS += -DDESFIRE_DEFAULT_TESTING_MODE=0
SETTINGS += -DDESFIRE_DEFAULT_TESTING_MODE=1

#Feature: Use randomized UIDs that mask the actual secret UID until
#the tag has been issued a successful authentication sequence:
Expand Down Expand Up @@ -133,7 +133,7 @@ SETTINGS += -DDESFIRE_MIN_OUTGOING_LOGSIZE=1

#Option to save space with the "Application/Crypto1.c" code by storing large tables
#in PROGMEM. Note that this will slow down the read times when accessing these tables:
#SETTINGS += -DDESFIRE_CRYPTO1_SAVE_SPACE
SETTINGS += -DDESFIRE_CRYPTO1_SAVE_SPACE

DESFIRE_MAINSRC = Application/DESFire

Expand Down

0 comments on commit 7176259

Please sign in to comment.