This commit is contained in:
iceman1001 2024-01-18 16:41:13 +01:00
commit 22fd440c83
14 changed files with 270 additions and 222 deletions

View file

@ -226,18 +226,18 @@ int smart_generator_msb_byte_only(generator_context_t *ctx) {
int smart_generator_nibble_sequence(generator_context_t *ctx) {
// patterns like A0A1A2A3...F0F1F2F3
// also with offsets - A1A2A3, A2A3A4, etc
// counter1 is high nibble (A, B, C), counter2 is low nibble (0,1, etc)
// counter1 is high nibble (A, B, C), counter2 is low nibble (0,1, etc)
if(ctx->counter1 == 0){ // init values on first generator call
if (ctx->counter1 == 0) { // init values on first generator call
ctx->counter1 = 0x0A;
}
uint8_t key_byte;
// we substract %2 value because max_offset must be even number
uint8_t max_offset = 10 - (ctx->key_length / 2) - (ctx->key_length/2) % 2;
if(ctx->counter1 == 0x10){
// we substract %2 value because max_offset must be even number
uint8_t max_offset = 10 - (ctx->key_length / 2) - (ctx->key_length / 2) % 2;
if (ctx->counter1 == 0x10) {
return BF_GENERATOR_END;
}
@ -245,16 +245,16 @@ int smart_generator_nibble_sequence(generator_context_t *ctx) {
for (key_byte = 0; key_byte < ctx->key_length; key_byte++) {
ctx->current_key |= (uint64_t) ctx->counter1 << (((ctx->key_length - key_byte - 1) * 8) + 4);
ctx->current_key |= (uint64_t) (key_byte + ctx->counter2) %10 << ((ctx->key_length - key_byte - 1) * 8);
ctx->current_key |= (uint64_t)(key_byte + ctx->counter2) % 10 << ((ctx->key_length - key_byte - 1) * 8);
}
// counter 2 is the offset
ctx->counter2++;
if(ctx->counter2 == max_offset){
if (ctx->counter2 == max_offset) {
ctx->counter2 = 0;
ctx->counter1++;
}
return BF_GENERATOR_NEXT;
}
}

View file

@ -37,7 +37,7 @@ static void CONSTRUCTOR init_lut(void) {
for (uint32_t i = 0; i < 1 << 20; ++i) {
filterlut[i] = filter(i);
}
}
for (uint32_t i = 0; i < 0x10E100A; i++) {
uc_evenparity32_lut[i] = evenparity32(i);
@ -45,9 +45,9 @@ static void CONSTRUCTOR init_lut(void) {
}
// MSVC
#if defined _MSC_VER
#if defined _MSC_VER
typedef void(__cdecl* PF)(void);
typedef void(__cdecl *PF)(void);
#pragma section(".CRT$XCG", read)
__declspec(allocate(".CRT$XCG")) PF f[] = { init_lut };
@ -79,16 +79,14 @@ static inline void extend_table(uint32_t *tbl, uint32_t **end, int bit, int m1,
*tbl |= tbl_filter ^ bit;
update_contribution(tbl, m1, m2);
*tbl ^= in;
}
else if (tbl_filter == bit) {
} else if (tbl_filter == bit) {
*++*end = tbl[1];
tbl[1] = tbl[0] | 1;
update_contribution(tbl, m1, m2);
*tbl++ ^= in;
update_contribution(tbl, m1, m2);
*tbl ^= in;
}
else
} else
*tbl-- = *(*end)--;
}
}
@ -102,12 +100,10 @@ static inline void extend_table_simple(uint32_t *tbl, uint32_t **end, int bit) {
tbl_filter = filter(*tbl);
if (tbl_filter ^ filter(*tbl | 1)) { // replace
*tbl |= tbl_filter ^ bit;
}
else if (tbl_filter == bit) { // insert
} else if (tbl_filter == bit) { // insert
*++*end = *++tbl;
*tbl = tbl[-1] | 1;
}
else { // drop
} else { // drop
*tbl-- = *(*end)--;
}
}