Skip to content

Commit

Permalink
Add user-level mu-api call for key derivation
Browse files Browse the repository at this point in the history
This commit introduces a new user-level mu-api call
(Tss2_MU_TPMT_PUBLIC_DERIVE_Marshal) that allows to
create a Derived Object with the command TPM2_CreateLoaded.

Signed-off-by: Christian Plappert <christian.plappert@sit.fraunhofer.de>
  • Loading branch information
cplappert committed Jul 3, 2024
1 parent 4e2fe02 commit 8dfb06e
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 0 deletions.
59 changes: 59 additions & 0 deletions include/tss2/tss2_mu.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,21 @@ Tss2_MU_TPM2B_ECC_POINT_Unmarshal(
size_t *offset,
TPM2B_ECC_POINT *dest);

TSS2_RC
Tss2_MU_TPM2B_LABEL_Marshal(
TPM2B_LABEL const *src,
uint8_t buffer[],
size_t buffer_size,
size_t *offset);

TSS2_RC
Tss2_MU_TPM2B_LABEL_Unmarshal(
uint8_t const buffer[],
size_t buffer_size,
size_t *offset,
TPM2B_LABEL *dest);


TSS2_RC
Tss2_MU_TPM2B_NV_PUBLIC_Marshal(
TPM2B_NV_PUBLIC const *src,
Expand Down Expand Up @@ -720,6 +735,20 @@ Tss2_MU_TPMS_ECC_POINT_Unmarshal(
size_t *offset,
TPMS_ECC_POINT *dest);

TSS2_RC
Tss2_MU_TPMS_DERIVE_Marshal(
TPMS_DERIVE const *src,
uint8_t buffer[],
size_t buffer_size,
size_t *offset);

TSS2_RC
Tss2_MU_TPMS_DERIVE_Unmarshal(
uint8_t const buffer[],
size_t buffer_size,
size_t *offset,
TPMS_DERIVE *dest);

TSS2_RC
Tss2_MU_TPMS_NV_PUBLIC_Marshal(
TPMS_NV_PUBLIC const *src,
Expand Down Expand Up @@ -1658,6 +1687,22 @@ Tss2_MU_TPMU_PUBLIC_ID_Unmarshal(
uint32_t selector_value,
TPMU_PUBLIC_ID *dest);

TSS2_RC
Tss2_MU_TPMU_PUBLIC_ID_DERIVE_Marshal(
TPMU_PUBLIC_ID_DERIVE const *src,
uint32_t selector_value,
uint8_t buffer[],
size_t buffer_size,
size_t *offset);

TSS2_RC
Tss2_MU_TPMU_PUBLIC_ID_DERIVE_Unmarshal(
uint8_t const buffer[],
size_t buffer_size,
size_t *offset,
uint32_t selector_value,
TPMU_PUBLIC_ID_DERIVE *dest);

TSS2_RC
Tss2_MU_TPMU_NAME_Marshal(
TPMU_NAME const *src,
Expand Down Expand Up @@ -1856,6 +1901,20 @@ Tss2_MU_TPMT_PUBLIC_Unmarshal(
size_t *offset,
TPMT_PUBLIC *dest);

TSS2_RC
Tss2_MU_TPMT_PUBLIC_DERIVE_Marshal(
TPMT_PUBLIC const *src,
uint8_t buffer[],
size_t buffer_size,
size_t *offset);

TSS2_RC
Tss2_MU_TPMT_PUBLIC_DERIVE_Unmarshal(
uint8_t const buffer[],
size_t buffer_size,
size_t *offset,
TPMT_PUBLIC *dest);

TSS2_RC
Tss2_MU_TPMT_PUBLIC_PARMS_Marshal(
TPMT_PUBLIC_PARMS const *src,
Expand Down
6 changes: 6 additions & 0 deletions include/tss2/tss2_tpm2_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,9 @@ union TPMU_PUBLIC_ID {
TPMS_DERIVE derive;
};

/* Definition of TPMU_PUBLIC_ID_DERIVE Union <INOUT S> */
typedef union TPMU_PUBLIC_ID TPMU_PUBLIC_ID_DERIVE;

/* Definition of TPMS_KEYEDHASH_PARMS Structure */
typedef struct TPMS_KEYEDHASH_PARMS TPMS_KEYEDHASH_PARMS;
struct TPMS_KEYEDHASH_PARMS {
Expand Down Expand Up @@ -1830,6 +1833,9 @@ struct TPMT_PUBLIC {
TPMU_PUBLIC_ID unique; /* the unique identifier of the structure. For an asymmetric key this would be the public key. */
};

/* Definition of TPMT_PUBLIC_DERIVE Structure */
typedef struct TPMT_PUBLIC TPMT_PUBLIC_DERIVE;

/* Definition of TPM2B_PUBLIC Structure */
typedef struct TPM2B_PUBLIC TPM2B_PUBLIC;
struct TPM2B_PUBLIC {
Expand Down
4 changes: 4 additions & 0 deletions lib/tss2-mu.def
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ EXPORTS
Tss2_MU_TPM2B_OPERAND_Unmarshal
Tss2_MU_TPM2B_TEMPLATE_Marshal
Tss2_MU_TPM2B_TEMPLATE_Unmarshal
Tss2_MU_TPM2B_LABEL_Marshal
Tss2_MU_TPM2B_LABEL_Unmarshal
Tss2_MU_TPM2B_TIMEOUT_Marshal
Tss2_MU_TPM2B_TIMEOUT_Unmarshal
Tss2_MU_TPMS_CONTEXT_Marshal
Expand Down Expand Up @@ -264,6 +266,8 @@ EXPORTS
Tss2_MU_TPMT_SENSITIVE_Unmarshal
Tss2_MU_TPMT_PUBLIC_Marshal
Tss2_MU_TPMT_PUBLIC_Unmarshal
Tss2_MU_TPMT_PUBLIC_DERIVE_Marshal
Tss2_MU_TPMT_PUBLIC_DERIVE_Unmarshal
Tss2_MU_TPMT_PUBLIC_PARMS_Marshal
Tss2_MU_TPMT_PUBLIC_PARMS_Unmarshal
Tss2_MU_TPMT_TK_CREATION_Marshal
Expand Down
4 changes: 4 additions & 0 deletions lib/tss2-mu.map
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
Tss2_MU_TPM2B_TIMEOUT_Unmarshal;
Tss2_MU_TPM2B_TEMPLATE_Marshal;
Tss2_MU_TPM2B_TEMPLATE_Unmarshal;
Tss2_MU_TPM2B_LABEL_Marshal;
Tss2_MU_TPM2B_LABEL_Unmarshal;
Tss2_MU_TPMS_CONTEXT_Marshal;
Tss2_MU_TPMS_CONTEXT_Unmarshal;
Tss2_MU_TPMS_TIME_INFO_Marshal;
Expand Down Expand Up @@ -264,6 +266,8 @@
Tss2_MU_TPMT_SENSITIVE_Unmarshal;
Tss2_MU_TPMT_PUBLIC_Marshal;
Tss2_MU_TPMT_PUBLIC_Unmarshal;
Tss2_MU_TPMT_PUBLIC_DERIVE_Marshal;
Tss2_MU_TPMT_PUBLIC_DERIVE_Unmarshal;
Tss2_MU_TPMT_PUBLIC_PARMS_Marshal;
Tss2_MU_TPMT_PUBLIC_PARMS_Unmarshal;
Tss2_MU_TPMT_TK_CREATION_Marshal;
Expand Down
8 changes: 8 additions & 0 deletions src/tss2-mu/tpms-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,14 @@ TPMS_UNMARSHAL_2(TPMS_ECC_POINT,
x, Tss2_MU_TPM2B_ECC_PARAMETER_Unmarshal,
y, Tss2_MU_TPM2B_ECC_PARAMETER_Unmarshal)

TPMS_MARSHAL_2(TPMS_DERIVE,
label, ADDR, Tss2_MU_TPM2B_LABEL_Marshal,
context, ADDR, Tss2_MU_TPM2B_LABEL_Marshal)

TPMS_UNMARSHAL_2(TPMS_DERIVE,
label, Tss2_MU_TPM2B_LABEL_Unmarshal,
context, Tss2_MU_TPM2B_LABEL_Unmarshal)

TPMS_MARSHAL_2(TPMS_SIGNATURE_RSA,
hash, VAL, Tss2_MU_UINT16_Marshal,
sig, ADDR, Tss2_MU_TPM2B_PUBLIC_KEY_RSA_Marshal)
Expand Down
14 changes: 14 additions & 0 deletions src/tss2-mu/tpmt-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,20 @@ TPMT_UNMARSHAL_6(TPMT_PUBLIC, type, Tss2_MU_UINT16_Unmarshal,
parameters, type, Tss2_MU_TPMU_PUBLIC_PARMS_Unmarshal,
unique, type, Tss2_MU_TPMU_PUBLIC_ID_Unmarshal)

TPMT_MARSHAL_6(TPMT_PUBLIC_DERIVE, type, VAL, Tss2_MU_UINT16_Marshal,
nameAlg, VAL, Tss2_MU_UINT16_Marshal,
objectAttributes, VAL, Tss2_MU_TPMA_OBJECT_Marshal,
authPolicy, ADDR, Tss2_MU_TPM2B_DIGEST_Marshal,
parameters, ADDR, type, Tss2_MU_TPMU_PUBLIC_PARMS_Marshal,
unique, ADDR, type, Tss2_MU_TPMU_PUBLIC_ID_DERIVE_Marshal)

TPMT_UNMARSHAL_6(TPMT_PUBLIC_DERIVE, type, Tss2_MU_UINT16_Unmarshal,
nameAlg, Tss2_MU_UINT16_Unmarshal,
objectAttributes, Tss2_MU_TPMA_OBJECT_Unmarshal,
authPolicy, Tss2_MU_TPM2B_DIGEST_Unmarshal,
parameters, type, Tss2_MU_TPMU_PUBLIC_PARMS_Unmarshal,
unique, type, Tss2_MU_TPMU_PUBLIC_ID_DERIVE_Unmarshal)

TPMT_MARSHAL_2(TPMT_PUBLIC_PARMS, type, VAL, Tss2_MU_UINT16_Marshal,
parameters, ADDR, type, Tss2_MU_TPMU_PUBLIC_PARMS_Marshal)

Expand Down
11 changes: 11 additions & 0 deletions src/tss2-mu/tpmu-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,17 @@ TPMU_UNMARSHAL2(TPMU_PUBLIC_ID,
TPM2_ALG_RSA, rsa, Tss2_MU_TPM2B_PUBLIC_KEY_RSA_Unmarshal,
TPM2_ALG_ECC, ecc, Tss2_MU_TPMS_ECC_POINT_Unmarshal)

TPMU_MARSHAL2(TPMU_PUBLIC_ID_DERIVE,
TPM2_ALG_KEYEDHASH, ADDR, derive, Tss2_MU_TPMS_DERIVE_Marshal,
TPM2_ALG_SYMCIPHER, ADDR, sym, Tss2_MU_TPM2B_DIGEST_Marshal,
TPM2_ALG_RSA, ADDR, rsa, Tss2_MU_TPM2B_PUBLIC_KEY_RSA_Marshal,
TPM2_ALG_ECC, ADDR, ecc, Tss2_MU_TPMS_ECC_POINT_Marshal)
TPMU_UNMARSHAL2(TPMU_PUBLIC_ID_DERIVE,
TPM2_ALG_KEYEDHASH, derive, Tss2_MU_TPMS_DERIVE_Unmarshal,
TPM2_ALG_SYMCIPHER, sym, Tss2_MU_TPM2B_DIGEST_Unmarshal,
TPM2_ALG_RSA, rsa, Tss2_MU_TPM2B_PUBLIC_KEY_RSA_Unmarshal,
TPM2_ALG_ECC, ecc, Tss2_MU_TPMS_ECC_POINT_Unmarshal)

TPMU_MARSHAL2(TPMU_PUBLIC_PARMS,
TPM2_ALG_KEYEDHASH, ADDR, keyedHashDetail, Tss2_MU_TPMS_KEYEDHASH_PARMS_Marshal,
TPM2_ALG_SYMCIPHER, ADDR, symDetail, Tss2_MU_TPMS_SYMCIPHER_PARMS_Marshal,
Expand Down

0 comments on commit 8dfb06e

Please sign in to comment.