mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-06-04 13:01:50 +00:00
Fix formatting and run make style
This commit is contained in:
+12
-12
@@ -36,7 +36,7 @@
|
||||
#include "crypto/asn1utils.h" // ASN1 decode / print
|
||||
#include "cmdflashmemspiffs.h" // SPIFFS flash memory download
|
||||
#include "mbedtls/bignum.h" // big num
|
||||
#include "mbedtls/entropy.h" //
|
||||
#include "mbedtls/entropy.h" //
|
||||
#include "mbedtls/ctr_drbg.h" // random generator
|
||||
|
||||
uint8_t g_DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
@@ -2429,7 +2429,7 @@ static int CmdZerocrossings(const char *Cmd) {
|
||||
}
|
||||
|
||||
static bool data_verify_hex(uint8_t *d, size_t n) {
|
||||
if (d == NULL)
|
||||
if (d == NULL)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
@@ -2517,7 +2517,7 @@ static int Cmdhex2bin(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (data_verify_hex((uint8_t*)data, dlen) == false) {
|
||||
if (data_verify_hex((uint8_t *)data, dlen) == false) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -3230,7 +3230,7 @@ static int CmdNumCon(const char *Cmd) {
|
||||
|
||||
// hex
|
||||
if (hlen > 0) {
|
||||
if (data_verify_hex((uint8_t*)hex, hlen) == false) {
|
||||
if (data_verify_hex((uint8_t *)hex, hlen) == false) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&N, 16, hex));
|
||||
@@ -3257,22 +3257,22 @@ static int CmdNumCon(const char *Cmd) {
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(&N, &N, &base));
|
||||
}
|
||||
|
||||
// printing
|
||||
// printing
|
||||
typedef struct {
|
||||
const char* desc;
|
||||
const char *desc;
|
||||
uint8_t radix;
|
||||
} radix_t;
|
||||
|
||||
radix_t radix[] = {
|
||||
{"dec..... ", 10},
|
||||
{"hex..... 0x", 16},
|
||||
{"bin..... 0b", 2}
|
||||
{"dec..... ", 10},
|
||||
{"hex..... 0x", 16},
|
||||
{"bin..... 0b", 2}
|
||||
};
|
||||
|
||||
char s[600] = {0};
|
||||
size_t slen = 0;
|
||||
|
||||
for (uint8_t i=0; i < ARRAYLEN(radix); i++) {
|
||||
for (uint8_t i = 0; i < ARRAYLEN(radix); i++) {
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_write_string(&N, radix[i].radix, s, sizeof(s), &slen));
|
||||
if (slen > 0) {
|
||||
PrintAndLogEx(INFO, "%s%s", radix[i].desc, s);
|
||||
@@ -3285,9 +3285,9 @@ static int CmdNumCon(const char *Cmd) {
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
mbedtls_entropy_init(&entropy);
|
||||
|
||||
MBEDTLS_MPI_CHK(mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0 ));
|
||||
MBEDTLS_MPI_CHK(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0));
|
||||
|
||||
res = mbedtls_mpi_is_prime_ext( &N, 50, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||
res = mbedtls_mpi_is_prime_ext(&N, 50, mbedtls_ctr_drbg_random, &ctr_drbg);
|
||||
if (res == 0) {
|
||||
PrintAndLogEx(INFO, "prime... " _YELLOW_("yes"));
|
||||
}
|
||||
|
||||
+8
-25
@@ -404,7 +404,7 @@ static void mf_analyse_acl(uint16_t n, uint8_t *d) {
|
||||
Sector trailer sanity checks.
|
||||
Warn if ACL is strict read-only, or invalid ACL.
|
||||
*/
|
||||
static int mf_analyse_st_block(uint8_t blockno, uint8_t *block, bool force){
|
||||
static int mf_analyse_st_block(uint8_t blockno, uint8_t *block, bool force) {
|
||||
|
||||
if (mfIsSectorTrailer(blockno) == false) {
|
||||
return PM3_SUCCESS;
|
||||
@@ -6665,10 +6665,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
||||
int res = mfkey32_moebius(&data, &key64);
|
||||
|
||||
if (res) {
|
||||
PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ "
|
||||
_GREEN_("%012"
|
||||
PRIX64) " ]", sprint_hex_inrow(trace_data, 4), data.sector, (data.keytype == 0x60) ? 'A'
|
||||
: 'B', key64);
|
||||
PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ "_GREEN_("%012" PRIX64) " ]", sprint_hex_inrow(trace_data, 4), data.sector, (data.keytype == 0x60) ? 'A' : 'B', key64);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -6694,16 +6691,12 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
||||
res = ExchangeAPDU14a(aCHANGE, sizeof(aCHANGE), activate_field, keep_field_on, response, sizeof(response),
|
||||
&resplen);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Super card UID change [ "
|
||||
_RED_("fail")
|
||||
" ]");
|
||||
PrintAndLogEx(FAILED, "Super card UID change [ " _RED_("fail") " ]");
|
||||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Super card UID change ( "
|
||||
_GREEN_("ok")
|
||||
" )");
|
||||
PrintAndLogEx(SUCCESS, "Super card UID change ( " _GREEN_("ok") " )");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -6717,15 +6710,11 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
||||
res = ExchangeAPDU14a(aRESET, sizeof(aRESET), activate_field, keep_field_on, response, sizeof(response),
|
||||
&resplen);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Super card reset [ "
|
||||
_RED_("fail")
|
||||
" ]");
|
||||
PrintAndLogEx(FAILED, "Super card reset [ " _RED_("fail") " ]");
|
||||
DropField();
|
||||
return res;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Super card reset ( "
|
||||
_GREEN_("ok")
|
||||
" )");
|
||||
PrintAndLogEx(SUCCESS, "Super card reset ( " _GREEN_("ok") " )");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -6813,13 +6802,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) {
|
||||
res = mfkey32_moebius(&data, &key64);
|
||||
|
||||
if (res) {
|
||||
PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ "
|
||||
_GREEN_("%12"
|
||||
PRIX64) " ]"
|
||||
, sprint_hex_inrow(outA, 4)
|
||||
, data.sector
|
||||
, (data.keytype == 0x60) ? 'A' : 'B'
|
||||
, key64);
|
||||
PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ " _GREEN_("%12" PRIX64) " ]", sprint_hex_inrow(outA, 4), data.sector, (data.keytype == 0x60) ? 'A' : 'B', key64);
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, "failed to recover any key");
|
||||
}
|
||||
@@ -8093,7 +8076,7 @@ static command_t CommandTable[] = {
|
||||
{"gsave", CmdHF14AGen4Save, IfPm3Iso14443a, "Save dump from card into file or emulator"},
|
||||
{"gsetblk", CmdHF14AGen4SetBlk, IfPm3Iso14443a, "Write block to card"},
|
||||
{"gview", CmdHF14AGen4View, IfPm3Iso14443a, "View card"},
|
||||
{"-----------", CmdHelp, IfPm3Iso14443a, "-------------------- " _CYAN_("magic gen4 GDM") " --------------------------"},
|
||||
{"-----------", CmdHelp, IfPm3Iso14443a, "-------------------- " _CYAN_("magic gen4 GDM") " --------------------------"},
|
||||
{"gdmconfig", CmdHF14AGen4_GDM_ConfigBlk, IfPm3Iso14443a, "Read config block from card"},
|
||||
{"gdmsetblk", CmdHF14AGen4_GDM_SetBlk, IfPm3Iso14443a, "Write block to card"},
|
||||
{"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("ndef") " -----------------------"},
|
||||
|
||||
@@ -271,4 +271,4 @@ static int CmdHelp(const char *Cmd) {
|
||||
int CmdHFTESLA(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown, bool full_help)
|
||||
|
||||
char currentparent[MAX_PM3_INPUT_ARGS_LENGTH] = {0};
|
||||
snprintf(currentparent, sizeof currentparent, "%s%s ", parent, cmds[i].Name);
|
||||
|
||||
|
||||
char *old_parent = parent;
|
||||
parent = currentparent;
|
||||
// This is what causes the recursion, since commands Parse-implementation
|
||||
|
||||
@@ -141,7 +141,7 @@ static void asn1_tag_dump_str_time(const struct tlv *tlv, const struct asn1_tag
|
||||
break;
|
||||
|
||||
// month
|
||||
PrintAndLogEx(NORMAL, "%.*s-" NOLF, 2, tlv->value + startidx );
|
||||
PrintAndLogEx(NORMAL, "%.*s-" NOLF, 2, tlv->value + startidx);
|
||||
if (len < startidx + 4)
|
||||
break;
|
||||
|
||||
@@ -233,16 +233,16 @@ static void asn1_tag_dump_hex(const struct tlv *tlv, const struct asn1_tag *tag,
|
||||
}
|
||||
|
||||
static void asn1_tag_dump_octet_string(const struct tlv *tlv, const struct asn1_tag *tag, int level) {
|
||||
/*
|
||||
for (size_t i = 0; i < tlv->len; i++) {
|
||||
if (!isspace(tlv->value[i]) && !isprint(tlv->value[i])) {
|
||||
*needdump = true;
|
||||
break;
|
||||
/*
|
||||
for (size_t i = 0; i < tlv->len; i++) {
|
||||
if (!isspace(tlv->value[i]) && !isprint(tlv->value[i])) {
|
||||
*needdump = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
PrintAndLogEx(NORMAL, " " NOLF);
|
||||
asn1_tag_dump_string(tlv, tag, level);
|
||||
*/
|
||||
PrintAndLogEx(NORMAL, " " NOLF);
|
||||
asn1_tag_dump_string(tlv, tag, level);
|
||||
}
|
||||
|
||||
static void asn1_tag_dump_boolean(const struct tlv *tlv, const struct asn1_tag *tag, int level) {
|
||||
@@ -262,7 +262,7 @@ static void asn1_tag_dump_integer(const struct tlv *tlv, const struct asn1_tag *
|
||||
return;
|
||||
}
|
||||
|
||||
hex_to_buffer((uint8_t*)hex, tlv->value, tlv->len, tlv->len, 0, 0, false);
|
||||
hex_to_buffer((uint8_t *)hex, tlv->value, tlv->len, tlv->len, 0, 0, false);
|
||||
|
||||
// results for MPI actions
|
||||
bool ret = false;
|
||||
@@ -277,7 +277,7 @@ static void asn1_tag_dump_integer(const struct tlv *tlv, const struct asn1_tag *
|
||||
size_t slen = 0;
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_write_string(&N, 10, s, sizeof(s), &slen));
|
||||
if (slen > 0) {
|
||||
PrintAndLogEx(NORMAL, "%*s value: %s", (level ), "", s);
|
||||
PrintAndLogEx(NORMAL, "%*s value: %s", (level), "", s);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
@@ -227,7 +227,7 @@ struct tlvdb *tlvdb_parse_multi(const unsigned char *buf, size_t len) {
|
||||
|
||||
while (left != 0) {
|
||||
struct tlvdb *db = calloc(1, sizeof(*db));
|
||||
if (db == NULL ) {
|
||||
if (db == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
@@ -1512,16 +1512,16 @@ int vigik_verify(mfc_vigik_t *d) {
|
||||
PrintAndLogEx(INFO, "Raw signature");
|
||||
print_hex_noascii_break(d->rsa_signature, sizeof(d->rsa_signature), MFBLOCK_SIZE * 2);
|
||||
}
|
||||
|
||||
/*
|
||||
int dl = 0;
|
||||
|
||||
param_gethex_to_eol("1C07D46DA3849326D24B3468BD76673F4F3C41827DC413E81E4F3C7804FAC727213059B21D047510D6432448643A92EBFC67FBEDDAB468D13D948B172F5EBC79A0E3FEFDFAF4E81FC7108E070F1E3CD0", 0, signature, PUBLIC_VIGIK_KEYLEN, &dl);
|
||||
|
||||
param_gethex_to_eol("1AB86FE0C17FFFFE4379D5E15A4B2FAFFEFCFA0F1F3F7FA03E7DDDF1E3C78FFFB1F0E23F7FFF51584771C5C18307FEA36CA74E60AA6B0409ACA66A9EC155F4E9112345708A2B8457E722608EE1157408", 0, signature, PUBLIC_VIGIK_KEYLEN, &dl);
|
||||
signature_len = dl;
|
||||
*/
|
||||
|
||||
/*
|
||||
int dl = 0;
|
||||
|
||||
param_gethex_to_eol("1C07D46DA3849326D24B3468BD76673F4F3C41827DC413E81E4F3C7804FAC727213059B21D047510D6432448643A92EBFC67FBEDDAB468D13D948B172F5EBC79A0E3FEFDFAF4E81FC7108E070F1E3CD0", 0, signature, PUBLIC_VIGIK_KEYLEN, &dl);
|
||||
|
||||
param_gethex_to_eol("1AB86FE0C17FFFFE4379D5E15A4B2FAFFEFCFA0F1F3F7FA03E7DDDF1E3C78FFFB1F0E23F7FFF51584771C5C18307FEA36CA74E60AA6B0409ACA66A9EC155F4E9112345708A2B8457E722608EE1157408", 0, signature, PUBLIC_VIGIK_KEYLEN, &dl);
|
||||
signature_len = dl;
|
||||
*/
|
||||
|
||||
uint8_t rev_sig[128];
|
||||
reverse_array_copy(d->rsa_signature, sizeof(d->rsa_signature), rev_sig);
|
||||
|
||||
|
||||
+757
-753
File diff suppressed because it is too large
Load Diff
@@ -126,7 +126,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||
struct addrinfo info;
|
||||
int iResult;
|
||||
|
||||
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (iResult != 0) {
|
||||
PrintAndLogEx(ERR, "error: WSAStartup failed with error: %d", iResult);
|
||||
free(sp);
|
||||
@@ -231,7 +231,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||
|
||||
void uart_close(const serial_port sp) {
|
||||
serial_port_windows_t *spw = (serial_port_windows_t *)sp;
|
||||
if (spw->hSocket != INVALID_SOCKET){
|
||||
if (spw->hSocket != INVALID_SOCKET) {
|
||||
shutdown(spw->hSocket, SD_BOTH);
|
||||
closesocket(spw->hSocket);
|
||||
WSACleanup();
|
||||
@@ -294,8 +294,7 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
|
||||
}
|
||||
|
||||
return PM3_ENOTTY;
|
||||
}
|
||||
else { // TCP
|
||||
} else { // TCP
|
||||
uint32_t byteCount; // FIONREAD returns size on 32b
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
@@ -332,12 +331,12 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
|
||||
|
||||
// Retrieve the count of the incoming bytes
|
||||
res = ioctlsocket(spw->hSocket, FIONREAD, (u_long *)&byteCount);
|
||||
// PrintAndLogEx(ERR, "UART:: RX ioctl res %d byteCount %u", res, byteCount);
|
||||
// PrintAndLogEx(ERR, "UART:: RX ioctl res %d byteCount %u", res, byteCount);
|
||||
if (res == SOCKET_ERROR) return PM3_ENOTTY;
|
||||
|
||||
// Cap the number of bytes, so we don't overrun the buffer
|
||||
if (pszMaxRxLen - (*pszRxLen) < byteCount) {
|
||||
// PrintAndLogEx(ERR, "UART:: RX prevent overrun (have %u, need %u)", pszMaxRxLen - (*pszRxLen), byteCount);
|
||||
// PrintAndLogEx(ERR, "UART:: RX prevent overrun (have %u, need %u)", pszMaxRxLen - (*pszRxLen), byteCount);
|
||||
byteCount = pszMaxRxLen - (*pszRxLen);
|
||||
}
|
||||
|
||||
@@ -374,8 +373,7 @@ int uart_send(const serial_port sp, const uint8_t *p_tx, const uint32_t len) {
|
||||
return PM3_EIO;
|
||||
}
|
||||
return PM3_ENOTTY;
|
||||
}
|
||||
else { // TCP
|
||||
} else { // TCP
|
||||
uint32_t pos = 0;
|
||||
fd_set wfds;
|
||||
struct timeval tv;
|
||||
|
||||
Reference in New Issue
Block a user