-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple test script to test all modes supported by capture.py #150
Conversation
cw/test_capture.sh
Outdated
done | ||
|
||
# OTBN | ||
# TODO! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vogelpi basically there are just two otbn commands:
otbn_test_list["otbn-vertical"]=100
otbn_test_list["otbn-vertical-batch"]=1000
The differentiation between keygen and modinv is done through an "app" parameter in the relevant capture config files
cw/test_capture.sh
Outdated
aes_test_list["aes-random"]=100 | ||
aes_test_list["aes-random-batch"]=1000 | ||
aes_test_list["aes-fvsr-key"]=100 | ||
aes_test_list["aes-fvsr-key-batch"]=1000 | ||
|
||
for test in ${!aes_test_list[@]}; do | ||
echo Testing ${test} on ${BOARD} | ||
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log" | ||
if [ "${test}" = "aes-random" ]; then | ||
ARGS="--force-program-bitstream" | ||
else | ||
ARGS="" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are not always executed in the order they're listed here. Consequently, argument --force-program-bitstream
is not always set for the first test that is executed. For this reason, some tests end up running using a wrong bitstream.
I would fix this by moving ARGS="--force-program-bitstream"
before the for loop and ARGS=""
at the end of the loop body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vrozic for your suggestion, this is now changed.
cw/test_capture.sh
Outdated
kmac_test_list["kmac-random"]=100 | ||
kmac_test_list["kmac-fvsr-key"]=100 | ||
kmac_test_list["kmac-fvsr-key-batch"]=1000 | ||
|
||
for test in ${!kmac_test_list[@]}; do | ||
echo Testing ${test} on ${BOARD} | ||
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log" | ||
if [ "${test}" = "kmac-random" ]; then | ||
ARGS="--force-program-bitstream" | ||
else | ||
ARGS="" | ||
fi | ||
NUM_TRACES=${kmac_test_list[${test}]} | ||
./capture.py --cfg-file capture_${MODE}_${BOARD}.yaml capture ${test} \ | ||
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log" | ||
mv projects/sample_traces_${MODE}.html tmp/${BOARD}_${test}_traces.html | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
cw/test_capture.sh
Outdated
sha3_test_list["sha3-fvsr-data"]=100 | ||
sha3_test_list["sha3-fvsr-data-batch"]=1000 | ||
|
||
for test in ${!sha3_test_list[@]}; do | ||
echo Testing ${test} on ${BOARD} | ||
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log" | ||
if [ "${test}" = "sha3-fvsr-data" ]; then | ||
ARGS="--force-program-bitstream" | ||
else | ||
ARGS="" | ||
fi | ||
NUM_TRACES=${sha3_test_list[${test}]} | ||
./capture.py --cfg-file capture_${MODE}_${BOARD}.yaml capture ${test} \ | ||
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log" | ||
mv projects/sample_traces_${MODE}.html tmp/${BOARD}_${test}_traces.html | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
cw/test_capture.sh
Outdated
# OTBN | ||
# TODO! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# OTBN | |
# TODO! | |
# OTBN keygen | |
MODE="otbn_vertical_keygen" | |
declare -A otbn_keygen_test_list | |
otbn_keygen_test_list["otbn-vertical"]=100 | |
otbn_keygen_test_list["otbn-vertical-batch"]=1000 | |
ARGS="--force-program-bitstream" | |
for test in ${!otbn_keygen_test_list[@]}; do | |
echo Testing ${test} on ${BOARD} | |
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log" | |
NUM_TRACES=${otbn_keygen_test_list[${test}]} | |
./capture.py --cfg-file capture_${MODE}.yaml capture ${test} \ | |
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log" | |
mv projects/sample_traces_ecdsa_keygen.html tmp/${BOARD}_${test}_traces.html | |
ARGS="" | |
done | |
# OTBN modinv | |
MODE="otbn_vertical_modinv" | |
declare -A otbn_modinv_test_list | |
otbn_modinv_test_list["otbn-vertical"]=100 | |
for test in ${!otbn_modinv_test_list[@]}; do | |
echo Testing ${test} on ${BOARD} | |
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log" | |
NUM_TRACES=${otbn_modinv_test_list[${test}]} | |
./capture.py --cfg-file capture_${MODE}.yaml capture ${test} \ | |
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log" | |
mv projects/sample_traces_ecdsa_modinv.html tmp/${BOARD}_${test}_traces.html | |
done |
Something like this works well for testing otbn vertical keygen and modinv.
A couple of caveats:
pll_frequency
incapture_otbn_vertical_modinv.yaml
needs to be reduced to 91 MHz- parameter
test_type:
(KEY or SEED) cannot be overridden through command line. This is currently only testing fortest_type: KEY
. - OTBN commands don't follow the same naming strategy used in the rest of the script. As a result we end up with two tests named
otbn_vertical
. We should come up with a convention for naming capture commands and modes. I'll open an issue for this. - This doesn't include capture of ECDSA256 and ECDSA384. I suggest to add those later after we close [objs] update ECC384 binaries #149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vrozic and @wettermo for your input. I've included this as is and it seems to work okay. Just needed to add something to distinguish the result figures for keygen and modinv.
Regarding the points you've raised @vrozic :
- This seems to be handled by the yaml file entirely and I believe it's fine as is
- Good point, I believe testing
KEY
is sufficient. IIRC, this is what we really care about here. - Thanks, sounds good.
- Thanks, I've added a TODO in the script and will update/merge that other PR in OpenTitan.
b413294
to
3f12af4
Compare
Signed-off-by: Pirmin Vogel <[email protected]>
3f12af4
to
4e93b4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vogelpi for the update.
I've tested the latest changes and the script works well.
All graphs look correct except for the sha3-fvsr-data (non-batch) where it seems that the wrong offset is used. This is a pre-existing problem.
In my view this is ready to merge.
Thanks @vrozic , yes I've noted the thing with the sha3 non-batch capture as well. |
This PR adds a very simple script to test all capture modes currently supported by
capture.py
. What it does is running the capture commands and copy the trace sample figures undertmp
for visual inspection. This is useful for a couple of things we need to do soon:capture.py
The script is not beautiful nor smart but it does what it needs. We can improve / rewrite as we do the things above.