Files
OpenCellular/test/tpm_test/crypto_test.xml
Vadim Bendebury afaaba44f1 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>
2015-11-21 13:12:18 -08:00

113 lines
3.5 KiB
XML

<?xml version="1.0"?>
<!--
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.
This file describes test vectors for various encryption schemes.
Each description is encapsulated in a 'crypto_test' element. This element must
have the name property set. The name starts witht the encryption scheme's name
(say AES or DES), delimited by a colon, and followed by a three character
encryption submode, if necessary (say ECB for AES).
The rest of the attributes are self explanatory. The default format for the
clear_text element is ASCII, for the rest - hex. This default could be
overridded using the 'format' property.
The ascii strings are stripped of leading and trailing whitespace and then
joined using space as a separator. Whitespace in hes strings is ignored.
Hex values are interpreted as a set of 4 byte entities in network byte order.
Many of the crypto_test elements were borrowed from NIST test vectors.
-->
<crypto_tests>
<crypto_test name="AES:ECB common">
<clear_text>
this is the text which will be encrypted if everything is going fine.
</clear_text>
<key>0123456789abcdef0123456789abcdef0123456789abcdef</key>
<cipher_text>
<!--
Cipher text matches the case of the clear text padded with zeros to
the nearest block size.
-->
f90fe23d ce62d9ee 57178af0 d08604c6
7244ec3d 871879d8 6d81313f 10bb4c66
9fe08dda ccb36763 bde8b464 c9a9b012
9ff06d09 fbaee2a4 901cfe0d f0fee26c
34b58f68 a9e27607 7bdd8e72 8b2b528b
</cipher_text>
</crypto_test>
<crypto_test name="AES:ECB128 1">
<clear_text format="hex">
33221100 77665544 bbaa9988 ffeeddcc
</clear_text>
<key>03020100 07060504 0b0a0908 0f0e0d0c</key>
<cipher_text>
d8e0c469 30047b6a 80b7cdd8 5ac5b470
</cipher_text>
</crypto_test>
<crypto_test name="AES:ECB192 1">
<clear_text format="hex">
00000000 00000000 00000000 00000000
</clear_text>
<key>
6e0fd215 9f647ebc b1765bd9 badae607
948a7c96 297f7984
</key>
<cipher_text>
42184e8e 3d1a594e 76086f5b 94856ff1
</cipher_text>
</crypto_test>
<crypto_test name="AES:ECB256 1">
<clear_text format="hex">
00000000 00000000 00000000 00000000
</clear_text>
<key>
00000080 00000000 00000000 00000000
00000000 00000000 00000000 00000000
</key>
<cipher_text>
cb6d5ae3 a001b219 8afabc1e 59572ba2
</cipher_text>
</crypto_test>
<crypto_test name="AES:ECB256 2">
<clear_text format="hex">
45249ff6 179b4fdf 7b412bad 10376ce6
</clear_text>
<key>
10eb3d60 be71ca15 f0ae732b 81777d85
072c351f d708613b a310982d f4df1409
</key>
<cipher_text>
7a4b3023 fff3f939 8f8d7d06 c7ec249e
</cipher_text>
</crypto_test>
<crypto_test name="AES:CTR128I 1">
<clear_text format="hex">
e2bec16b 969f402e 117e3de9 2a179373
</clear_text>
<key>
16157e2b a6d2ae28 8815f7ab 3c4fcf09
</key>
<cipher_text>
91614d87 26e320b6 6468ef1b ceb60d99
</cipher_text>
<iv>f3f2f1f0 f7f6f5f4 fbfaf9f8 fffefdfc</iv>
</crypto_test>
<crypto_test name="AES:CTR256I 1">
<clear_text format="hex">
13c31e60 a5895777 04f5a7b7 28d2f3bb
</clear_text>
<key>
10eb3d60 be71ca15 f0ae732b 81777d85
072c351f d708613b a310982d f4df1409
</key>
<cipher_text>
e2bec16b 969f402e 117e3de9 2a179373
</cipher_text>
<iv>f3f2f1f0 f7f6f5f4 fbfaf9f8 fffefdfc</iv>
</crypto_test>
</crypto_tests>