Skip to content

Commit 2e0f28b

Browse files
Add double-round function
1 parent c69a13a commit 2e0f28b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crypto/ChaCha20.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@ def _quarter_round(self, state: List[int], a: int, b: int, c: int, d: int):
3838
state[c] = (state[c] + state[d]) % (2**32)
3939
state[b] ^= state[c]
4040
state[b] = ((state[b] << 7) | (state[b] >> 25)) % (2**32)
41+
def _double_round(self, state: List[int]):
42+
self._quarter_round(state, 0, 4, 8, 12)
43+
self._quarter_round(state, 1, 5, 9, 13)
44+
self._quarter_round(state, 2, 6, 10, 14)
45+
self._quarter_round(state, 3, 7, 11, 15)
46+
self._quarter_round(state, 0, 5, 10, 15)
47+
self._quarter_round(state, 1, 6, 11, 12)
48+
self._quarter_round(state, 2, 7, 8, 13)
49+
self._quarter_round(state, 3, 4, 9, 14)

0 commit comments

Comments
 (0)