mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
fix warning about cast realignment, WIP
This commit is contained in:
parent
82ad1b683a
commit
c94eae0046
8 changed files with 30 additions and 24 deletions
|
@ -58,9 +58,9 @@ INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
|
||||||
#CFLAGS ?= -Wall -Werror -O3
|
#CFLAGS ?= -Wall -Werror -O3
|
||||||
ifeq ($(platform),Darwin)
|
ifeq ($(platform),Darwin)
|
||||||
# readline has strict-prototype issues
|
# readline has strict-prototype issues
|
||||||
CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations
|
CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wno-error=cast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations
|
||||||
else
|
else
|
||||||
CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wstrict-prototypes -Wnested-externs -Wmissing-declarations
|
CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wno-error=cast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wstrict-prototypes -Wnested-externs -Wmissing-declarations
|
||||||
endif
|
endif
|
||||||
# -Wshadow
|
# -Wshadow
|
||||||
# -Wbad-function-cast -Wextra -Wswitch-enum -Wold-style-definition
|
# -Wbad-function-cast -Wextra -Wswitch-enum -Wold-style-definition
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MYSRCPATHS =
|
MYSRCPATHS =
|
||||||
MYINCLUDES = -I../../../common -I../../../include -I../../src
|
MYINCLUDES = -I../../../common -I../../../include -I../../src
|
||||||
MYCFLAGS =
|
MYCFLAGS = -Wno-cast-align
|
||||||
MYDEFS =
|
MYDEFS =
|
||||||
MYSRCS = \
|
MYSRCS = \
|
||||||
argtable3.c \
|
argtable3.c \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MYSRCPATHS =
|
MYSRCPATHS =
|
||||||
MYINCLUDES = -I.
|
MYINCLUDES = -I.
|
||||||
MYCFLAGS = -Wno-unused-function
|
MYCFLAGS = -Wno-unused-function -Wno-cast-align
|
||||||
MYDEFS = -DHAVE_STDINT_H
|
MYDEFS = -DHAVE_STDINT_H
|
||||||
MYSRCS = \
|
MYSRCS = \
|
||||||
dump.c \
|
dump.c \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
MYSRCPATHS =
|
MYSRCPATHS =
|
||||||
MYINCLUDES = -I.
|
MYINCLUDES = -I.
|
||||||
# Lua lib requires GNU extensions (implicit declarations of functions): -std=gnu99 or -std=gnu11
|
# Lua lib requires GNU extensions (implicit declarations of functions): -std=gnu99 or -std=gnu11
|
||||||
MYCFLAGS =
|
MYCFLAGS = -Wno-cast-align
|
||||||
MYDEFS = -DLUA_COMPAT_ALL $(SYSCFLAGS)
|
MYDEFS = -DLUA_COMPAT_ALL $(SYSCFLAGS)
|
||||||
MYSRCS = lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c \
|
MYSRCS = lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c \
|
||||||
lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c \
|
lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c \
|
||||||
|
|
|
@ -45,11 +45,14 @@ uint32_t intersection(uint64_t *listA, uint64_t *listB) {
|
||||||
// Darkside attack (hf mf mifare)
|
// Darkside attack (hf mf mifare)
|
||||||
// if successful it will return a list of keys, not just one.
|
// if successful it will return a list of keys, not just one.
|
||||||
uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t par_info, uint64_t ks_info, uint64_t **keys) {
|
uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t par_info, uint64_t ks_info, uint64_t **keys) {
|
||||||
struct Crypto1State *states;
|
union {
|
||||||
|
struct Crypto1State *states;
|
||||||
|
uint64_t *keylist;
|
||||||
|
} unionstate;
|
||||||
|
|
||||||
uint32_t i, pos;
|
uint32_t i, pos;
|
||||||
uint8_t ks3x[8], par[8][8];
|
uint8_t ks3x[8], par[8][8];
|
||||||
uint64_t key_recovered;
|
uint64_t key_recovered;
|
||||||
uint64_t *keylist;
|
|
||||||
|
|
||||||
// Reset the last three significant bits of the reader nonce
|
// Reset the last three significant bits of the reader nonce
|
||||||
nr &= 0xFFFFFF1F;
|
nr &= 0xFFFFFF1F;
|
||||||
|
@ -68,23 +71,21 @@ uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t
|
||||||
par[7 - pos][7] = (bt >> 7) & 1;
|
par[7 - pos][7] = (bt >> 7) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
states = lfsr_common_prefix(nr, ar, ks3x, par, (par_info == 0));
|
unionstate.states = lfsr_common_prefix(nr, ar, ks3x, par, (par_info == 0));
|
||||||
|
|
||||||
if (!states) {
|
if (!unionstate.states) {
|
||||||
*keys = NULL;
|
*keys = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
keylist = (uint64_t *)states;
|
for (i = 0; unionstate.keylist[i]; i++) {
|
||||||
|
lfsr_rollback_word(unionstate.states + i, uid ^ nt, 0);
|
||||||
for (i = 0; keylist[i]; i++) {
|
crypto1_get_lfsr(unionstate.states + i, &key_recovered);
|
||||||
lfsr_rollback_word(states + i, uid ^ nt, 0);
|
unionstate.keylist[i] = key_recovered;
|
||||||
crypto1_get_lfsr(states + i, &key_recovered);
|
|
||||||
keylist[i] = key_recovered;
|
|
||||||
}
|
}
|
||||||
keylist[i] = -1;
|
unionstate.keylist[i] = -1;
|
||||||
|
|
||||||
*keys = keylist;
|
*keys = unionstate.keylist;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
StateList_t *statelist = arg;
|
StateList_t *statelist = arg;
|
||||||
statelist->head.slhead = lfsr_recovery32(statelist->ks1, statelist->nt_enc ^ statelist->uid);
|
statelist->head.slhead = lfsr_recovery32(statelist->ks1, statelist->nt_enc ^ statelist->uid);
|
||||||
|
|
||||||
for (p1 = statelist->head.slhead; * (uint64_t *)p1 != 0; p1++) {};
|
for (p1 = statelist->head.slhead; p1->odd | p1->even; p1++) {};
|
||||||
|
|
||||||
statelist->len = p1 - statelist->head.slhead;
|
statelist->len = p1 - statelist->head.slhead;
|
||||||
statelist->tail.sltail = --p1;
|
statelist->tail.sltail = --p1;
|
||||||
|
@ -492,8 +492,10 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*(uint64_t *)p3 = -1;
|
p3->odd = -1;
|
||||||
*(uint64_t *)p4 = -1;
|
p3->even = -1;
|
||||||
|
p4->odd = -1;
|
||||||
|
p4->even = -1;
|
||||||
statelists[0].len = p3 - statelists[0].head.slhead;
|
statelists[0].len = p3 - statelists[0].head.slhead;
|
||||||
statelists[1].len = p4 - statelists[1].head.slhead;
|
statelists[1].len = p4 - statelists[1].head.slhead;
|
||||||
statelists[0].tail.sltail = --p3;
|
statelists[0].tail.sltail = --p3;
|
||||||
|
@ -637,7 +639,8 @@ int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*(uint64_t *)p3 = -1;
|
p3->odd = -1;
|
||||||
|
p3->even = -1;
|
||||||
statelists[0].len = p3 - statelists[0].head.slhead;
|
statelists[0].len = p3 - statelists[0].head.slhead;
|
||||||
statelists[0].tail.sltail = --p3;
|
statelists[0].tail.sltail = --p3;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,10 @@ void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
crc32_byte(&desfire_crc, data[i]);
|
crc32_byte(&desfire_crc, data[i]);
|
||||||
}
|
}
|
||||||
|
uint32_t crctmp = htole32(desfire_crc);
|
||||||
*((uint32_t *)(crc)) = htole32(desfire_crc);
|
for (size_t i=0; i < sizeof(uint32_t); i++) {
|
||||||
|
crc[i] = ((uint8_t *) &crctmp)[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void crc32_append(uint8_t *data, const size_t len) {
|
void crc32_append(uint8_t *data, const size_t len) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MYSRCPATHS =
|
MYSRCPATHS =
|
||||||
MYINCLUDES = -I. -I..
|
MYINCLUDES = -I. -I..
|
||||||
MYCFLAGS =
|
MYCFLAGS = -Wno-cast-align
|
||||||
MYDEFS =
|
MYDEFS =
|
||||||
MYSRCS = \
|
MYSRCS = \
|
||||||
aes.c \
|
aes.c \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue