Commit 9f0816f9 by Enrico Pozzobon

test.py with flag for ram testing

parent 28a6d424
...@@ -8,6 +8,8 @@ from subprocess import Popen, PIPE ...@@ -8,6 +8,8 @@ from subprocess import Popen, PIPE
def main(argv): def main(argv):
speed_test = True
if len(argv) < 3: if len(argv) < 3:
print("Usage: test.py LWC_AEAD_KAT.txt program [arguments]") print("Usage: test.py LWC_AEAD_KAT.txt program [arguments]")
...@@ -16,11 +18,13 @@ def main(argv): ...@@ -16,11 +18,13 @@ def main(argv):
for attempt in range(3): for attempt in range(3):
print("beginning test %d of '%s' using test vectors '%s'" % (attempt, ' '.join(cmd), argv[1])) print("beginning test %d of '%s' using test vectors '%s'" % (attempt, ' '.join(cmd), argv[1]))
try: try:
measurements = begin_measurement() if speed_test:
measurements = begin_measurement()
try: try:
test(argv[1], cmd) test(argv[1], cmd)
finally: finally:
end_measurement(measurements) if speed_test:
end_measurement(measurements)
print("TEST SUCCESSFUL") print("TEST SUCCESSFUL")
return 0 return 0
...@@ -33,7 +37,7 @@ def main(argv): ...@@ -33,7 +37,7 @@ def main(argv):
return 1 return 1
def test(test_file, cmd): def test(test_file, cmd, ram_test=False):
test_file = open(test_file, 'r') test_file = open(test_file, 'r')
p = Popen(cmd, bufsize=0, stdin=PIPE, stdout=PIPE) p = Popen(cmd, bufsize=0, stdin=PIPE, stdout=PIPE)
...@@ -114,6 +118,13 @@ def test(test_file, cmd): ...@@ -114,6 +118,13 @@ def test(test_file, cmd):
print(" m = %s" % output.hex()) print(" m = %s" % output.hex())
if m != output: if m != output:
raise Exception("output of encryption is different from expected ciphertext") raise Exception("output of encryption is different from expected ciphertext")
if ram_test:
# RAM test only tests the first test vector
write(b'u')
output = obtain()
print(" untouched memory = %d" % struct.unpack("<I", output))
break
elif res is not None: elif res is not None:
if res[1].lower() == 'count': if res[1].lower() == 'count':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment