Commit 72e9cc76 by Enrico Pozzobon

minor changes

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