/
format_john_lm.py
66 lines (45 loc) · 1.12 KB
/
format_john_lm.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
# -*- coding: utf-8 -*-
# LM with output to john's format
# Copyright © 2015 Aleksey Cherepanov <lyosha@openwall.com>
#
# 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'
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',
'format_name': 'LM',
'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' ],
[ O.gen, c_code, args, B.global_vars ]
)