1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import tempfile
from unittest import TestCase
from pyecsca.ec.configuration import (HashType, RandomMod, Multiplication, Squaring, Reduction,
Inversion)
from pyecsca.ec.params import get_params
from pyecsca.ec.mult import LTRMultiplier
from pyecsca.codegen.common import Platform, DeviceConfiguration
from pyecsca.codegen.render import render_and_build
class RenderTests(TestCase):
def test_basic_build(self):
platform = Platform.HOST
hash_type = HashType.SHA1
mod_rand = RandomMod.REDUCE
mult = Multiplication.BASE
sqr = Squaring.BASE
red = Reduction.BASE
inv = Inversion.GCD
params = get_params("secg", "secp128r1", "projective")
model = params.curve.model
coords = params.curve.coordinate_model
add = coords.formulas["add-1998-cmo"]
dbl = coords.formulas["dbl-1998-cmo"]
scl = coords.formulas["z"]
formulas = [add, dbl, scl]
scalarmult = LTRMultiplier(add, dbl, scl)
config = DeviceConfiguration(model, coords, formulas, scalarmult, hash_type, mod_rand, mult,
sqr, red, inv, platform, True, True, True)
temp = tempfile.mkdtemp()
render_and_build(config, temp, True)
|