X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/3130ba4b2168f8e8dd66f214d1eecdca65708d53..e1778858ddc53a6a82e8ee24f02e6b673687f69a:/client/nonce2key/crypto1_bs.c diff --git a/client/nonce2key/crypto1_bs.c b/client/nonce2key/crypto1_bs.c index 2bb1194d..62d586df 100644 --- a/client/nonce2key/crypto1_bs.c +++ b/client/nonce2key/crypto1_bs.c @@ -25,9 +25,6 @@ THE SOFTWARE. #include "crypto1_bs.h" #include #define __STDC_FORMAT_MACROS -#define llx PRIx64 -#define lli PRIi64 -#define lu PRIu32 // The following functions use this global or thread-local state // It is sized to fit exactly KEYSTREAM_SIZE more states next to the initial state @@ -80,7 +77,9 @@ inline const bitslice_value_t crypto1_bs_lfsr_rollback(const bitslice_value_t in // note that bytes are sliced and unsliced with reversed endianness inline void crypto1_bs_convert_states(bitslice_t bitsliced_states[], state_t regular_states[]){ size_t bit_idx = 0, slice_idx = 0; - state_t values[MAX_BITSLICES]; + state_t values[MAX_BITSLICES]; + memset(values, 0x0, sizeof(values)); + for(slice_idx = 0; slice_idx < MAX_BITSLICES; slice_idx++){ for(bit_idx = 0; bit_idx < STATE_SIZE; bit_idx++){ bool bit = get_vector_bit(slice_idx, bitsliced_states[bit_idx]); @@ -90,7 +89,8 @@ inline void crypto1_bs_convert_states(bitslice_t bitsliced_states[], state_t reg // swap endianness values[slice_idx].value = rev_state_t(values[slice_idx].value); // roll off unused bits - values[slice_idx].value >>= ((sizeof(state_t)*8)-STATE_SIZE); + //values[slice_idx].value >>= ((sizeof(state_t)*8)-STATE_SIZE); // - 48 + values[slice_idx].value >>= 16; } memcpy(regular_states, values, sizeof(values)); } @@ -111,10 +111,10 @@ void crypto1_bs_bitslice_value32(uint32_t value, bitslice_t bitsliced_value[], s void crypto1_bs_print_states(bitslice_t bitsliced_states[]){ size_t slice_idx = 0; - state_t values[MAX_BITSLICES]; + state_t values[MAX_BITSLICES] = {{0x00}}; crypto1_bs_convert_states(bitsliced_states, values); for(slice_idx = 0; slice_idx < MAX_BITSLICES; slice_idx++){ - printf("State %03zu: %012"llx"\n", slice_idx, values[slice_idx].value); + printf("State %03zu: %012" PRIx64 "\n", slice_idx, values[slice_idx].value); } }