Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add user-level mu-api call for key derivation #2101

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
60 changes: 60 additions & 0 deletions include/tss2/tss2_mu.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,22 @@ 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 +736,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 +1688,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 @@ -1870,6 +1916,20 @@ Tss2_MU_TPMT_PUBLIC_PARMS_Unmarshal(
size_t *offset,
TPMT_PUBLIC_PARMS *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_TK_CREATION_Marshal(
TPMT_TK_CREATION 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
7 changes: 7 additions & 0 deletions lib/tss2-mu.def
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ EXPORTS
Tss2_MU_TPM2B_ENCRYPTED_SECRET_Unmarshal
Tss2_MU_TPM2B_ATTEST_Marshal
Tss2_MU_TPM2B_ATTEST_Unmarshal
Tss2_MU_TPM2B_LABEL_Marshal
Tss2_MU_TPM2B_MAX_BUFFER_Marshal
Tss2_MU_TPM2B_MAX_BUFFER_Unmarshal
Tss2_MU_TPM2B_MAX_CAP_BUFFER_Marshal
Expand All @@ -96,6 +97,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 All @@ -104,6 +107,7 @@ EXPORTS
Tss2_MU_TPMS_TIME_INFO_Unmarshal
Tss2_MU_TPMS_ECC_POINT_Marshal
Tss2_MU_TPMS_ECC_POINT_Unmarshal
Tss2_MU_TPMS_DERIVE_Marshal
Tss2_MU_TPMS_NV_PUBLIC_Marshal
Tss2_MU_TPMS_NV_PUBLIC_Unmarshal
Tss2_MU_TPMS_ALG_PROPERTY_Marshal
Expand Down Expand Up @@ -234,6 +238,7 @@ EXPORTS
Tss2_MU_TPMU_PUBLIC_PARMS_Unmarshal
Tss2_MU_TPMU_PUBLIC_ID_Marshal
Tss2_MU_TPMU_PUBLIC_ID_Unmarshal
Tss2_MU_TPMU_PUBLIC_ID_DERIVE_Marshal
Tss2_MU_TPMU_NAME_Marshal
Tss2_MU_TPMU_NAME_Unmarshal
Tss2_MU_TPMU_ENCRYPTED_SECRET_Marshal
Expand Down Expand Up @@ -264,6 +269,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
7 changes: 7 additions & 0 deletions lib/tss2-mu.map
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
Tss2_MU_TPM2B_ENCRYPTED_SECRET_Unmarshal;
Tss2_MU_TPM2B_ATTEST_Marshal;
Tss2_MU_TPM2B_ATTEST_Unmarshal;
Tss2_MU_TPM2B_LABEL_Marshal;
Tss2_MU_TPM2B_MAX_BUFFER_Marshal;
Tss2_MU_TPM2B_MAX_BUFFER_Unmarshal;
Tss2_MU_TPM2B_MAX_CAP_BUFFER_Marshal;
Expand All @@ -98,12 +99,15 @@
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;
Tss2_MU_TPMS_TIME_INFO_Unmarshal;
Tss2_MU_TPMS_ECC_POINT_Marshal;
Tss2_MU_TPMS_ECC_POINT_Unmarshal;
Tss2_MU_TPMS_DERIVE_Marshal;
Tss2_MU_TPMS_NV_PUBLIC_Marshal;
Tss2_MU_TPMS_NV_PUBLIC_Unmarshal;
Tss2_MU_TPMS_ALG_PROPERTY_Marshal;
Expand Down Expand Up @@ -234,6 +238,7 @@
Tss2_MU_TPMU_PUBLIC_PARMS_Unmarshal;
Tss2_MU_TPMU_PUBLIC_ID_Marshal;
Tss2_MU_TPMU_PUBLIC_ID_Unmarshal;
Tss2_MU_TPMU_PUBLIC_ID_DERIVE_Marshal;
Tss2_MU_TPMU_NAME_Marshal;
Tss2_MU_TPMU_NAME_Unmarshal;
Tss2_MU_TPMU_ENCRYPTED_SECRET_Marshal;
Expand Down Expand Up @@ -264,6 +269,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 @@ -347,6 +347,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(TPM2B_MAX_CAP_BUFFER);
TPM2B_UNMARSHAL(TPM2B_MAX_CAP_BUFFER, buffer);
TPM2B_MARSHAL_SUBTYPE(TPM2B_ECC_POINT, TPMS_ECC_POINT, point);
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
Loading