summaryrefslogtreecommitdiff
path: root/test/tpm_test
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2016-02-19 15:21:45 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-03-31 07:08:01 -0700
commit7aa42e2ba9a33530dd97bc5e814cd1b73d2cbb25 (patch)
tree78886f1b2d0b148a31e2471b4196fa7cd5858da9 /test/tpm_test
parent70378b86b4e5682b70a8145c9679e250280d6f14 (diff)
downloadchrome-ec-7aa42e2ba9a33530dd97bc5e814cd1b73d2cbb25.tar.gz
CR50: add NULL padding support for RSA encrypt/decrypt
NULL padding (aka vanilla RSA) support is required by the TPM2 test suite (referred to as TPM_ALG_NULL in the tpm2 source). BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=tests under test/tpm2 pass Change-Id: I9848fad3b44add05a04810ecd178fbad20ae92cc Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/328830 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Nagendra Modadugu <ngm@google.com>
Diffstat (limited to 'test/tpm_test')
-rw-r--r--test/tpm_test/rsa_test.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/tpm_test/rsa_test.py b/test/tpm_test/rsa_test.py
index 37ffbd2677..2a751d3ee7 100644
--- a/test/tpm_test/rsa_test.py
+++ b/test/tpm_test/rsa_test.py
@@ -26,7 +26,8 @@ _RSA_PADDING = {
'PKCS1-SSA': 0x14,
'PKCS1-ES': 0x15,
'PKCS1-PSS': 0x16,
- 'OAEP': 0x17
+ 'OAEP': 0x17,
+ 'NULL': 0x10,
}
@@ -110,6 +111,7 @@ _ENCRYPT_INPUTS = (
('OAEP', 'SHA256', 768),
('PKCS1-ES', 'NONE', 768),
('PKCS1-ES', 'NONE', 2048),
+ ('NULL', 'NONE', 768),
)
@@ -135,6 +137,14 @@ def _encrypt_tests(tpm):
key_len, ciphertext)
wrapped_response = tpm.command(tpm.wrap_ext_command(subcmd.RSA, cmd))
plaintext = tpm.unwrap_ext_response(subcmd.RSA, wrapped_response)
+ if padding == 'NULL':
+ # Check for leading zeros.
+ if reduce(lambda x, y: x | y,
+ map(ord, plaintext[:len(plaintext) - len(msg)])):
+ raise subcmd.TpmTestError('%s error:%s%s' % (
+ test_name, utils.hex_dump(msg), utils.hex_dump(plaintext)))
+ else:
+ plaintext = plaintext[len(plaintext) - len(msg):]
if msg != plaintext:
raise subcmd.TpmTestError('%s error:%s%s' % (
test_name, utils.hex_dump(msg), utils.hex_dump(plaintext)))