-
Notifications
You must be signed in to change notification settings - Fork 2
/
format_john_lm_bs.py
87 lines (63 loc) · 1.63 KB
/
format_john_lm_bs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -*- coding: utf-8 -*-
# Bitslice LM with output to john's format
# Copyright © 2015 Aleksey Cherepanov <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
import util_ui as U
import bytecode_main as B
import output_c as O
# import output_c_sse as O
args = U.parse_args()
c_template = 'lm_bs'
algo_file = 'lm'
c_code = U.load_code_template(c_template)
size = 8
endianity = 'be'
args['args'] = { 'size': size }
O.apply_size(size)
O.apply_endianity(endianity)
bs_size = 64
O.apply_bs_size(bs_size)
# Format setup
tests = '''
'''
vs = {
'fmt_struct_name': 'raw1_LM_bs',
'format_name': 'LM-bs',
'algo_name': 'LM',
'tag': '$LM$',
'plaintext_length': '7',
'binary_form_size': '8',
'tests': tests
}
U.setup_vars(vs)
# Optimizations and code generation
code = B.get_code_full(algo_file, **args)
interleave = 1
B.global_vars['batch_size'] = 1
B.global_vars['interleave'] = interleave
# B.global_vars['vectorize'] = 1
d = B.thread_code( code,
B.replace_state_with_const,
[ B.dump, 'pure.bytecode' ],
[ B.bitslice, 64, size ],
B.expand_bs_andnot,
[ B.dump, 'bs.bytecode' ],
[ O.gen, c_code, args, B.global_vars ]
)
# p1, p2 = B.thread_code( code,
# B.replace_state_with_const,
# [ B.dump, 'pure.bytecode' ],
# [ B.bitslice, 64, size ],
# B.expand_bs_andnot,
# [ B.dump, 'bs.bytecode' ],
# [ B.split_bitslice, 20000 ]
# )
# p1code = B.thread_code( p1,
# [ O.gen_to_str, '$code', args ]
# )
# B.global_vars['part1code'] = p1code
# p2code = B.thread_code( p2,
# [ O.gen, c_code, args, B.global_vars ]
# )