-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_app.py
38 lines (30 loc) · 947 Bytes
/
test_app.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
import pytest
import random
import string
from dss import *
n = 4 # number of tests
def random_string(stringLength):
"""Generate a random string of given length"""
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
def test():
for i in range(n):
st = random_string(10)
dso = DSS(st)
h = dso.gen_hash()
# Test for 1024 bits and e = 3
dso.gen_keys(1024, 3)
ds = dso.gen_DS(h)
assert dso.verify(h, ds), "Test Failed"
# Test for 1024 bit
dso.gen_keys(1024)
ds = dso.gen_DS(h)
assert dso.verify(h, ds), "Test Failed"
# Test for 2048 bit and e = 3
dso.gen_keys(2048, 3)
ds = dso.gen_DS(h)
assert dso.verify(h, ds), "Test Failed"
# Test for 2048 bit
dso.gen_keys(2048)
ds = dso.gen_DS(h)
assert dso.verify(h, ds), "Test Failed"