From 72e9cc767df967f3906f84cb1a07a3c4664ad51d Mon Sep 17 00:00:00 2001 From: Enrico Pozzobon Date: Wed, 13 May 2020 13:48:42 +0200 Subject: [PATCH] minor changes --- compile_all.py | 13 +++++-------- templates/esp32/platformio.ini | 1 + test-dude.py | 23 ++++++++++++++++------- test_common.py | 10 ++++++---- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/compile_all.py b/compile_all.py index 798bcf5..429bab1 100755 --- a/compile_all.py +++ b/compile_all.py @@ -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: diff --git a/templates/esp32/platformio.ini b/templates/esp32/platformio.ini index 95213de..f27374c 100644 --- a/templates/esp32/platformio.ini +++ b/templates/esp32/platformio.ini @@ -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 = diff --git a/test-dude.py b/test-dude.py index 6ab48c4..e85cdea 100644 --- a/test-dude.py +++ b/test-dude.py @@ -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,12 +35,13 @@ class ScheduledTest: _next_id = 1 def __init__(self, **kwargs): - self.path = kwargs['build_dir'] - self.cipher = kwargs['cipher'] - self.cipher_timestamp = kwargs['cipher_timestamp'] - self.template_timestamp = kwargs['template_timestamp'] - self.template = kwargs['template'] - self.template_commit = kwargs['template_commit'] + if len(kwargs) > 0: + self.path = kwargs['build_dir'] + self.cipher = kwargs['cipher'] + self.cipher_timestamp = kwargs['cipher_timestamp'] + self.template_timestamp = kwargs['template_timestamp'] + self.template = kwargs['template'] + self.template_commit = kwargs['template_commit'] self.id = str(ScheduledTest._next_id) ScheduledTest._next_id += 1 @@ -60,7 +62,8 @@ class ScheduledTest: a = ScheduledTest() for k in ScheduledTest.__slots__: if k not in ScheduledTest._unserialized_slots: - setattr(a, k, dict[k]) + 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') diff --git a/test_common.py b/test_common.py index 2e4a681..6eaeaa4 100644 --- a/test_common.py +++ b/test_common.py @@ -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): -- libgit2 0.26.0