mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-28 18:14:39 +08:00
arg names
This commit is contained in:
parent
a52a0bf537
commit
ebdfba033d
6 changed files with 39 additions and 36 deletions
|
@ -141,7 +141,7 @@ void EPA_PACE_Collect_Nonce(UsbCommand *c);
|
|||
void EPA_PACE_Replay(UsbCommand *c);
|
||||
|
||||
// mifarecmd.h
|
||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
|
||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareUC_Auth(uint8_t arg0, uint8_t *datain);
|
||||
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
|
|
|
@ -100,7 +100,7 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
LEDsoff();
|
||||
}
|
||||
|
||||
void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes) {
|
||||
void MifareUC_Auth(uint8_t arg0, uint8_t *datain) {
|
||||
|
||||
bool turnOffField = (arg0 == 1);
|
||||
|
||||
|
@ -119,7 +119,7 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes) {
|
|||
return;
|
||||
};
|
||||
|
||||
if (!mifare_ultra_auth(keybytes)) {
|
||||
if (!mifare_ultra_auth(datain)) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Authentication failed");
|
||||
OnError(1);
|
||||
return;
|
||||
|
@ -851,12 +851,13 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
|||
// MIFARE nested authentication.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *datain) {
|
||||
void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain) {
|
||||
// params
|
||||
uint8_t blockNo = arg0 & 0xff;
|
||||
uint8_t keyType = (arg0 >> 8) & 0xff;
|
||||
uint8_t targetBlockNo = arg1 & 0xff;
|
||||
uint8_t targetKeyType = (arg1 >> 8) & 0xff;
|
||||
// calibrate = arg2
|
||||
uint64_t ui64Key = 0;
|
||||
|
||||
ui64Key = bytes_to_num(datain, 6);
|
||||
|
@ -888,14 +889,14 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
|
|||
BigBuf_free();
|
||||
BigBuf_Clear_ext(false);
|
||||
|
||||
if (calibrate) clear_trace();
|
||||
if (arg2) clear_trace();
|
||||
set_tracing(true);
|
||||
|
||||
// statistics on nonce distance
|
||||
int16_t isOK = 0;
|
||||
#define NESTED_MAX_TRIES 12
|
||||
uint16_t unsuccessfull_tries = 0;
|
||||
if (calibrate) { // for first call only. Otherwise reuse previous calibration
|
||||
if (arg2) { // calibrate: for first call only. Otherwise reuse previous calibration
|
||||
LED_B_ON();
|
||||
WDT_HIT();
|
||||
|
||||
|
|
|
@ -167,8 +167,10 @@ void MifareDesfireGetInformation() {
|
|||
OnSuccess();
|
||||
}
|
||||
|
||||
void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain) {
|
||||
|
||||
void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
|
||||
// mode = arg0
|
||||
// algo = arg1
|
||||
// keyno = arg2
|
||||
int len = 0;
|
||||
//uint8_t PICC_MASTER_KEY8[8] = { 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47};
|
||||
uint8_t PICC_MASTER_KEY16[16] = { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f };
|
||||
|
@ -196,24 +198,24 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
LED_C_OFF();
|
||||
|
||||
// 3 different way to authenticate AUTH (CRC16) , AUTH_ISO (CRC32) , AUTH_AES (CRC32)
|
||||
// 4 different crypto algo DES, 3DES, 3K3DES, AES
|
||||
// 4 different crypto arg1 DES, 3DES, 3K3DES, AES
|
||||
// 3 different communication modes, PLAIN,MAC,CRYPTO
|
||||
|
||||
// des, key 0,
|
||||
switch (mode) {
|
||||
switch (arg0) {
|
||||
case 1: {
|
||||
uint8_t keybytes[16];
|
||||
uint8_t RndA[8] = {0x00};
|
||||
uint8_t RndB[8] = {0x00};
|
||||
|
||||
if (algo == 2) {
|
||||
if (arg1 == 2) {
|
||||
if (datain[1] == 0xff) {
|
||||
memcpy(keybytes, PICC_MASTER_KEY16, 16);
|
||||
} else {
|
||||
memcpy(keybytes, datain + 1, datalen);
|
||||
}
|
||||
} else {
|
||||
if (algo == 1) {
|
||||
if (arg1 == 1) {
|
||||
if (datain[1] == 0xff) {
|
||||
memcpy(keybytes, null_key_data8, 8);
|
||||
} else {
|
||||
|
@ -225,13 +227,13 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
struct desfire_key defaultkey = {0};
|
||||
desfirekey_t key = &defaultkey;
|
||||
|
||||
if (algo == 2)
|
||||
if (arg1 == 2)
|
||||
Desfire_3des_key_new_with_version(keybytes, key);
|
||||
else if (algo == 1)
|
||||
else if (arg1 == 1)
|
||||
Desfire_des_key_new(keybytes, key);
|
||||
|
||||
cmd[0] = AUTHENTICATE;
|
||||
cmd[1] = keyno; //keynumber
|
||||
cmd[1] = arg2; //keynumber
|
||||
len = DesfireAPDU(cmd, 2, resp);
|
||||
if (!len) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) {
|
||||
|
@ -249,9 +251,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
}
|
||||
|
||||
memcpy(encRndB, resp + 3, 8);
|
||||
if (algo == 2)
|
||||
if (arg1 == 2)
|
||||
tdes_dec(&decRndB, &encRndB, key->data);
|
||||
else if (algo == 1)
|
||||
else if (arg1 == 1)
|
||||
des_dec(&decRndB, &encRndB, key->data);
|
||||
|
||||
memcpy(RndB, decRndB, 8);
|
||||
|
@ -262,9 +264,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
memcpy(RndA, decRndA, 8);
|
||||
uint8_t encRndA[8] = {0x00};
|
||||
|
||||
if (algo == 2)
|
||||
if (arg1 == 2)
|
||||
tdes_dec(&encRndA, &decRndA, key->data);
|
||||
else if (algo == 1)
|
||||
else if (arg1 == 1)
|
||||
des_dec(&encRndA, &decRndA, key->data);
|
||||
|
||||
memcpy(both, encRndA, 8);
|
||||
|
@ -274,9 +276,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
|
||||
}
|
||||
|
||||
if (algo == 2)
|
||||
if (arg1 == 2)
|
||||
tdes_dec(&encRndB, &decRndB, key->data);
|
||||
else if (algo == 1)
|
||||
else if (arg1 == 1)
|
||||
des_dec(&encRndB, &decRndB, key->data);
|
||||
|
||||
memcpy(both + 8, encRndB, 8);
|
||||
|
@ -302,9 +304,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
|
||||
memcpy(encRndA, resp + 3, 8);
|
||||
|
||||
if (algo == 2)
|
||||
if (arg1 == 2)
|
||||
tdes_dec(&encRndA, &encRndA, key->data);
|
||||
else if (algo == 1)
|
||||
else if (arg1 == 1)
|
||||
des_dec(&encRndA, &encRndA, key->data);
|
||||
|
||||
rol(decRndA, 8);
|
||||
|
@ -320,9 +322,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
/*
|
||||
|
||||
// Current key is a 3DES key, change it to a DES key
|
||||
if (algo == 2) {
|
||||
if (arg1 == 2) {
|
||||
cmd[0] = CHANGE_KEY;
|
||||
cmd[1] = keyno;
|
||||
cmd[1] = arg2;
|
||||
|
||||
uint8_t newKey[16] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77};
|
||||
|
||||
|
@ -362,9 +364,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
|
||||
} else {
|
||||
// Current key is a DES key, change it to a 3DES key
|
||||
if (algo == 1) {
|
||||
if (arg1 == 1) {
|
||||
cmd[0] = CHANGE_KEY;
|
||||
cmd[1] = keyno;
|
||||
cmd[1] = arg2;
|
||||
|
||||
uint8_t newKey[16] = {0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f};
|
||||
|
||||
|
@ -406,9 +408,9 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
*/
|
||||
|
||||
OnSuccess();
|
||||
if (algo == 2)
|
||||
if (arg1 == 2)
|
||||
cmd_send(CMD_ACK, 1, 0, 0, skey->data, 16);
|
||||
else if (algo == 1)
|
||||
else if (arg1 == 1)
|
||||
cmd_send(CMD_ACK, 1, 0, 0, skey->data, 8);
|
||||
} else {
|
||||
DbpString("Authentication failed.");
|
||||
|
@ -418,7 +420,7 @@ void MifareDES_Auth1(uint8_t mode, uint8_t algo, uint8_t keyno, uint8_t *datain
|
|||
}
|
||||
break;
|
||||
case 2:
|
||||
//SendDesfireCommand(AUTHENTICATE_ISO, &keyno, resp);
|
||||
//SendDesfireCommand(AUTHENTICATE_ISO, &arg2, resp);
|
||||
break;
|
||||
case 3: {
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ int mifare_classic_halt_ex(struct Crypto1State *pcs);
|
|||
int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
|
||||
// Ultralight/NTAG...
|
||||
int mifare_ul_ev1_auth(uint8_t *key, uint8_t *pack);
|
||||
int mifare_ultra_auth(uint8_t *key);
|
||||
int mifare_ul_ev1_auth(uint8_t *keybytes, uint8_t *pack);
|
||||
int mifare_ultra_auth(uint8_t *keybytes);
|
||||
int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData);
|
||||
//int mifare_ultra_writeblock_compat(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_writeblock(uint8_t blockNo, uint8_t *blockData);
|
||||
|
@ -97,7 +97,7 @@ int mifare_desfire_des_auth1(uint32_t uid, uint8_t *blockData);
|
|||
int mifare_desfire_des_auth2(uint32_t uid, uint8_t *key, uint8_t *blockData);
|
||||
|
||||
// crypto functions
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *receivedCmd, int len);
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len);
|
||||
void mf_crypto1_decryptEx(struct Crypto1State *pcs, uint8_t *data_in, int len, uint8_t *data_out);
|
||||
void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, uint16_t len, uint8_t *par);
|
||||
uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data);
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "string.h"
|
||||
|
||||
size_t DemodPCF7931(uint8_t **outBlocks);
|
||||
bool IsBlock0PCF7931(uint8_t *Block);
|
||||
bool IsBlock1PCF7931(uint8_t *Block);
|
||||
bool IsBlock0PCF7931(uint8_t *block);
|
||||
bool IsBlock1PCF7931(uint8_t *block);
|
||||
void ReadPCF7931();
|
||||
void SendCmdPCF7931(uint32_t *tab);
|
||||
bool AddBytePCF7931(uint8_t byte, uint32_t *tab, int32_t l, int32_t p);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <stddef.h>
|
||||
#include "string.h"
|
||||
|
||||
int kvsprintf(const char *format, void *arg, int radix, va_list ap) __attribute__((format(printf, 1, 0)));
|
||||
int kvsprintf(const char *fmt, void *arg, int radix, va_list ap) __attribute__((format(printf, 1, 0)));
|
||||
int vsprintf(char *dest, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0)));
|
||||
int sprintf(char *dest, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
|
||||
|
|
Loading…
Reference in a new issue