Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/unit_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ static void test_TPM2_PCRSel(void)
TPM2_SetupPCRSelArray(&pcr, TPM_ALG_SHA384, pcrArray, 1);
pcrArray[0] = 4;
TPM2_SetupPCRSelArray(&pcr, TPM_ALG_SHA512, pcrArray, 1);
pcrArray[0] = 5;
TPM2_SetupPCRSelArray(&pcr, TPM_ALG_SHA3_256, pcrArray, 1);
pcrArray[0] = 6;
TPM2_SetupPCRSelArray(&pcr, TPM_ALG_SHA3_384, pcrArray, 1);
pcrArray[0] = 7;
TPM2_SetupPCRSelArray(&pcr, TPM_ALG_SHA3_512, pcrArray, 1);
if (pcr.count != HASH_COUNT) {
rc = BAD_FUNC_ARG;
}
Expand Down
5 changes: 5 additions & 0 deletions wolftpm/tpm2.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ typedef enum {
TPM_ALG_ECC = 0x0023,
TPM_ALG_SYMCIPHER = 0x0025,
TPM_ALG_CAMELLIA = 0x0026,
TPM_ALG_SHA3_256 = 0x0027,
TPM_ALG_SHA3_384 = 0x0028,
TPM_ALG_SHA3_512 = 0x0029,
TPM_ALG_SHAKE128 = 0x002A,
TPM_ALG_SHAKE256 = 0x002B,
TPM_ALG_CTR = 0x0040,
TPM_ALG_OFB = 0x0041,
TPM_ALG_CBC = 0x0042,
Expand Down
34 changes: 33 additions & 1 deletion wolftpm/tpm2_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,39 @@ typedef int64_t INT64;
#define MAX_CAP_HANDLES (MAX_CAP_DATA / sizeof(TPM_HANDLE))
#endif
#ifndef HASH_COUNT
#define HASH_COUNT (2) /* SHA1 and SHA256 */
/* Calculate hash count based on wolfCrypt enables */
#ifndef NO_SHA
#define HASH_COUNT_SHA1 1
#else
#define HASH_COUNT_SHA1 0
#endif

#ifndef NO_SHA256
#define HASH_COUNT_SHA256 1
#else
#define HASH_COUNT_SHA256 0
#endif

#ifdef WOLFSSL_SHA384
#define HASH_COUNT_SHA384 1
#else
#define HASH_COUNT_SHA384 0
#endif

#ifdef WOLFSSL_SHA512
#define HASH_COUNT_SHA512 1
#else
#define HASH_COUNT_SHA512 0
#endif

#ifdef WOLFSSL_SHA3
#define HASH_COUNT_SHA3 1
#else
#define HASH_COUNT_SHA3 0
#endif

#define HASH_COUNT (HASH_COUNT_SHA1 + HASH_COUNT_SHA256 + \
HASH_COUNT_SHA384 + HASH_COUNT_SHA512 + HASH_COUNT_SHA3)
#endif
#ifndef MAX_CAP_ALGS
#define MAX_CAP_ALGS (MAX_CAP_DATA / sizeof(TPMS_ALG_PROPERTY))
Expand Down