Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8af9d9f6
authored
Jul 13, 2020
by
Enrico Pozzobon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved some reused code in test_common.py
parent
a5fb9cb2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
84 deletions
+55
-84
templates/bluepill/test.py
+2
-14
templates/esp32/test.py
+2
-14
templates/f1-libopencm3/test.py
+2
-14
templates/f7/test.py
+2
-14
templates/maixduino/test.py
+2
-14
templates/uno/test.py
+2
-14
test_common.py
+43
-0
No files found.
templates/bluepill/test.py
View file @
8af9d9f6
...
@@ -6,6 +6,7 @@ import serial.tools.list_ports
...
@@ -6,6 +6,7 @@ import serial.tools.list_ports
from
test_common
import
(
from
test_common
import
(
DeviceUnderTestAeadUARTP
,
DeviceUnderTestAeadUARTP
,
eprint
,
eprint
,
test_main
,
OpenOcd
,
OpenOcd
,
FileMutex
,
FileMutex
,
run_nist_lws_aead_test
run_nist_lws_aead_test
...
@@ -110,18 +111,5 @@ class BluePill(DeviceUnderTestAeadUARTP):
...
@@ -110,18 +111,5 @@ class BluePill(DeviceUnderTestAeadUARTP):
return
ram
return
ram
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
BluePill
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
0x0002
)
return
0
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
sys
.
exit
(
test_main
(
BluePill
,
0x0002
,
sys
.
argv
))
templates/esp32/test.py
View file @
8af9d9f6
...
@@ -8,6 +8,7 @@ import serial.tools.list_ports
...
@@ -8,6 +8,7 @@ import serial.tools.list_ports
from
test_common
import
(
from
test_common
import
(
DeviceUnderTestAeadUARTP
,
DeviceUnderTestAeadUARTP
,
eprint
,
eprint
,
test_main
,
FileMutex
,
FileMutex
,
run_nist_lws_aead_test
,
run_nist_lws_aead_test
,
)
)
...
@@ -97,18 +98,5 @@ class ESP32(DeviceUnderTestAeadUARTP):
...
@@ -97,18 +98,5 @@ class ESP32(DeviceUnderTestAeadUARTP):
return
None
return
None
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
ESP32
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
0x0020
)
return
0
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
sys
.
exit
(
test_main
(
ESP32
,
0x0020
,
sys
.
argv
))
templates/f1-libopencm3/test.py
View file @
8af9d9f6
...
@@ -6,6 +6,7 @@ import serial.tools.list_ports
...
@@ -6,6 +6,7 @@ import serial.tools.list_ports
from
test_common
import
(
from
test_common
import
(
DeviceUnderTestAeadUARTP
,
DeviceUnderTestAeadUARTP
,
eprint
,
eprint
,
test_main
,
OpenOcd
,
OpenOcd
,
FileMutex
,
FileMutex
,
run_nist_lws_aead_test
run_nist_lws_aead_test
...
@@ -110,18 +111,5 @@ class BluePill(DeviceUnderTestAeadUARTP):
...
@@ -110,18 +111,5 @@ class BluePill(DeviceUnderTestAeadUARTP):
return
ram
return
ram
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
BluePill
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
0x0002
)
return
0
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
sys
.
exit
(
test_main
(
BluePill
,
0x0002
,
sys
.
argv
))
templates/f7/test.py
View file @
8af9d9f6
...
@@ -7,6 +7,7 @@ import serial.tools.list_ports
...
@@ -7,6 +7,7 @@ import serial.tools.list_ports
from
test_common
import
(
from
test_common
import
(
DeviceUnderTestAeadUARTP
,
DeviceUnderTestAeadUARTP
,
eprint
,
eprint
,
test_main
,
FileMutex
,
FileMutex
,
run_nist_lws_aead_test
,
run_nist_lws_aead_test
,
)
)
...
@@ -65,18 +66,5 @@ class F7(DeviceUnderTestAeadUARTP):
...
@@ -65,18 +66,5 @@ class F7(DeviceUnderTestAeadUARTP):
return
bytes
(
jlink
.
memory_read8
(
0x20000000
,
F7
.
RAM_SIZE
))
return
bytes
(
jlink
.
memory_read8
(
0x20000000
,
F7
.
RAM_SIZE
))
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
F7
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
0x0008
)
return
0
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
sys
.
exit
(
test_main
(
F7
,
0x0008
,
sys
.
argv
))
templates/maixduino/test.py
View file @
8af9d9f6
...
@@ -9,6 +9,7 @@ from test_common import (
...
@@ -9,6 +9,7 @@ from test_common import (
DeviceUnderTestAeadUARTP
,
DeviceUnderTestAeadUARTP
,
FileMutex
,
FileMutex
,
eprint
,
eprint
,
test_main
,
run_nist_lws_aead_test
,
run_nist_lws_aead_test
,
)
)
...
@@ -78,18 +79,5 @@ class Maixduino(DeviceUnderTestAeadUARTP):
...
@@ -78,18 +79,5 @@ class Maixduino(DeviceUnderTestAeadUARTP):
return
None
return
None
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
Maixduino
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
0x0080
)
return
0
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
sys
.
exit
(
test_main
(
Maixduino
,
0x0080
,
sys
.
argv
))
templates/uno/test.py
View file @
8af9d9f6
...
@@ -9,6 +9,7 @@ import serial.tools.list_ports
...
@@ -9,6 +9,7 @@ import serial.tools.list_ports
from
test_common
import
(
from
test_common
import
(
DeviceUnderTestAeadUARTP
,
DeviceUnderTestAeadUARTP
,
eprint
,
eprint
,
test_main
,
FileMutex
,
FileMutex
,
run_nist_lws_aead_test
,
run_nist_lws_aead_test
,
)
)
...
@@ -95,18 +96,5 @@ class Uno(DeviceUnderTestAeadUARTP):
...
@@ -95,18 +96,5 @@ class Uno(DeviceUnderTestAeadUARTP):
return
None
return
None
def
main
(
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
Uno
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
0x0800
)
return
0
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
sys
.
exit
(
test_main
(
Uno
,
0x0800
,
sys
.
argv
))
test_common.py
100644 → 100755
View file @
8af9d9f6
...
@@ -730,3 +730,46 @@ def run_nist_lws_aead_test(dut, vectors_file, build_dir,
...
@@ -730,3 +730,46 @@ def run_nist_lws_aead_test(dut, vectors_file, build_dir,
print
(
"TIME,VALUE"
,
file
=
f
)
print
(
"TIME,VALUE"
,
file
=
f
)
for
t
,
v
in
logic_trace
:
for
t
,
v
in
logic_trace
:
print
(
"
%.10
f,0x
%
x"
%
(
t
,
v
),
file
=
f
)
print
(
"
%.10
f,0x
%
x"
%
(
t
,
v
),
file
=
f
)
def
test_main
(
dut_ctor
,
logic_mux_mask
,
argv
):
if
len
(
argv
)
!=
2
:
print
(
"Usage: test build_dir"
)
return
1
build_dir
=
argv
[
1
]
kat_path
=
os
.
path
.
join
(
build_dir
,
'LWC_AEAD_KAT.txt'
)
dut
=
dut_ctor
(
build_dir
)
run_nist_lws_aead_test
(
dut
,
kat_path
,
build_dir
,
logic_mux_mask
)
return
0
if
__name__
==
'__main__'
:
import
serial
import
argparse
# Parse the arguments
argparser
=
argparse
.
ArgumentParser
(
description
=
'Execute a single test over UART - useful for debugging'
)
argparser
.
add_argument
(
'-t'
,
'--tty'
,
required
=
True
)
argparser
.
add_argument
(
'-b'
,
'--baud'
,
default
=
115200
)
argparser
.
add_argument
(
'-m'
,
'--message'
,
required
=
True
)
argparser
.
add_argument
(
'-a'
,
'--ad'
,
default
=
""
)
argparser
.
add_argument
(
'-k'
,
'--key'
,
required
=
True
)
argparser
.
add_argument
(
'-n'
,
'--nonce'
,
required
=
True
)
argparser
.
add_argument
(
'-c'
,
'--ciphertext'
,
default
=
None
)
args
=
argparser
.
parse_args
(
sys
.
argv
[
1
:])
ser
=
serial
.
Serial
(
args
.
tty
,
args
.
baud
,
timeout
=
1
)
dut
=
DeviceUnderTestAeadUARTP
(
ser
)
dut
.
uartp
=
UARTP
(
ser
)
run_nist_aead_test_line
(
dut
,
0
,
bytes
.
fromhex
(
args
.
message
),
bytes
.
fromhex
(
args
.
ad
),
bytes
.
fromhex
(
args
.
key
),
bytes
.
fromhex
(
args
.
nonce
),
bytes
.
fromhex
(
args
.
ciphertext
)
if
args
.
ciphertext
is
not
None
else
None
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment