Commit 72e9cc76 by Enrico Pozzobon

minor changes

parent 3538b59b
......@@ -10,7 +10,7 @@ import subprocess
def build(algo_dir, template_dir, build_dir):
if os.path.isdir(build_dir):
return None
raise Exception("Directory %s doesn't exist" % build_dir)
print("Building in %s" % build_dir)
......@@ -77,7 +77,7 @@ def build(algo_dir, template_dir, build_dir):
os.chdir(wd)
# if execution arrives here, the build was successful
return build_dir
return True
# Find test vectors in directory or one of the parent directories
......@@ -201,18 +201,15 @@ def main(argv):
print()
# Build all found algorithms
for i, (t, d, name, st_mtime) in enumerate(files):
for t, d, name, st_mtime in files:
print()
print(d)
try:
build_dir = os.path.join(build_root_dir, name)
b = build(d, template_dir, build_dir)
build(d, template_dir, build_dir)
if b is None:
continue
shutil.copyfile(t, os.path.join(b, 'LWC_AEAD_KAT.txt'))
shutil.copyfile(t, os.path.join(build_dir, 'LWC_AEAD_KAT.txt'))
mdate_path = os.path.join(build_dir, 'cipher_mtime.txt')
with open(mdate_path, 'wt') as mdate_file:
......
......@@ -3,6 +3,7 @@ platform = espressif32
platform_packages =
toolchain-xtensa32 @ 2.50200.80
board = esp32dev
board_build.f_cpu = 240000000L
framework = arduino
build_type = release
build_flags =
......
......@@ -8,6 +8,7 @@ import signal
import datetime
import threading
import subprocess
import json
from flask import Flask, request, Response
from flask_restful import Resource, Api
from flask_jsonpify import jsonify
......@@ -34,6 +35,7 @@ class ScheduledTest:
_next_id = 1
def __init__(self, **kwargs):
if len(kwargs) > 0:
self.path = kwargs['build_dir']
self.cipher = kwargs['cipher']
self.cipher_timestamp = kwargs['cipher_timestamp']
......@@ -60,6 +62,7 @@ class ScheduledTest:
a = ScheduledTest()
for k in ScheduledTest.__slots__:
if k not in ScheduledTest._unserialized_slots:
if k != 'id':
setattr(a, k, dict[k])
return a
......@@ -303,4 +306,10 @@ if __name__ == '__main__':
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
if len(sys.argv) > 1:
with open(sys.argv[1], 'r') as fin:
saved = json.load(fin)
for job in saved['schedule']:
schedule.append(ScheduledTest.from_dict(job))
app.run(port='5002')
......@@ -170,8 +170,9 @@ def run_nist_aead_test_line(dut, i, m, ad, k, npub, c):
output = dut.obtain_var(ord('C'))
print(" c = %s" % output.hex())
if c != output:
raise Exception("output of encryption is different from " +
"expected ciphertext")
raise Exception(
("output of encryption (%s) is different from " +
"expected ciphertext (%s)") % (output.hex(), c.hex()))
dut.send_var(ord('m'), b"\0" * len(c))
dut.send_var(ord('s'), b"")
......@@ -185,8 +186,9 @@ def run_nist_aead_test_line(dut, i, m, ad, k, npub, c):
output = dut.obtain_var(ord('M'))
print(" m = %s" % output.hex())
if m != output:
raise Exception("output of encryption is different from " +
"expected ciphertext")
raise Exception(
("output of decryption (%s) is different from " +
"expected plaintext (%s)") % (output.hex(), m.hex()))
def parse_nist_aead_test_vectors(test_file_path):
......
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