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

swtpm_setup: Comment flags for storage primary key and deprecate --cr… #945

Merged
merged 1 commit into from
Nov 7, 2024
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
12 changes: 11 additions & 1 deletion src/swtpm_setup/swtpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,8 @@ static int swtpm_tpm2_createprimary_ecc(struct swtpm *self, uint32_t primaryhand
static int swtpm_tpm2_createprimary_spk_ecc_nist_p384(struct swtpm *self,
uint32_t *curr_handle)
{
// keyflags: fixedTPM, fixedParent, sensitiveDataOrigin, userWithAuth
// noDA, restricted, decrypt
unsigned int keyflags = 0x00030472;
const unsigned char authpolicy[0] = { };
size_t authpolicy_len = sizeof(authpolicy);
Expand All @@ -1109,6 +1111,12 @@ static int swtpm_tpm2_createprimary_spk_ecc_nist_p384(struct swtpm *self,
size_t schemedata_len = sizeof(schemedata);
size_t off = 42;

/* per "TCG TPM v2.0 Provisioning Guidance v1.0" page 37
* -> "Ek Credential Profile 2.0" rev.14 section 2.1.5.2:
* template for NIST P256 uses 2 identical 32-byte all-zero nonces
* -> Use two 48-byte all-zero nonces for NIST P384.
*/

return swtpm_tpm2_createprimary_ecc(self, TPM2_RH_OWNER, keyflags, symkeydata, symkeydata_len,
authpolicy, authpolicy_len, schemedata, schemedata_len,
TPM2_ECC_NIST_P384, TPM2_ALG_SHA384,
Expand All @@ -1119,6 +1127,8 @@ static int swtpm_tpm2_createprimary_spk_ecc_nist_p384(struct swtpm *self,
static int swtpm_tpm2_createprimary_spk_rsa(struct swtpm *self, unsigned int rsa_keysize,
uint32_t *curr_handle)
{
// keyflags: fixedTPM, fixedParent, sensitiveDataOrigin, userWithAuth
// noDA, restricted, decrypt
unsigned int keyflags = 0x00030472;
const unsigned char authpolicy[0] = { };
size_t authpolicy_len = sizeof(authpolicy);
Expand All @@ -1143,7 +1153,7 @@ static int swtpm_tpm2_createprimary_spk_rsa(struct swtpm *self, unsigned int rsa
off, curr_handle, NULL, 0, NULL, NULL);
}

/* Create either an ECC or RSA storage primary key */
/* Create either an ECC or RSA storage primary key (deprecated) */
static int swtpm_tpm2_create_spk(struct swtpm *self, gboolean isecc, unsigned int rsa_keysize)
{
int ret;
Expand Down
2 changes: 1 addition & 1 deletion src/swtpm_setup/swtpm_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ static void usage(const char *prgname, const char *default_config_file)
"--create-platform-cert\n"
" : Create a platform certificate; this implies --create-ek-cert\n"
"\n"
"--create-spk : Create storage primary key; this requires --tpm2\n"
"--create-spk : Create storage primary key; this requires --tpm2; deprecated\n"
"\n"
"--lock-nvram : Lock NVRAM access\n"
"\n"
Expand Down