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 <[email protected]>
  • Loading branch information
cplappert committed Nov 16, 2022
1 parent ca38f44 commit 84c1107
Show file tree
Hide file tree
Showing 8 changed files with 104 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 @@ -1686,6 +1715,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 @@ -1884,6 +1929,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 @@ -1760,6 +1760,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 @@ -1819,6 +1822,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
2 changes: 2 additions & 0 deletions lib/tss2-mu.def
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,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
2 changes: 2 additions & 0 deletions lib/tss2-mu.map
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,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
2 changes: 2 additions & 0 deletions src/tss2-mu/tpm2b-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ TPM2B_MARSHAL (TPM2B_OPERAND);
TPM2B_UNMARSHAL(TPM2B_OPERAND, buffer);
TPM2B_MARSHAL (TPM2B_TEMPLATE);
TPM2B_UNMARSHAL(TPM2B_TEMPLATE, buffer);
TPM2B_MARSHAL (TPM2B_LABEL);
TPM2B_UNMARSHAL(TPM2B_LABEL, buffer);
TPM2B_MARSHAL_SUBTYPE(TPM2B_ECC_POINT, TPMS_ECC_POINT, point);
TPM2B_UNMARSHAL_SUBTYPE(TPM2B_ECC_POINT, TPMS_ECC_POINT, point);
TPM2B_MARSHAL_SUBTYPE(TPM2B_NV_PUBLIC, TPMS_NV_PUBLIC, nvPublic);
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 @@ -1119,6 +1119,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 @@ -588,6 +588,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 @@ -630,6 +630,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 84c1107

Please sign in to comment.