Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit f09fc6c

Browse files
committed
tpm: Rename TPM2_OA_TMPL to TPM2_OA_NULL_KEY and make it local
Rename and document TPM2_OA_TMPL, as originally requested in the patch set review, but left unaddressed without any appropriate reasoning. The new name is TPM2_OA_NULL_KEY, has a documentation and is local only to tpm2-sessions.c. Link: https://lore.kernel.org/linux-integrity/ddbeb8111f48a8ddb0b8fca248dff6cc9d7079b2.camel@HansenPartnership.com/ Link: https://lore.kernel.org/linux-integrity/CZCKTWU6ZCC9.2UTEQPEVICYHL@suppilovahvero/ Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent f3d7ba9 commit f09fc6c

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

drivers/char/tpm/tpm2-sessions.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
/* maximum number of names the TPM must remember for authorization */
8181
#define AUTH_MAX_NAMES 3
8282

83+
#define AES_KEY_BYTES AES_KEYSIZE_128
84+
#define AES_KEY_BITS (AES_KEY_BYTES*8)
85+
8386
static int tpm2_create_primary(struct tpm_chip *chip, u32 hierarchy,
8487
u32 *handle, u8 *name);
8588

@@ -954,6 +957,20 @@ int tpm2_start_auth_session(struct tpm_chip *chip)
954957
}
955958
EXPORT_SYMBOL(tpm2_start_auth_session);
956959

960+
/*
961+
* A mask containing the object attributes for the kernel held null primary key
962+
* used in HMAC encryption. For more information on specific attributes look up
963+
* to "8.3 TPMA_OBJECT (Object Attributes)".
964+
*/
965+
#define TPM2_OA_NULL_KEY ( \
966+
TPM2_OA_NO_DA | \
967+
TPM2_OA_FIXED_TPM | \
968+
TPM2_OA_FIXED_PARENT | \
969+
TPM2_OA_SENSITIVE_DATA_ORIGIN | \
970+
TPM2_OA_USER_WITH_AUTH | \
971+
TPM2_OA_DECRYPT | \
972+
TPM2_OA_RESTRICTED)
973+
957974
/**
958975
* tpm2_parse_create_primary() - parse the data returned from TPM_CC_CREATE_PRIMARY
959976
*
@@ -1018,7 +1035,7 @@ static int tpm2_parse_create_primary(struct tpm_chip *chip, struct tpm_buf *buf,
10181035
val = tpm_buf_read_u32(buf, &offset_t);
10191036

10201037
/* object properties */
1021-
if (val != TPM2_OA_TMPL)
1038+
if (val != TPM2_OA_NULL_KEY)
10221039
return -EINVAL;
10231040

10241041
/* auth policy (empty) */
@@ -1178,7 +1195,7 @@ static int tpm2_create_primary(struct tpm_chip *chip, u32 hierarchy,
11781195
tpm_buf_append_u16(&template, TPM_ALG_SHA256);
11791196

11801197
/* object properties */
1181-
tpm_buf_append_u32(&template, TPM2_OA_TMPL);
1198+
tpm_buf_append_u32(&template, TPM2_OA_NULL_KEY);
11821199

11831200
/* sauth policy (empty) */
11841201
tpm_buf_append_u16(&template, 0);

include/linux/tpm.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -394,21 +394,6 @@ enum tpm2_object_attributes {
394394
TPM2_OA_SIGN = BIT(18),
395395
};
396396

397-
/*
398-
* definitions for the canonical template. These are mandated
399-
* by the TCG key template documents
400-
*/
401-
402-
#define AES_KEY_BYTES AES_KEYSIZE_128
403-
#define AES_KEY_BITS (AES_KEY_BYTES*8)
404-
#define TPM2_OA_TMPL (TPM2_OA_NO_DA | \
405-
TPM2_OA_FIXED_TPM | \
406-
TPM2_OA_FIXED_PARENT | \
407-
TPM2_OA_SENSITIVE_DATA_ORIGIN | \
408-
TPM2_OA_USER_WITH_AUTH | \
409-
TPM2_OA_DECRYPT | \
410-
TPM2_OA_RESTRICTED)
411-
412397
enum tpm2_session_attributes {
413398
TPM2_SA_CONTINUE_SESSION = BIT(0),
414399
TPM2_SA_AUDIT_EXCLUSIVE = BIT(1),

0 commit comments

Comments
 (0)