0
$\begingroup$
from Crypto.Util.number import bytes_to_long
import random
from secret import mask

def lfsr(R, mask):
    output = (R << 1) & ((1 << 128) - 1)
    i = (R & mask) & ((1 << 128) - 1)
    last = 0
    while i != 0:
        last ^= (i & 1)
        i = i >> 1
    output ^= last
    return (output,last)


real_mask = bytes_to_long(mask)
R = random.getrandbits(128)
print(R)

for _ in range(777):
    R, out = lfsr(R, real_mask)
print(R)

# 266411319647933582688190755591962455713
# 213109676864975401669496815463805618647

I know two states. How can I get the mask?

New contributor
lazyd0g is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
  • 2
    $\begingroup$ Use Berlakamp-Massey or use Gaussian elimination. Keep in mind that both requires output... $\endgroup$
    – kelalaka
    Sep 19 at 5:22

0

Your Answer

lazyd0g is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.