So here is the new version:
![](https://cdn.hackaday.io/images/4090321739299370488.png)
It can recover from low entropy, working as a PRNG when D is fixed, uses a 32-bit barrel shifter, a 16-bit add and two 8-bit XORs.
And when the LUT is well shuffled, this works as a good scrambler.
You can't say it's complex:
uint16_t LUT16[256];
uint16_t FG;
uint8_t LFSR8=1;
uint16_t Scramble_round(uint16_t D) {
uint8_t S=LFSR8;
LFSR8 >>= 1;
if (S & 1)
LFSR8 ^= 0x8e; // Poly can be 0x: e7 f3 a6 b2 8e b8 b1 c6
uint16_t C = D + FG;
uint8_t A = C ^ S;
uint8_t B = C >> 8;
uint16_t X = LUT16[A];
uint16_t Y = LUT16[B];
uint16_t R = (X & 0x00FF)
| (Y & 0xFF00);
FG = (X & 0xFF00)
| (Y & 0x00FF);
uint32_t Z = X | (Y << 16);
Z = (Z >> (S&31)) | (Z << ((-S)& 31));
Y = Z >> 16;
LUT16[A] = Z;
LUT16[B] = Y;
return R;
}
.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.