mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-20 21:33:19 -07:00
Deduplicate mfkey32 and mfkey64
- rename client/nonce2key.[ch] to mfkey.[ch] - leave only main() wrapper in tools/mfkey - add mfkey32 and mfkey64 to .gitignore
This commit is contained in:
parent
bd2797de15
commit
4cb4b588c2
11 changed files with 193 additions and 170 deletions
|
@ -58,7 +58,7 @@ CORESRCS = uart.c \
|
|||
|
||||
CMDSRCS = crapto1/crapto1.c\
|
||||
crapto1/crypto1.c\
|
||||
nonce2key.c\
|
||||
mfkey.c\
|
||||
loclass/cipher.c \
|
||||
loclass/cipherutils.c \
|
||||
loclass/des.c \
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "ui.h"
|
||||
#include "mifarehost.h"
|
||||
#include "mifare.h"
|
||||
#include "nonce2key.h"
|
||||
#include "mfkey.h"
|
||||
|
||||
#define NESTED_SECTOR_RETRY 10 // how often we try mfested() until we give up
|
||||
|
||||
|
|
|
@ -10,15 +10,11 @@
|
|||
// MIFARE Darkside hack
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "nonce2key.h"
|
||||
#include "mfkey.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "mifarehost.h"
|
||||
#include "util.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
|
||||
|
||||
// recover key from 2 different reader responses on same tag challenge
|
||||
bool mfkey32(nonces_t data, uint64_t *outputkey) {
|
||||
struct Crypto1State *s,*t;
|
||||
|
@ -27,8 +23,6 @@ bool mfkey32(nonces_t data, uint64_t *outputkey) {
|
|||
bool isSuccess = false;
|
||||
uint8_t counter = 0;
|
||||
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
s = lfsr_recovery32(data.ar ^ prng_successor(data.nonce, 64), 0);
|
||||
|
||||
for(t = s; t->odd | t->even; ++t) {
|
||||
|
@ -46,8 +40,6 @@ bool mfkey32(nonces_t data, uint64_t *outputkey) {
|
|||
}
|
||||
}
|
||||
isSuccess = (counter == 1);
|
||||
t1 = msclock() - t1;
|
||||
//if ( t1 > 0 ) PrintAndLog("Time in mfkey32: %.1f seconds \nFound %d possible keys", (float)t1/1000.0, counter);
|
||||
*outputkey = ( isSuccess ) ? outkey : 0;
|
||||
crypto1_destroy(s);
|
||||
/* //un-comment to save all keys to a stats.txt file
|
||||
|
@ -70,9 +62,6 @@ bool mfkey32_moebius(nonces_t data, uint64_t *outputkey) {
|
|||
bool isSuccess = false;
|
||||
int counter = 0;
|
||||
|
||||
//PrintAndLog("Enter mfkey32_moebius");
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
s = lfsr_recovery32(data.ar ^ prng_successor(data.nonce, 64), 0);
|
||||
|
||||
for(t = s; t->odd | t->even; ++t) {
|
||||
|
@ -92,8 +81,6 @@ bool mfkey32_moebius(nonces_t data, uint64_t *outputkey) {
|
|||
}
|
||||
}
|
||||
isSuccess = (counter == 1);
|
||||
t1 = msclock() - t1;
|
||||
// PrintAndLog("Time in mfkey32_moebius: %.1f seconds \nFound %d possible keys", (float)t1/1000.0, counter);
|
||||
*outputkey = ( isSuccess ) ? outkey : 0;
|
||||
crypto1_destroy(s);
|
||||
/* // un-comment to output all keys to stats.txt
|
||||
|
@ -115,9 +102,6 @@ int mfkey64(nonces_t data, uint64_t *outputkey){
|
|||
uint32_t ks3; // keystream used to encrypt tag response
|
||||
struct Crypto1State *revstate;
|
||||
|
||||
// PrintAndLog("Enter mfkey64");
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
// Extract the keystream from the messages
|
||||
ks2 = data.ar ^ prng_successor(data.nonce, 64);
|
||||
ks3 = data.at ^ prng_successor(data.nonce, 96);
|
||||
|
@ -131,7 +115,7 @@ int mfkey64(nonces_t data, uint64_t *outputkey){
|
|||
crypto1_destroy(revstate);
|
||||
*outputkey = key;
|
||||
|
||||
t1 = msclock() - t1;
|
||||
// PrintAndLog("Time in mfkey64: %.1f seconds \n", (float)t1/1000.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
// MIFARE Darkside hack
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __NONCE2KEY_H
|
||||
#define __NONCE2KEY_H
|
||||
#ifndef MFKEY_H
|
||||
#define MFKEY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -29,8 +29,8 @@ typedef struct {
|
|||
uint32_t nr2;
|
||||
} nonces_t;
|
||||
|
||||
bool mfkey32(nonces_t data, uint64_t *outputkey);
|
||||
bool mfkey32_moebius(nonces_t data, uint64_t *outputkey);
|
||||
int mfkey64(nonces_t data, uint64_t *outputkey);
|
||||
extern bool mfkey32(nonces_t data, uint64_t *outputkey);
|
||||
extern bool mfkey32_moebius(nonces_t data, uint64_t *outputkey);
|
||||
extern int mfkey64(nonces_t data, uint64_t *outputkey);
|
||||
|
||||
#endif
|
|
@ -8,6 +8,8 @@
|
|||
// mifare commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "mifarehost.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -20,7 +22,6 @@
|
|||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "mifarehost.h"
|
||||
|
||||
// mifare tracer flags used in mfTraceDecode()
|
||||
#define TRACE_IDLE 0x00
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
// High frequency ISO14443A commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MIFAREHOST_H
|
||||
#define MIFAREHOST_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "data.h"
|
||||
|
@ -42,3 +45,5 @@ extern int isBlockTrailer(int blockN);
|
|||
extern int loadTraceCard(uint8_t *tuid);
|
||||
extern int saveTraceCard(void);
|
||||
extern int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue