summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-11-27 07:31:57 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-01 22:36:59 -0800
commitc9e0e4d5789992902844c31805f1cb4553b557a1 (patch)
treee0ddb6286c716a2367ff0afbc5a1966cd2f3fa5d
parentca6e4836a6e9cfaac1a99d3c4166f8dd656ac9db (diff)
downloadchrome-ec-c9e0e4d5789992902844c31805f1cb4553b557a1.tar.gz
cr50: test: extended command code does not have to be passed as argument
The extended command code is fixed, there is no need to pass it as a parameter when calling functions wrapping and unwrapping extended commands. BRANCH=none BUG=chrome-os-partner:43025 TEST=AES tests still pass: $ ./test/tpm_test/tpmtest.py Starting MPSSE at 800 kHz Connected to device vid:did:rid of 1ae0:0028:00 SUCCESS: AES:ECB common SUCCESS: AES:ECB128 1 SUCCESS: AES:ECB192 1 SUCCESS: AES:ECB256 1 SUCCESS: AES:ECB256 2 SUCCESS: AES:CTR128I 1 -New max timeout: 1 s SUCCESS: AES:CTR256I 1 Change-Id: Ic0c9d7983755de8380b57e841891fd638ef2c62a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314690 Reviewed-by: Nagendra Modadugu <ngm@google.com>
-rwxr-xr-xtest/tpm_test/tpmtest.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/test/tpm_test/tpmtest.py b/test/tpm_test/tpmtest.py
index c2056c01c7..5117f2b1ad 100755
--- a/test/tpm_test/tpmtest.py
+++ b/test/tpm_test/tpmtest.py
@@ -95,12 +95,12 @@ class TPM(object):
self.validate(response, response_mode=True)
return response
- def wrap_ext_command(self, cmd_code, subcmd_code, cmd_body):
+ def wrap_ext_command(self, subcmd_code, cmd_body):
return struct.pack(self.HEADER_FMT, 0x8001,
len(cmd_body) + struct.calcsize(self.HEADER_FMT),
- cmd_code, subcmd_code) + cmd_body
+ EXT_CMD, subcmd_code) + cmd_body
- def unwrap_ext_response(self, expected_cmd, expected_subcmd, response):
+ def unwrap_ext_response(self, expected_subcmd, response):
"""Verify basic validity and strip off TPM extended command header.
Get the response generated by the device, as it came off the wire, verify
@@ -108,8 +108,6 @@ class TPM(object):
command header and return the payload to the caller.
Args:
- expected_cmd: an int, up to 32 bits, expected value in the
- command/response field of the header. expected_subcmd, response
expected_subcmd: an int, up to 16 bits in size, the extension command
this response is supposed to be for.
response: a binary string, the actual response received over the wire.
@@ -124,7 +122,7 @@ class TPM(object):
response[:header_size])
if tag != 0x8001:
raise TpmError('Wrong response tag: %4.4x' % tag)
- if cmd != expected_cmd:
+ if cmd != EXT_CMD:
raise TpmError('Unexpected response command field: %8.8x' % cmd)
if subcmd != expected_subcmd:
raise TpmError('Unexpected response subcommand field: %2.2x' %
@@ -288,10 +286,8 @@ def crypto_run(node_name, op_type, key, iv, in_text, out_text, tpm, debug_mode):
cmd += in_text
if debug_mode:
print('%d:%d cmd size' % (op_type, mode.subcmd), len(cmd), hex_dump(cmd))
- wrapped_response = tpm.command(tpm.wrap_ext_command(
- EXT_CMD, mode.subcmd, cmd))
- real_out_text = tpm.unwrap_ext_response(
- EXT_CMD, mode.subcmd, wrapped_response)
+ wrapped_response = tpm.command(tpm.wrap_ext_command(mode.subcmd, cmd))
+ real_out_text = tpm.unwrap_ext_response(mode.subcmd, wrapped_response)
if out_text:
if len(real_out_text) > len(out_text):
real_out_text = real_out_text[:len(out_text)] # Ignore padding