aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2020-12-14 17:38:23 +0100
committerJ08nY2020-12-14 17:38:23 +0100
commitbf264e994bedf8c5df7f9477b9546271d1ddaf00 (patch)
tree406a6d631c02a7251ea866aff1caaea26ded47fe
parent467b3185e9d2ef3457ad3c1281280c87394ab912 (diff)
downloadpyecsca-codegen-bf264e994bedf8c5df7f9477b9546271d1ddaf00.tar.gz
pyecsca-codegen-bf264e994bedf8c5df7f9477b9546271d1ddaf00.tar.zst
pyecsca-codegen-bf264e994bedf8c5df7f9477b9546271d1ddaf00.zip
Fix tests with master version of pyecsca.
-rw-r--r--ext/Makefile11
-rw-r--r--pyecsca/codegen/render.py8
-rw-r--r--test/test_client.py4
-rw-r--r--test/test_impl.py4
-rw-r--r--test/test_render.py2
5 files changed, 16 insertions, 13 deletions
diff --git a/ext/Makefile b/ext/Makefile
index 85427f0..f3216ac 100644
--- a/ext/Makefile
+++ b/ext/Makefile
@@ -11,11 +11,14 @@ clean:
tommath_dir:
mkdir -p ../pyecsca/codegen/tommath
+tommath_headers: tommath_dir
+ cp libtommath/*.h ../pyecsca/codegen/tommath/
+
host: LIBNAME=libtommath-HOST.a
host: CFLAGS=-DMP_NO_DEV_URANDOM -DMP_LOW_MEM -DMP_DEFAULT_DIGIT_COUNT=10
host: COMPILE_SIZE=1
host: COMPILE_LTO=1
-host: tommath_dir
+host: tommath_dir tommath_headers
$(MAKE) -C libtommath clean
$(MAKE) -C libtommath
cp libtommath/$(LIBNAME) ../pyecsca/codegen/tommath/$(LIBNAME)
@@ -26,7 +29,7 @@ stm32f0: LDFLAGS=--specs=nano.specs --specs=nosys.specs -T ../pyecsca/codegen/ha
stm32f0: COMPILE_SIZE=1
stm32f0: COMPILE_LTO=1
stm32f0: LIBNAME=libtommath-CW308_STM32F0.a
-stm32f0: tommath_dir
+stm32f0: tommath_dir tommath_headers
$(MAKE) -C libtommath clean
$(MAKE) -C libtommath
cp libtommath/$(LIBNAME) ../pyecsca/codegen/tommath/$(LIBNAME)
@@ -37,9 +40,9 @@ stm32f3: LDFLAGS=--specs=nano.specs -T ../pyecsca/codegen/hal/stm32f3/LinkerScri
stm32f3: COMPILE_SIZE=1
stm32f3: COMPILE_LTO=1
stm32f3: LIBNAME=libtommath-CW308_STM32F3.a
-stm32f3: tommath_dir
+stm32f3: tommath_dir tommath_headers
$(MAKE) -C libtommath clean
$(MAKE) -C libtommath
cp libtommath/$(LIBNAME) ../pyecsca/codegen/tommath/$(LIBNAME)
-.PHONY: all host stm32f0 stm32f3 xmega tommath_dir help clean \ No newline at end of file
+.PHONY: all host stm32f0 stm32f3 xmega tommath_dir tommath_headers help clean
diff --git a/pyecsca/codegen/render.py b/pyecsca/codegen/render.py
index c5c9367..2649073 100644
--- a/pyecsca/codegen/render.py
+++ b/pyecsca/codegen/render.py
@@ -4,7 +4,7 @@ import subprocess
import tempfile
from _ast import Pow
from os import path
-from os import mkdir
+from os import makedirs
from typing import Optional, List, Set, Mapping, MutableMapping, Any, Tuple
from jinja2 import Environment, PackageLoader
@@ -216,7 +216,7 @@ def render(config: DeviceConfiguration) -> Tuple[str, str, str]:
for sym in symlinks:
os.symlink(resource_filename("pyecsca.codegen", sym), path.join(temp, sym))
gen_dir = path.join(temp, "gen")
- os.mkdir(gen_dir)
+ makedirs(gen_dir, exist_ok=True)
save_render(temp, "Makefile",
render_makefile(config.platform, config.hash_type, config.mod_rand, config.red, config.mult, config.sqr))
@@ -253,10 +253,10 @@ def build(dir: str, elf_file: str, hex_file: str, outdir: str, strip: bool = Fal
if res.returncode != 0:
raise ValueError("Build failed!")
if strip:
- subprocess.run(["make", "strip"], cwd=dir)
+ subprocess.run(["make", "strip"], cwd=dir, capture_output=True)
full_elf_path = path.join(dir, elf_file)
full_hex_path = path.join(dir, hex_file)
- mkdir(outdir)
+ makedirs(outdir, exist_ok=True)
shutil.copy(full_elf_path, outdir)
shutil.copy(full_hex_path, outdir)
if remove:
diff --git a/test/test_client.py b/test/test_client.py
index aa07ff0..3132e4e 100644
--- a/test/test_client.py
+++ b/test/test_client.py
@@ -2,7 +2,7 @@ from os.path import join
from unittest import TestCase
from click.testing import CliRunner
-from pyecsca.ec.curves import get_params
+from pyecsca.ec.params import get_params
from pyecsca.ec.mod import Mod
from pyecsca.codegen.builder import build_impl
@@ -105,4 +105,4 @@ class ClientTests(TestCase):
join(tmpdir, "pyecsca-codegen-HOST.elf"),
"shortw", "projective", "ecdh", "secg/secp128r1",
"something"])
- self.assertEqual(result.exit_code, 2) \ No newline at end of file
+ self.assertEqual(result.exit_code, 2)
diff --git a/test/test_impl.py b/test/test_impl.py
index ee56c41..a061a74 100644
--- a/test/test_impl.py
+++ b/test/test_impl.py
@@ -4,7 +4,7 @@ from os.path import join
from unittest import TestCase
from click.testing import CliRunner
-from pyecsca.ec.curves import get_params
+from pyecsca.ec.params import get_params
from pyecsca.ec.key_agreement import ECDH_SHA1
from pyecsca.ec.mult import LTRMultiplier, RTLMultiplier, CoronMultiplier, BinaryNAFMultiplier
from pyecsca.ec.point import Point
@@ -232,7 +232,7 @@ class ECDSATests(ImplTests):
def callback(target, mult, params):
priv, pub = target.generate()
ecdsa = ECDSA_SHA1(copy(mult), params, mult.formulas["add"],
- Point.from_affine(params.curve.coordinate_model, pub), priv)
+ pub.to_model(params.curve.coordinate_model, params.curve), priv)
signature_data = target.ecdsa_sign(data)
diff --git a/test/test_render.py b/test/test_render.py
index 1c7acf7..b8d6075 100644
--- a/test/test_render.py
+++ b/test/test_render.py
@@ -3,7 +3,7 @@ from unittest import TestCase
from pyecsca.ec.configuration import (HashType, RandomMod, Multiplication, Squaring, Reduction,
Inversion)
-from pyecsca.ec.curves import get_params
+from pyecsca.ec.params import get_params
from pyecsca.ec.mult import LTRMultiplier
from pyecsca.codegen.common import Platform, DeviceConfiguration