mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-20 13:23:25 -07:00
some refactoring
This commit is contained in:
parent
729dbe0471
commit
fb2e025f9d
4 changed files with 25 additions and 5 deletions
|
@ -2670,7 +2670,7 @@ int CmdHF14AMfAuth4(const char *cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
return MifareAuth4(keyn, key, true, false, true);
|
||||
return MifareAuth4(NULL, keyn, key, true, false, true);
|
||||
}
|
||||
|
||||
static command_t CommandTable[] =
|
||||
|
|
|
@ -351,7 +351,7 @@ int CmdHFMFPAuth(const char *cmd) {
|
|||
CLIParserInit("hf mfp auth",
|
||||
"Executes AES authentication command in ISO14443-4",
|
||||
"Usage:\n\thf mfp auth 4000 000102030405060708090a0b0c0d0e0f -> executes authentication\n"
|
||||
"\thf mfp auth 9003 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> executes authentication\n");
|
||||
"\thf mfp auth 9003 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -v -> executes authentication and shows all the system data\n");
|
||||
|
||||
void* argtable[] = {
|
||||
arg_param_begin,
|
||||
|
@ -377,10 +377,13 @@ int CmdHFMFPAuth(const char *cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
return MifareAuth4(keyn, key, true, false, verbose);
|
||||
return MifareAuth4(NULL, keyn, key, true, false, verbose);
|
||||
}
|
||||
|
||||
int CmdHFMFPRdbl(const char *cmd) {
|
||||
//mf4Session session
|
||||
//int res = MifareAuth4(&session, keyn, key, true, false, verbose);
|
||||
//res = Read();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,15 @@
|
|||
#include "ui.h"
|
||||
#include "polarssl/libpcrypto.h"
|
||||
|
||||
int MifareAuth4(uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSignalON, bool verbose) {
|
||||
int MifareAuth4(mf4Session *session, uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSignalON, bool verbose) {
|
||||
uint8_t data[257] = {0};
|
||||
int datalen = 0;
|
||||
|
||||
uint8_t Rnd1[17] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00};
|
||||
uint8_t Rnd2[17] = {0};
|
||||
|
||||
if (session)
|
||||
session->Authenticated = false;
|
||||
|
||||
uint8_t cmd1[] = {0x70, keyn[1], keyn[0], 0x00};
|
||||
int res = ExchangeRAW14a(cmd1, sizeof(cmd1), activateField, true, data, sizeof(data), &datalen);
|
||||
|
@ -102,6 +104,13 @@ int MifareAuth4(uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSigna
|
|||
if (verbose)
|
||||
PrintAndLog("");
|
||||
|
||||
if (session) {
|
||||
session->Authenticated = true;
|
||||
session->KeyNum = keyn[1] + (keyn[0] << 8);
|
||||
memmove(session->Rnd1, Rnd1, 16);
|
||||
memmove(session->Rnd2, Rnd2, 16);
|
||||
}
|
||||
|
||||
PrintAndLog("Authentication OK");
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -15,7 +15,15 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
extern int MifareAuth4(uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSignalON, bool verbose);
|
||||
typedef struct {
|
||||
bool Authenticated;
|
||||
uint16_t KeyNum;
|
||||
uint8_t Rnd1[16];
|
||||
uint8_t Rnd2[16];
|
||||
|
||||
}mf4Session;
|
||||
|
||||
extern int MifareAuth4(mf4Session *session, uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSignalON, bool verbose);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue