Example #1
0
 def __init__(self, nbits):
     self.__set_nbits(nbits)
     self.gen_x = Vector(nbits)
     self.use_esf = False
     self.use_opt_mba = True
     for i in range(0, nbits):
         self.gen_x[i] = symbol("__gen_X_%d" % i)
Example #2
0
         0x88, 0xe1, 0x28, 0x52, 0xfa, 0xf4, 0x17, 0xd5, 0xd9, 0xb2, 0x1b,
         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):
Example #3
0
 def var_symbols(self, name):
     symbols = [symbol("%s%d" % (name, i)) for i in range(0, self.nbits)]
     M = Vector(self.nbits)
     for i in range(0, self.nbits):
         M[i] = symbols[i]
     return M