Skip to content

Instantly share code, notes, and snippets.

@pun1sher729
Last active May 18, 2022 19:24
Show Gist options
  • Save pun1sher729/203d4c61e72ff5ed99d64b09040ce50d to your computer and use it in GitHub Desktop.
Save pun1sher729/203d4c61e72ff5ed99d64b09040ce50d to your computer and use it in GitHub Desktop.
Cryptohack - Round Keys writeup
state = [
    [206, 243, 61, 34],
    [171, 11, 93, 31],
    [16, 200, 91, 108],
    [150, 3, 194, 51],
]

round_key = [
    [173, 129, 68, 82],
    [223, 100, 38, 109],
    [32, 189, 53, 8],
    [253, 48, 187, 78],
]


def add_round_key(s, k):
    out = []
    for i in range(len(s)):
        for j in range(len(s[i])):
            out.append(s[i][j] ^ k[i][j])
    return out

def matrix2bytes(matrix):
    out = []
    for r in matrix:
        out.append(r.to_bytes(2,byteorder='little').decode())
    return ''.join(out)

print(matrix2bytes(add_round_key(state, round_key)))

flag = crypto{r0undk3y}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment