mirror of
https://github.com/stefanberger/libtpms
synced 2025-12-31 11:12:04 +00:00
tpm2: Filter-out runtime-disabled algorithms
Filter-out runtime-disabled algorithms from being reported in TPM2_GetCapability and also don't run tests with runtime-disabled algorithms during self-test. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
96f5dc28fd
commit
ed27f21e60
@ -202,6 +202,9 @@ AlgorithmCapGetImplemented(
|
||||
// If algID is less than the starting algorithm ID, skip it
|
||||
if(s_algorithms[i].algID < algID)
|
||||
continue;
|
||||
if(!RuntimeAlgorithmCheckEnabled(&g_RuntimeProfile.RuntimeAlgorithm,// libtpms added begin
|
||||
s_algorithms[i].algID))
|
||||
continue; // libtpms added end
|
||||
if(algList->count < count)
|
||||
{
|
||||
// If we have not filled up the return list, add more algorithms
|
||||
@ -267,7 +270,10 @@ AlgorithmGetImplementedVector(
|
||||
// Go through the list of implemented algorithms and SET the corresponding bit in
|
||||
// in the implemented vector
|
||||
for(index = (sizeof(s_algorithms) / sizeof(s_algorithms[0])) - 1;
|
||||
index >= 0; index--)
|
||||
SET_BIT(s_algorithms[index].algID, *implemented);
|
||||
index >= 0; index--) { // libtpms changed
|
||||
if (RuntimeAlgorithmCheckEnabled(&g_RuntimeProfile.RuntimeAlgorithm, // libtpms added begin
|
||||
s_algorithms[index].algID))
|
||||
SET_BIT(s_algorithms[index].algID, *implemented);
|
||||
} // libtpms added end
|
||||
return;
|
||||
}
|
||||
|
||||
@ -232,6 +232,12 @@ static void TestSymmetricAlgorithm(const SYMMETRIC_TEST_VECTOR* test, //
|
||||
// libtpms added begin
|
||||
if (test->dataOut[mode - TPM_ALG_CTR] == NULL)
|
||||
return;
|
||||
/* Skip test cases whose algorithms or keysizes are runtime-disabled */
|
||||
if (!RuntimeAlgorithmKeySizeCheckEnabled(&g_RuntimeProfile.RuntimeAlgorithm,
|
||||
test->alg, test->keyBits,
|
||||
TPM_ECC_NONE,
|
||||
g_RuntimeProfile.stateFormatLevel))
|
||||
return;
|
||||
// libtpms added end
|
||||
|
||||
//
|
||||
|
||||
Loading…
Reference in New Issue
Block a user