diff --git a/src/tpm2/RuntimeAlgorithm.c b/src/tpm2/RuntimeAlgorithm.c index 5e9d934c..3d326cd2 100644 --- a/src/tpm2/RuntimeAlgorithm.c +++ b/src/tpm2/RuntimeAlgorithm.c @@ -118,7 +118,7 @@ static const struct { { .name = ENABLED ? NAME : NULL, .canBeDisabled = CANDISABLE, .stateFormatLevel = SFL } [TPM_ALG_RSA] = ASYMMETRIC(ALG_RSA, "rsa", s_KeySizesRSA, false, 1), - [TPM_ALG_TDES] = SYMMETRIC(ALG_TDES, "tdes", s_KeySizesTDES, false, 1), + [TPM_ALG_TDES] = SYMMETRIC(ALG_TDES, "tdes", s_KeySizesTDES, true, 1), [TPM_ALG_SHA1] = HASH(ALG_SHA1, "sha1", false, 1), [TPM_ALG_HMAC] = SIGNING(ALG_HMAC, "hmac", false, 1), [TPM_ALG_AES] = SYMMETRIC(ALG_AES, "aes", s_KeySizesAES, false, 1), // never disable: context encryption diff --git a/src/tpm2/Unmarshal.c b/src/tpm2/Unmarshal.c index 5b2fa2ea..03236c5f 100644 --- a/src/tpm2/Unmarshal.c +++ b/src/tpm2/Unmarshal.c @@ -2757,12 +2757,21 @@ TPMI_TDES_KEY_BITS_Unmarshal(TPMI_SM4_KEY_BITS *target, BYTE **buffer, INT32 *si switch (*target) { case 128: case 192: + if (!RuntimeAlgorithmKeySizeCheckEnabled(&g_RuntimeProfile.RuntimeAlgorithm,// libtpms added begin + TPM_ALG_TDES, + *target, + TPM_ECC_NONE, + g_RuntimeProfile.stateFormatLevel)) { + rc = TPM_RC_VALUE; + } // libtpms added end break; default: rc = TPM_RC_VALUE; - *target = orig_target; // libtpms added } } + if (rc != TPM_RC_SUCCESS) { // libtpms added begin + *target = orig_target; + } // libtpms added end return rc; } #endif // libtpms added end