Commit | Line | Data |
---|---|---|
93966bd3 PG |
1 | import binascii |
2 | import sys | |
3 | ||
4 | import crypto | |
5 | ||
6 | FIXED_FILE = "no-such-file" | |
7 | FIXED_PASS = "swordfish" | |
8 | FIXED_NACL = binascii.unhexlify (b"00112233445566778899aabbccddeeff") | |
9 | ||
10 | def noise (*a, **b): | |
11 | print (file=sys.stderr, *a, **b) | |
12 | ||
13 | ||
14 | def create_objects (n): | |
15 | """ | |
16 | Repeatedly apply the .next () method of the Encrypt handle for profiling. | |
17 | """ | |
18 | ||
19 | enc = crypto.Encrypt (1, 1, password=FIXED_PASS, nacl=FIXED_NACL) | |
20 | ||
21 | for i in range (n): | |
22 | _ = enc.next (FIXED_FILE) | |
23 | ||
24 | noise ("accumulated %d ivs" % len (enc.get_used_ivs ())) | |
25 | ||
26 | noise ("") | |
27 | noise ("** <C-d> to terminate **") | |
28 | _ = sys.stdin.read () # halt here so we get a chance to inspec /proc/$$/status | |
29 | ||
30 | return 0 | |
31 | ||
32 | ||
33 | def main (argv): | |
34 | if len (argv) != 2: | |
35 | noise ("number of iterations required!") | |
36 | return 42 | |
37 | ||
38 | n = argv [1] | |
39 | n = int (n) | |
40 | ||
41 | return create_objects (n) | |
42 | ||
43 | if __name__ == "__main__": | |
44 | sys.exit (main (sys.argv)) |