forked from mikeboers/PyTomCrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkcs5-timing.py
More file actions
57 lines (41 loc) · 1.3 KB
/
Copy pathpkcs5-timing.py
File metadata and controls
57 lines (41 loc) · 1.3 KB
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
'''Tests to determine the models for time performance of pkcs5.
It appears as though pkcs5 is linear with respect to number of iteractions,
and constant with respect to password/salt length.
'''
import os
import timeit
setup = '''
from tomcrypt.pkcs5 import pkcs5
password = %r
salt = %r
'''
source = '''
pkcs5(password, salt, iteration_count=%d)
'''
print '(* Variable iteration count:'
data = []
for i in range(1, 8):
n = 2**i
data_point = (n, timeit.timeit(source % n, setup % (os.urandom(8), os.urandom(16)), number=100))
data.append(data_point)
print '\t%d -> %f' % data_point
print '*)'
print 'data = {%s}' % ', '.join('{%d, %f}' % x for x in data)
print '(* Variable password length:'
data = []
for i in range(1, 20):
n = 2 * i
data_point = (n, timeit.timeit(source % 64, setup % (os.urandom(n), os.urandom(16)), number=100))
data.append(data_point)
print '\t%d -> %f' % data_point
print '*)'
print 'data = {%s}' % ', '.join('{%d, %f}' % x for x in data)
print '(* Variable salt length:'
data = []
for i in range(1, 20):
n = 4 * i
data_point = (n, timeit.timeit(source % 64, setup % (os.urandom(8), os.urandom(n)), number=100))
data.append(data_point)
print '\t%d -> %f' % data_point
print '*)'
print 'data = {%s}' % ', '.join('{%d, %f}' % x for x in data)