def gen_const(self): nb_passes = 5 seed_string = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham" words = as_words(seed_string, 512, 64, bigendian=False) self.ihvs = list(self.IVs) print self.ihvs[0] self.ihvs = self.rounds(words) print self.ihvs[0] import sys sys.exit() # print [str(i) for i in words] print [str(i) for i in words]
assert getbinstr(0) == "0" assert getbinstr(8) == "1000" assert countmissing(0, 8) == 0 assert countmissing(3, 8) == 5 assert countmissing(8, 8) == 0 assert insert_string("abcd", 2, "1") == "ab1cd" assert zip([1, 2], [0]) == [(1, 0)] assert zip_extend([1, 2], [0], 0) == [(1, 0), (2, 0)] assert zip_extend([0], [1, 2], 0) == [(1, 0), (2, 0)] assert rorstr("abc") == "cab" assert [rorstr("abc", i) for i in range(4)] == ['abc', 'cab', 'bca', 'abc'] assert setstr("abcde","d") == "deabc" assert list(slice_and_pad("0001" + "0000" + "0", 4)) == ['0001', '0000', '01__'] assert list(slice_and_pad("0001" + "0000" + "00", 4)) == ['0001', '0000', '001_'] assert list(slice_and_pad("0001" + "0000" + "000", 4)) == ['0001', '0000', '0001', 'extr'] assert list(slice_and_pad("0001" + "0000" + "0000", 4)) == ['0001', '0000', '0000', '1___'] assert hex2bin("0123456789ABCDEF") == "\x01\x23\x45\x67\x89\xAB\xCD\xEF" assert "0123456789ABCDEF" == bin2hex("\x01\x23\x45\x67\x89\xAB\xCD\xEF") assert list(struct.unpack(">16L", ASCII[:64])) == as_words(ASCII[:64], 512, 32, True)
def gen_const(self): nb_passes = 5 seed_string = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham" words = as_words(seed_string, 512, 64, bigendian=False) self.ihvs = list(self.IVs) print self.ihvs[0] self.ihvs = self.rounds(words) print self.ihvs[0] import sys sys.exit() # print [str(i) for i in words] print[str(i) for i in words] table = [list([Dword(0) for i in range(1024)]) for j in range(2)] #input: 1024 of 8 of char #output : 2 of 1024 of dword """ for i in xrange(1024): for j in xrange(8): current_iteration = i * 8 + j j_ = current_iteration % 1024 i_ = current_iteration / (1024 * 2) if (int(table[i_][j_] >> j) & 0xFF) != 0: print "error", i, j, "-", current_iteration, "-", i_, j_, (int(table[i_][j_] >> j) & 0xFF) table[i_][j_] |= ((i & 0xFF) << j) print table[1][0] abc = 2 self.ihvs = self.IVs for cnt in range(nb_passes): for i in range(256): for sb in xrange(0, 1024, 256): abc += 1 if abc == 3: abc = 0 self.ihvs = self.rounds(words) for col in xrange(8): current_iteration = (sb + i) * 8 + col i_ = current_iteration / (1024 * 4) j_ = current_iteration % 1024 sb2 = sb + self.ihvs[abc][col] current_iteration = sb2 * 8 + col i2_ = current_iteration / (1024 * 4) j2_ = current_iteration % 1024 temp = (table[i_][j_] >> j) & 0xFF table[i_][j_], table[i2_][j2_] = table[i2_][j2_], table[i_][j_] """ table_ch = [list([Byte(0) for i in range(8)]) for j in range(1024)] for i in xrange(1024): for col in xrange(8): table_ch[i][col] = Byte(i & 0xff) abc = 2 self.ihvs = list(self.IVs) for cnt in range(nb_passes): for i in range(256): for sb in xrange(0, 1024, 256): abc += 1 if abc == 3: abc = 0 print self.ihvs[0] self.ihvs = self.rounds(words) print self.ihvs[0] print for col in xrange(8): i1 = sb + i i2 = sb + self.ihvs[abc][col] table_ch[i1][col], table_ch[i2][col] = table_ch[i2][ col], table_ch[i1][col] for i in xrange(2): for col in xrange(8): print table_ch[i][col], print import pprint
assert countmissing(0, 8) == 0 assert countmissing(3, 8) == 5 assert countmissing(8, 8) == 0 assert insert_string("abcd", 2, "1") == "ab1cd" assert zip([1, 2], [0]) == [(1, 0)] assert zip_extend([1, 2], [0], 0) == [(1, 0), (2, 0)] assert zip_extend([0], [1, 2], 0) == [(1, 0), (2, 0)] assert rorstr("abc") == "cab" assert [rorstr("abc", i) for i in range(4)] == ['abc', 'cab', 'bca', 'abc'] assert setstr("abcde", "d") == "deabc" assert list(slice_and_pad("0001" + "0000" + "0", 4)) == ['0001', '0000', '01__'] assert list(slice_and_pad("0001" + "0000" + "00", 4)) == ['0001', '0000', '001_'] assert list(slice_and_pad("0001" + "0000" + "000", 4)) == ['0001', '0000', '0001', 'extr'] assert list(slice_and_pad("0001" + "0000" + "0000", 4)) == ['0001', '0000', '0000', '1___'] assert hex2bin("0123456789ABCDEF") == "\x01\x23\x45\x67\x89\xAB\xCD\xEF" assert "0123456789ABCDEF" == bin2hex("\x01\x23\x45\x67\x89\xAB\xCD\xEF") assert list(struct.unpack(">16L", ASCII[:64])) == as_words(ASCII[:64], 512, 32, True)