summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-05-26 17:24:32 -0500
committerCommit Bot <commit-bot@chromium.org>2021-06-09 16:16:28 +0000
commitf85786a95860e88f6c37561ec5d15a9d8e338658 (patch)
tree2caff5b920f5d1db0183c82a9bd242003214a9e2
parent718a708fceafd05e5499ccbaf824ca22bd715707 (diff)
downloadchrome-ec-f85786a95860e88f6c37561ec5d15a9d8e338658.tar.gz
tpm_test: drbg_test: save the results in a list
Save the results in a list with their group and test case ids. We'll need all of this information to generate the response vectors for the lab. BUG=b:189376694 TEST=./tpmtest Change-Id: I9a43d8397baed30e527b213c8860a0ec740c5398 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2924403 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--test/tpm_test/drbg_test.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/test/tpm_test/drbg_test.py b/test/tpm_test/drbg_test.py
index ed03cb4053..e02da07bc3 100644
--- a/test/tpm_test/drbg_test.py
+++ b/test/tpm_test/drbg_test.py
@@ -87,19 +87,26 @@ def _drbg_gen_cmd(inp, outlen):
outlen.to_bytes(2, 'big')
-def drbg_test(tpm):
+def drbg_test_inputs(tpm, test_inputs):
"""Runs DRBG test case.
Args:
tpm: a tpm object used to communicate with the device
+ Returns:
+ a list of tuples with the generate responses (tgid, tcid, result_str)
+
Raises:
subcmd.TpmTestError: on unexpected target responses
"""
- for test in TEST_INPUTS:
+ tcid = 0
+ tgid = 0
+ test_results = []
+ for test in test_inputs:
drbg_op, drbg_params = test
if drbg_op == DRBG_GROUP_INIT:
+ tgid += 1
outlen = drbg_params
elif drbg_op == DRBG_INIT:
entropy, nonce, perso = drbg_params
@@ -122,10 +129,26 @@ def drbg_test(tpm):
cmd = _drbg_gen_cmd(a2b(inp), outlen)
response = tpm.command(tpm.wrap_ext_command(subcmd.DRBG_TEST, cmd))
if check_result:
+ tcid += 1
result = response[12:]
+ result_hexdump = utils.hex_dump(result)
if expected and a2b(expected) != result:
raise subcmd.TpmTestError('error:\nexpected %s'
'\nreceived %s' %
(utils.hex_dump(a2b(expected)),
- utils.hex_dump(result)))
+ result_hexdump))
+ result_str = ''.join(result_hexdump.split()).upper()
+ test_results.append((tgid, tcid, result_str))
print('%sSUCCESS: %s' % (utils.cursor_back(), 'DRBG test'))
+ return test_results
+
+def drbg_test(tpm):
+ """Runs DRBG test cases.
+
+ Args:
+ tpm: a tpm object used to communicate with the device
+
+ Raises:
+ subcmd.TpmTestError: on unexpected target responses
+ """
+ drbg_test_inputs(tpm, TEST_INPUTS)