0x87, 0xe4, 0x40, 0x23, 0xc7, 0xa4, 0x00, 0x63, 0x2b, 0x48, 0xec, 0x8f, 0x7d, 0x1e, 0xba, 0xd9, 0x91, 0xf2, 0x56, 0x35, 0x14, 0x77, 0xd3, 0xb0, 0xf8, 0x9b, 0x3f, 0x5c, 0xae, 0xcd, 0x69, 0x0a, 0x42, 0x21, 0x85, 0xe6, 0x02, 0x61, 0xc5, 0xa6, 0xee, 0x8d, 0x29, 0x4a, 0xb8, 0xdb, 0x7f, 0x1c, 0x54, 0x37, 0x93, 0xf0, 0x38, 0x5b, 0xff, 0x9c, 0xd4, 0xb7, 0x13, 0x70, 0x82, 0xe1, 0x45, 0x26, 0x6e, 0x0d, 0xa9, 0xca, 0x2e, 0x4d, 0xe9, 0x8a, 0xc2, 0xa1, 0x05, 0x66, 0x94, 0xf7, 0x53, 0x30, 0x78, 0x1b, 0xbf, 0xdc, 0x4c, 0x2f, 0x8b, 0xe8, 0xa0, 0xc3, 0x67, 0x04, 0xf6, 0x95, 0x31, 0x52, 0x1a, 0x79, 0xdd, 0xbe, 0x5a, 0x39, 0x9d, 0xfe, 0xb6, 0xd5, 0x71, 0x12, 0xe0, 0x83, 0x27, 0x44, 0x0c, 0x6f, 0xcb, 0xa8, 0x60, 0x03, 0xa7, 0xc4, 0x8c, 0xef, 0x4b, 0x28, 0xda, 0xb9, 0x1d, 0x7e, 0x36, 0x55, 0xf1, 0x92, 0x76, 0x15, 0xb1, 0xd2, 0x9a, 0xf9, 0x5d, 0x3e, 0xcc, 0xaf, 0x0b, 0x68, 0x20, 0x43, 0xe7, 0x84 ] S, X = mba8.permut2expr(S) S = S.vectorial_decomp([X]) def step(b): new = S((b[10] ^ b[12] ^ b[13] ^ b[15]).vec) new = mba8.from_vec(simplify_inplace(new)) return [new] + b[:15] def f(b): for i in range(64): b = step(b) return b
0x99, 0x48, 0xbc, 0x92, 0x4a, 0xf1, 0x1b, 0xd7, 0x20 ]] from arybo.lib import MBA, simplify, simplify_inplace from pytanque import symbol, Vector import copy, random, sys mba8 = MBA(8) mba64 = MBA(64) data = [mba8.from_cst(random.randint(0, 255)) for i in range(32)] nbits = int(sys.argv[1]) idxes = list(range(nbits)) random.shuffle(idxes) for i in range(nbits): data[idxes[i]].vec[random.randint(0, 7)] = symbol("i%d" % i) sbox_E, X = mba8.permut2expr(sbox) sbox = sbox_E.vectorial_decomp([X]) def S(K): return [mba8.from_vec(simplify_inplace(sbox(K[i].vec))) for i in range(64)] def P(K): return [K[tau[i]] for i in range(64)] def L(K): state = K for i in range(8): v = mba64.from_cst(0)
Z_ = (Z >> (N * 8)) & 0xFF t = Z_ ^ C_ T_ = S[t] B = C >> 8 C = B ^ T_ C = (~C) & 0xFFFFFFFF return C from arybo.lib import MBA, simplify, simplify_inplace from arybo.tools import app_inverse mba = MBA(32) S, X = mba.permut2expr(S) S = S.vectorial_decomp([X]) def compute_arybo(Z): C = mba.from_cst(0xFFFFFFFF) A = 0 for N in range(0, 4): C_ = (C >> (A * 8)) & 0xFF Z_ = (Z >> (N * 8)) & 0xFF t = Z_ ^ C_ T_ = mba.from_vec(simplify(S(t.vec))) B = C >> 8 C = B ^ T_