aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Pronin <apronin@chromium.org>2016-12-21 18:33:02 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-12-21 18:33:02 +0000
commit2ba96f18ca0bd9bea98b9935d9a4ac2f70f9433b (patch)
tree2d6048884195ca1156232290b71e80c62d8c670e
parent6c856e63621bddc00c1c8587b2e70b3c2da78e7c (diff)
parentabf58a352bcf12f34b77ace0772219f7dd0a1e32 (diff)
downloadtpm2-2ba96f18ca0bd9bea98b9935d9a4ac2f70f9433b.tar.gz
tpm2: add support for padding-only RSASSA am: 569c3c58dc am: be42694d9f am: acdff2ed61
am: abf58a352b Change-Id: I008be36f019c3cda402734f64e594a9b26bcaf1e
-rw-r--r--CpriRSA.c12
-rw-r--r--Implementation.h1
-rw-r--r--Sign.c6
-rw-r--r--tpm_generated.c4
4 files changed, 20 insertions, 3 deletions
diff --git a/CpriRSA.c b/CpriRSA.c
index a436716..c3f5d62 100644
--- a/CpriRSA.c
+++ b/CpriRSA.c
@@ -805,11 +805,19 @@ RSASSA_Encode(
INT32 fillSize;
pAssert(eOut != NULL && hIn != NULL);
// Can't use this scheme if the algorithm doesn't have a DER string defined.
- if(derSize == 0 )
+ if(
+#if defined(SUPPORT_PADDING_ONLY_RSASSA) && SUPPORT_PADDING_ONLY_RSASSA == YES
+ hashAlg != TPM_ALG_NULL &&
+#endif
+ derSize == 0)
return CRYPT_SCHEME;
// If the digest size of 'hashAl' doesn't match the input digest size, then
// the DER will misidentify the digest so return an error
- if((unsigned)_cpri__GetDigestSize(hashAlg) != hInSize)
+ if(
+#if defined(SUPPORT_PADDING_ONLY_RSASSA) && SUPPORT_PADDING_ONLY_RSASSA == YES
+ hashAlg != TPM_ALG_NULL &&
+#endif
+ (unsigned)_cpri__GetDigestSize(hashAlg) != hInSize)
return CRYPT_PARAMETER;
fillSize = eOutSize - derSize - hInSize - 3;
// Make sure that this combination will fit in the provided space
diff --git a/Implementation.h b/Implementation.h
index 755945e..0d12c45 100644
--- a/Implementation.h
+++ b/Implementation.h
@@ -357,6 +357,7 @@ typedef UINT16 TPM_ALG_ID;
#define ALG_SM4_VALUE 0x0013
#if defined ALG_RSASSA && ALG_RSASSA == YES
#define TPM_ALG_RSASSA (TPM_ALG_ID)(0x0014)
+#define SUPPORT_PADDING_ONLY_RSASSA YES
#endif
#define ALG_RSASSA_VALUE 0x0014
#if defined ALG_RSAES && ALG_RSAES == YES
diff --git a/Sign.c b/Sign.c
index f0e29f9..10b673b 100644
--- a/Sign.c
+++ b/Sign.c
@@ -63,7 +63,11 @@ TPM2_Sign(
// NOTE: this does not guarantee that the 'digest' is actually produced using
// the indicated hash algorithm, but at least it might be.
{
- if( in->digest.t.size
+ if(
+#if defined(SUPPORT_PADDING_ONLY_RSASSA) && SUPPORT_PADDING_ONLY_RSASSA == YES
+ in->inScheme.details.any.hashAlg != TPM_ALG_NULL &&
+#endif
+ in->digest.t.size
!= CryptGetHashDigestSize(in->inScheme.details.any.hashAlg))
return TPM_RC_SIZE + RC_Sign_digest;
}
diff --git a/tpm_generated.c b/tpm_generated.c
index b471be1..e3c72ab 100644
--- a/tpm_generated.c
+++ b/tpm_generated.c
@@ -2349,7 +2349,11 @@ UINT16 TPMS_SIG_SCHEME_RSASSA_Marshal(TPMS_SIG_SCHEME_RSASSA* source,
TPM_RC TPMS_SIG_SCHEME_RSASSA_Unmarshal(TPMS_SIG_SCHEME_RSASSA* target,
BYTE** buffer,
INT32* size) {
+#if defined(SUPPORT_PADDING_ONLY_RSASSA) && SUPPORT_PADDING_ONLY_RSASSA == YES
+ return TPMI_ALG_HASH_Unmarshal(&target->hashAlg, buffer, size, TRUE);
+#else
return TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);
+#endif
}
UINT16 TPMS_ENC_SCHEME_OAEP_Marshal(TPMS_ENC_SCHEME_OAEP* source,