summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2015-12-17 10:32:11 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-17 15:46:39 -0800
commit6a29ca187a22012a984808d76caaa339c85c5616 (patch)
treed507f04f5375643b3ca13b88d1ec8e7938c5f1e2
parentf72decc80443af676f3e3174eaaa6d56fdf25494 (diff)
downloadchrome-ec-6a29ca187a22012a984808d76caaa339c85c5616.tar.gz
Refactor crypto subcommands into their own python module.
BRANCH=none TEST=tpmtest.py passes BUG=chrome-os-partner:43025,chrome-os-partner:47524 Signed-off-by: nagendra modadugu <ngm@google.com> Change-Id: I48f426176f17c57c723104d19c963b228f16d985 Reviewed-on: https://chromium-review.googlesource.com/318915 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--test/tpm_test/crypto_test.py6
-rw-r--r--test/tpm_test/hash_test.py5
-rw-r--r--test/tpm_test/subcmd.py10
3 files changed, 14 insertions, 7 deletions
diff --git a/test/tpm_test/crypto_test.py b/test/tpm_test/crypto_test.py
index 147b5f301b..7fa4ea6146 100644
--- a/test/tpm_test/crypto_test.py
+++ b/test/tpm_test/crypto_test.py
@@ -10,11 +10,9 @@ from __future__ import print_function
import struct
import xml.etree.ElementTree as ET
+import subcmd
import utils
-# Extension 'cryptography' subcommand codes:
-AES = 0
-
# Basic crypto operations
DECRYPT = 0
ENCRYPT = 1
@@ -99,7 +97,7 @@ class CryptoD(object):
self.submodes = submodes
SUPPORTED_MODES = {
- 'AES': CryptoD(AES, {
+ 'AES': CryptoD(subcmd.AES, {
'ECB': 0,
'CTR': 1,
'CBC': 2,
diff --git a/test/tpm_test/hash_test.py b/test/tpm_test/hash_test.py
index c1cdddbbe5..fd8d0f4184 100644
--- a/test/tpm_test/hash_test.py
+++ b/test/tpm_test/hash_test.py
@@ -10,10 +10,9 @@ from __future__ import print_function
import hashlib
import struct
+import subcmd
import utils
-HASH = 1
-
# Hash command modes
CMD_START = 0
CMD_CONT = 1
@@ -92,7 +91,7 @@ def hash_test(tpm):
cmd += '%c' % handle # Ignored for single shots
cmd += struct.pack('>H', len(text))
cmd += text
- wrapped_response = tpm.command(tpm.wrap_ext_command(HASH, cmd))
+ wrapped_response = tpm.command(tpm.wrap_ext_command(subcmd.HASH, cmd))
if hash_cmd in (CMD_START, CMD_CONT):
if hash_cmd == CMD_START:
contexts[handle] = hash_func()
diff --git a/test/tpm_test/subcmd.py b/test/tpm_test/subcmd.py
new file mode 100644
index 0000000000..dbfcadb1c5
--- /dev/null
+++ b/test/tpm_test/subcmd.py
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Subcommand codes that specify the crypto module."""
+
+# Keep these codes in sync with include/extension.h.
+AES = 0
+HASH = 1