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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
from os.path import join
from pyecsca.codegen.builder import build_impl
from pyecsca.codegen.client import main
def test_generate(cli_runner):
with cli_runner.isolated_filesystem() as tmpdir:
cli_runner.invoke(
build_impl,
[
"--platform",
"HOST",
"shortw",
"projective",
"add-1998-cmo",
"dbl-1998-cmo",
"z",
"ltr(complete=False)",
".",
],
)
result = cli_runner.invoke(
main,
[
"--platform",
"HOST",
"--fw",
join(tmpdir, "pyecsca-codegen-HOST.elf"),
"shortw",
"projective",
"gen",
"secg/secp128r1",
],
)
assert result.exit_code == 0
def test_ecdh(cli_runner):
with cli_runner.isolated_filesystem() as tmpdir:
cli_runner.invoke(
build_impl,
[
"--platform",
"HOST",
"shortw",
"projective",
"add-1998-cmo",
"dbl-1998-cmo",
"z",
"ltr(complete=False)",
".",
],
)
result = cli_runner.invoke(
main,
[
"--platform",
"HOST",
"--fw",
join(tmpdir, "pyecsca-codegen-HOST.elf"),
"shortw",
"projective",
"ecdh",
"secg/secp128r1",
"122835813094999453922649270086793500655,326514220558629293368386081113307347349",
],
)
assert result.exit_code == 0
result = cli_runner.invoke(
main,
[
"--platform",
"HOST",
"--fw",
join(tmpdir, "pyecsca-codegen-HOST.elf"),
"shortw",
"projective",
"ecdh",
"secg/secp128r1",
"045c69512b630addd5b6d347b7bce517eff5a459f98f015c6906ccfed3cf0bf995",
],
)
assert result.exit_code == 0
result = cli_runner.invoke(
main,
[
"--platform",
"HOST",
"--fw",
join(tmpdir, "pyecsca-codegen-HOST.elf"),
"shortw",
"projective",
"ecdh",
"secg/secp128r1",
"something",
],
)
assert result.exit_code == 2
|