diff --git a/test.py b/test.py index 4ce83a9..d19a447 100755 --- a/test.py +++ b/test.py @@ -8,6 +8,8 @@ from subprocess import Popen, PIPE def main(argv): + speed_test = True + if len(argv) < 3: print("Usage: test.py LWC_AEAD_KAT.txt program [arguments]") @@ -16,11 +18,13 @@ def main(argv): for attempt in range(3): print("beginning test %d of '%s' using test vectors '%s'" % (attempt, ' '.join(cmd), argv[1])) try: - measurements = begin_measurement() + if speed_test: + measurements = begin_measurement() try: test(argv[1], cmd) finally: - end_measurement(measurements) + if speed_test: + end_measurement(measurements) print("TEST SUCCESSFUL") return 0 @@ -33,7 +37,7 @@ def main(argv): return 1 -def test(test_file, cmd): +def test(test_file, cmd, ram_test=False): test_file = open(test_file, 'r') p = Popen(cmd, bufsize=0, stdin=PIPE, stdout=PIPE) @@ -114,6 +118,13 @@ def test(test_file, cmd): print(" m = %s" % output.hex()) if m != output: 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("