diff options
author | nagendra modadugu <ngm@google.com> | 2016-05-19 15:42:36 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-26 03:22:25 -0700 |
commit | 4c8359f4fa167461094595006da9299939e8d9cc (patch) | |
tree | fdeee7adb83c87b35413edaf8fd07d58ff83138d /test/tpm_test | |
parent | 798a50ca0eea00ae6ff2339783e14c6c9240bb84 (diff) | |
download | chrome-ec-4c8359f4fa167461094595006da9299939e8d9cc.tar.gz |
CR50: increment prime generation counter
The counter used for prime generation should be
incremented after each success / failure. Not doing
so results in duplicate primes being picked when
a label is explicitly specified.
BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
TEST=all tests in test/tpm_test/tpmtest.py pass
Change-Id: Ib2fd0e7fa6255b04946e6d2808e8c67a2199fb55
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/346056
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'test/tpm_test')
-rw-r--r-- | test/tpm_test/rsa_test.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/tpm_test/rsa_test.py b/test/tpm_test/rsa_test.py index 6ee474c579..d746fba47c 100644 --- a/test/tpm_test/rsa_test.py +++ b/test/tpm_test/rsa_test.py @@ -116,13 +116,13 @@ def _keytest_cmd(key_len): dl='', dig='') -def _keygen_cmd(key_len, e): +def _keygen_cmd(key_len, e, label): op = _RSA_OPCODES['KEYGEN'] padding = _RSA_PADDING['NONE'] hashing = _HASH['NONE'] return _RSA_CMD_FORMAT.format(o=op, p=padding, h=hashing, kl=struct.pack('>H', key_len), - ml=struct.pack('>H', 0), msg='', + ml=struct.pack('>H', len(label)), msg=label, dl=struct.pack('>H', 0), dig='') @@ -582,7 +582,8 @@ _KEYTEST_INPUTS = ( ) _KEYGEN_INPUTS = ( - (768, 65537), + (768, 65537, "rsa_test"), + (768, 65537, ''), ) @@ -659,9 +660,9 @@ def _keytest_tests(tpm): def _keygen_tests(tpm): for data in _KEYGEN_INPUTS: - key_len, e = data - test_name = 'RSA-KEYGEN:%d:%d' % data - cmd = _keygen_cmd(key_len, e) + key_len, e, label = data + test_name = 'RSA-KEYGEN:%d:%d:%s' % data + cmd = _keygen_cmd(key_len, e, label) wrapped_response = tpm.command(tpm.wrap_ext_command(subcmd.RSA, cmd)) result = tpm.unwrap_ext_response(subcmd.RSA, wrapped_response) @@ -679,6 +680,9 @@ def _keygen_tests(tpm): if not rsa.prime.is_prime(q): raise subcmd.TpmTestError('%s error:%s' % ( test_name, utils.hex_dump(result))) + if p == q: + raise subcmd.TpmTestError('%s error:%s' % ( + test_name, utils.hex_dump(result))) print('%sSUCCESS: %s' % (utils.cursor_back(), test_name)) |