base_key_pointer = 0 base_tweak_pointer = 17 base_subkey_pointer = 20 expected_value = [ 0xd593da0741e72355, 0x15b5e511ac73e00c, 0x5180e5aebaf2c4f0, 0x03bd41d3fcbcafaf, 0x1caec6fd1983a898, 0x6e510b8bcdd0589f, 0x77e2bdfdc6394ada, 0xc11e1db524dcb0a3, 0xd6d14af9c6329ab5, 0x6a9b0bfc6eb67e0d, 0x9243c60dccff1332, 0x1a1f1dde743f02d4, 0x0996753c10ed0bb8, 0x6572dd22f2b496ad, 0x51fd3062d00a579a, 0x1de0536e8682e539 ] f = open("test/build/subkey_test.asm", 'w') sg = SkeinGenerator(f) sg.select_core() sg.initialize_key(base_key_pointer) sg.initialize_tweak(base_tweak_pointer, base_tweak_pointer, SkeinTypeValue.MESSAGE) sg.calculate_key_extend(base_key_pointer) sg.calculate_tweak_extend(base_tweak_pointer) s = 0 for i in range(0, 16): sg.calculate_subkey_word(s, i, base_key_pointer, base_tweak_pointer) f.write("Save {}\n".format(base_subkey_pointer)) sg.check_word_64(base_subkey_pointer, expected_value[i]) f.close()
from skein import SkeinGenerator state_ptr = 0 next_state_ptr = 16 expected_value = [ 0, 9, 2, 13, 6, 11, 4, 15, 10, 7, 12, 3, 14, 5, 8, 1 ] f = open("test/build/permute_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() # Initialize array for i in range(0, 16): f.write("// CoreSimInput {}\n".format(i)) f.write("Constant 0\n") f.write("Save {}\n".format(i)) # Perform permutation sg.calculate_permute(state_ptr, next_state_ptr) # Check for (position, value) in enumerate(expected_value): sg.check_word_64(position + next_state_ptr, value) f.close()
# Multi test will test multiple hash functions and make sure that the lowest # bits off nonce is saved. It is basically multiple runs of full_test.py from skein import SkeinGenerator, SkeinTypeValue key = 0 tweak = 17 state = 20 nextstate = 37 best_nonce = 54 best_bits_off = 56 new_nonce = 57 f = open("test/build/multi_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() sg.initialize_best_bits_off(best_bits_off) sg.initialize_key(key) sg.initialize_plaintext(state, SkeinTypeValue.MESSAGE, new_nonce=new_nonce) sg.hash(key, tweak, state, nextstate, new_nonce) sg.count_bits_off(key) sg.compare_bits_off(best_nonce, best_bits_off, new_nonce) sg.check_word_64(best_bits_off, 517) sg.initialize_key(key) sg.initialize_plaintext(state, SkeinTypeValue.MESSAGE, new_nonce=new_nonce, nonce_index=1) sg.hash(key, tweak, state, nextstate, new_nonce)
key = 0 tweak = 17 state = 20 nextstate = 37 new_nonce = 57 expected_value = [ 0xd5ff68909ad07bb0, 0x34139128d6af518b, 0x59efa8feec314b40, 0x96e163d52fb379f9, 0xef219342d38d3a4d, 0x89bb52cc13a90583, 0xea3d1f2f23ed6545, 0xe87b9aa7b2bc36d8, 0xfad0aca8fecb0a21, 0x52ef503d6d8c64f9, 0x93cbebbd598dcef2, 0x5c7f6f7dd26fa565, 0x870c73f160426e7e, 0xa1d752a58d01bcfd, 0x19db6f6db300c113, 0x994ca58ddec3d814 ] f = open("test/build/hash_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() sg.initialize_key(key) sg.initialize_plaintext(state, SkeinTypeValue.MESSAGE, new_nonce) sg.hash(key, tweak, state, nextstate, new_nonce) # Check result for (i, val) in enumerate(expected_value): sg.check_word_64(key + i, val) f.close()
from skein import SkeinGenerator state_ptr = 0 next_state_ptr = 16 expected_value = [ 0, 9, 2, 13, 6, 11, 4, 15, 10, 7, 12, 3, 14, 5, 8, 1 ] f = open("test/build/permute_test.asm", 'w') sg = SkeinGenerator(f) sg.select_core() # Initialize array for i in range(0, 16): f.write("// CoreSimInput {}\n".format(i)) f.write("Constant 0\n") f.write("Save {}\n".format(i)) # Perform permutation sg.calculate_permute(state_ptr, next_state_ptr) # Check for (position, value) in enumerate(expected_value): sg.check_word_64(position + next_state_ptr, value) f.close()
state = 0 bits_off = 40 hash_result = [ 0x929e8e3169cbd68b, 0x84af36b812cc2442, 0xa2a6bf36db04a29d, 0x29bd9ec675ae7151, 0x9ffddc3ed0098f76, 0x880176525044f3d6, 0xa11450e8859f7adc, 0xa77d0428d216aeae, 0x618ed3f431a9f5af, 0x08d73dc5094591e4, 0x56c8ee5e50006c58, 0x2172838faabd410f, 0x3acc0c87f95eae38, 0x1ed16982db2979b5, 0x3087d22f0fc7b53b, 0x71802626662ab09c ] f = open("test/build/bits_off_count_test.asm", 'w') sg = SkeinGenerator(f) sg.select_core() # Initialize result in RAM for (index, val) in enumerate(hash_result): f.write("// CoreSimInput {}\n".format(hex(val))) f.write("Constant {}\n".format(index)) f.write("Save {}\n".format(state + index)) # Count the bits sg.count_bits_off(state, bits_off) sg.check_word_64(bits_off, 502) f.close()
0x96e163d52fb379f9, 0xef219342d38d3a4d, 0x89bb52cc13a90583, 0xea3d1f2f23ed6545, 0xe87b9aa7b2bc36d8, 0xfad0aca8fecb0a21, 0x52ef503d6d8c64f9, 0x93cbebbd598dcef2, 0x5c7f6f7dd26fa565, 0x870c73f160426e7e, 0xa1d752a58d01bcfd, 0x19db6f6db300c113, 0x994ca58ddec3d814 ] f = open("test/build/hash_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() sg.initialize_key(key) sg.initialize_plaintext(state, SkeinTypeValue.MESSAGE, new_nonce) sg.hash(key, tweak, state, nextstate, new_nonce) # Check result for (i, val) in enumerate(expected_value): sg.check_word_64(key + i, val) f.close()
from skein import SkeinGenerator state_a = 0 state_b = 16 d = 2 j = 1 x0 = 0x7cf426fd60eab5b3 x1 = 0xe94a5b59a1742100 expected_y0 = 0x663e8257025ed6b3 expected_y1 = 0xf29b37cd151cc6bd f = open("test/build/mix_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() f.write("// CoreSimInput {}\n".format(x0)) f.write("Constant 0\n") f.write("Save {}\n".format(state_a + (2 * j))) f.write("// CoreSimInput {}\n".format(x1)) f.write("Constant 0\n") f.write("Save {}\n".format(state_a + (2 * j) + 1)) sg.calculate_mix(d, j, state_a, state_b) sg.check_word_64(state_b + (2 * j), expected_y0) sg.check_word_64(state_b + (2 * j) + 1, expected_y1) f.close()
0x880176525044f3d6, 0xa11450e8859f7adc, 0xa77d0428d216aeae, 0x618ed3f431a9f5af, 0x08d73dc5094591e4, 0x56c8ee5e50006c58, 0x2172838faabd410f, 0x3acc0c87f95eae38, 0x1ed16982db2979b5, 0x3087d22f0fc7b53b, 0x71802626662ab09c ] f = open("test/build/bits_off_count_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() # Initialize result in RAM for (index, val) in enumerate(hash_result): f.write("// CoreSimInput {}\n".format(hex(val))) f.write("Constant {}\n".format(index)) f.write("Save {}\n".format(state + index)) # Count the bits sg.count_bits_off(state, bits_off) sg.check_word_64(bits_off, 502) f.close()
0x6e510b8bcdd0589f, 0x77e2bdfdc6394ada, 0xc11e1db524dcb0a3, 0xd6d14af9c6329ab5, 0x6a9b0bfc6eb67e0d, 0x9243c60dccff1332, 0x1a1f1dde743f02d4, 0x0996753c10ed0bb8, 0x6572dd22f2b496ad, 0x51fd3062d00a579a, 0x1de0536e8682e539 ] f = open("test/build/subkey_test.asm", 'w+') sg = SkeinGenerator(f) sg.select_core() sg.initialize_key(base_key_pointer) sg.initialize_tweak(base_tweak_pointer, base_tweak_pointer, SkeinTypeValue.MESSAGE) sg.calculate_key_extend(base_key_pointer) sg.calculate_tweak_extend(base_tweak_pointer) s = 0 for i in range(0, 16): sg.calculate_subkey_word(s, i, base_key_pointer, base_tweak_pointer) f.write("Save {}\n".format(base_subkey_pointer)) sg.check_word_64(base_subkey_pointer, expected_value[i]) f.close()