diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-11-18 10:56:51 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-21 13:12:18 -0800 |
commit | afaaba44f13e7982e68b503123d48f912f3fd5eb (patch) | |
tree | 8c01fdeee0915cbf50dd75b4b95c912ea2a34a98 /test/tpm_test/ftdi_spi_tpm.h | |
parent | 32267c1094a1961ad8acd180f3220faed51794d0 (diff) | |
download | chrome-ec-afaaba44f13e7982e68b503123d48f912f3fd5eb.tar.gz |
cr50: Extended command test utility
The utility builds on the extended command protocol recently
introduced in the EC and allows to test implementation of various
cryptographic primitives available on CR50.
This patch brings in the ftdi_spi_tpm.c and mpsse.c from the AOSP
trunksd package. mpsse.c has been modified to limit its feature set
(no i2c or bigbang support, only SPI0 mode), and ftdit_spi_tpm.c has
been modified to properly present binary strings to the Python swig
wrapper.
The crypro_test.xml file includes descriptions of the tests to perform
on the target. Most of its contents other than the first crypto_test
element are borrowed from NIST AES test vectors set. See file header
for description of the contents format.
The actual test command is the tpmtest.py. When started it establishes
connection with the device, and then reads test vectors from
crypto_test.xml and executes them one at a time.
Starting the test program with the -d command line argument enables
debug output sent to the console.
There are some other programs in ./extras which use the mpsse.c from
AOSP, they will have to be modified to use the local copy.
BRANCH=none
BUG=chrome-os-partner:43025
TEST=ran the following in the directory:
$ make # output suppressed
$ ./tpmtest.py
Starting MPSSE at 800 kHz
Connected to device vid:did:rid of 1ae0:0028:00
\New max timeout: 1 s
SUCCESS: AES:ECB common
SUCCESS: AES:ECB128 1
SUCCESS: AES:ECB192 1
SUCCESS: AES:ECB256 1
SUCCESS: AES:ECB256 2
SUCCESS: AES:CTR128I 1
SUCCESS: AES:CTR256I 1
- temporarily corrupted the contents of the clear_text element of 'AES:ECB common':
$ ./tpmtest.py
Starting MPSSE at 800 kHz
Connected to device vid:did:rid of 1ae0:0028:00
|
Out text mismatch in node AES:ECB common, operation 1:
In text:
74 68 69 73 20 20 69 73 20 74 68 65 20 74 65 78
74 20 77 68 69 63 68 20 77 69 6c 6c 20 62 65 20
65 6e 63 72 79 70 74 65 64 20 69 66 20 65 76 65
72 79 74 68 69 6e 67 20 69 73 20 67 6f 69 6e 67
20 66 69 6e 65 2e 20
Expected out text:
3d e2 0f f9 ee d9 62 ce f0 8a 17 57 c6 04 86 d0
3d ec 44 72 d8 79 18 87 3f 31 81 6d 66 4c bb 10
da 8d e0 9f 63 67 b3 cc 64 b4 e8 bd 12 b0 a9 c9
09 6d f0 9f a4 e2 ae fb 0d fe 1c 90 6c e2 fe f0
68 8f b5 34 07 76 e2 a9 72 8e dd 7b 8b 52 2b 8b
Real out text:
f9 50 fe 93 c9 3f cb e5 9e e0 a4 7e 51 1a bb a0
36 2f d1 d6 5f a8 1d 22 5a 1a bb f7 e6 65 89 55
ad e8 f5 8f 1a 20 ff a5 c4 de 76 3e b8 ef cc 8d
9d 94 b8 89 22 1c c9 2a 43 58 c3 8c 75 9f 9f 56
ab 2f 89 1a f6 a0 36 8b 95 23 91 d6 23 47 77 36
Change-Id: I2687ac03236b528e71b92df7cb35606e473ab2c5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313443
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'test/tpm_test/ftdi_spi_tpm.h')
-rw-r--r-- | test/tpm_test/ftdi_spi_tpm.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/tpm_test/ftdi_spi_tpm.h b/test/tpm_test/ftdi_spi_tpm.h new file mode 100644 index 0000000000..5393d4cd86 --- /dev/null +++ b/test/tpm_test/ftdi_spi_tpm.h @@ -0,0 +1,25 @@ +/* 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. + */ + +#ifndef __EC_TEST_TPM_TEST_FTDI_SPI_TPM_H +#define __EC_TEST_TPM_TEST_FTDI_SPI_TPM_H + +#include "mpsse.h" + +/* + * This structure allows to convert string representation between C and + * Python. + */ +struct swig_string_data { + int size; + uint8_t *data; +}; + +int FtdiSpiInit(uint32_t freq, int enable_debug); +void FtdiStop(void); +struct swig_string_data FtdiSendCommandAndWait(char *tpm_command, + int command_size); + +#endif /* ! __EC_TEST_TPM_TEST_FTDI_SPI_TPM_H */ |