Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from chacha20 import *
- from os import urandom
- from math import log
- for rounds in range(0,21,2):
- count = 0
- for _ in range(0xffff):
- key = urandom(32)
- key1 = bytes([rot_left(key[i],1) % 0xff for i in range(len(key))])
- nonce = urandom(8)
- chacha1 = ChaCha20(key,nonce,rounds = rounds)
- chacha2 = ChaCha20(key1,nonce,rounds = rounds)
- s1, s2 = chacha1.retrieve_stream(), chacha2.retrieve_stream()
- if rot_left(s1[0],1) == s2[0]:
- count = count + 1
- try:
- print("With {} rounds: 2^({}), {} positive".format(str(rounds),str(log(count/0xffff)),str(count)))
- except:
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement