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

Add support to store FDO Credentials in the TPM #261

Merged
merged 12 commits into from
Mar 1, 2024

Conversation

shrikant1407
Copy link
Contributor

@shrikant1407 shrikant1407 commented Nov 13, 2023

Add support to store FDO Credentials in the TPM NV storage as per specs

@shrikant1407 shrikant1407 force-pushed the tpm-nv-store branch 4 times, most recently from b73a8c7 to 906307b Compare November 13, 2023 14:14
…NV storage

Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
@shrikant1407 shrikant1407 changed the title [WIP] Add support to store device credentials and device status inside TPM Add support to store device credentials and device status inside TPM Jan 12, 2024
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
@shrikant1407 shrikant1407 changed the title Add support to store device credentials and device status inside TPM Add support to store FDO Credentials in the TPM Jan 19, 2024
@shrikant1407 shrikant1407 marked this pull request as draft January 19, 2024 15:47
@shrikant1407 shrikant1407 marked this pull request as ready for review January 19, 2024 15:48
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
- Add TPM2_NV_WriteLock/TPM2_NV_ReadLock support
- Update readme for FDO TPM usage

Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
…r writes

Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
@KiranSukhavasi KiranSukhavasi merged commit e32ec0d into fido-device-onboard:master Mar 1, 2024
2 checks passed
if (BN_bn2bin(s, sig_s) <= 0) {
LOG(LOG_ERROR, "Sig s conversion Failed\n");
goto error;
}

*signature_length = sig_r_len + sig_s_len;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no check whether message_signature has enough space to store a total of sig_r_len + sig_s_len bytes - there is no validation of the buffer size . Maybe something like following check we can have
if (*signature_length > MAX_SIGNATURE_BUFFER_SIZE)


sealed_data_len =
PLATFORM_HMAC_SIZE + BLOB_CONTENT_SIZE + n_bytes;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibility of integer overflow in sealed_data_len whenever you do any arithmetic operation please make sure total length is not crossing integer boundary otherwise integer wrap around can happen. Please all the places

*/
write_context_len =
PLATFORM_HMAC_SIZE + BLOB_CONTENT_SIZE + n_bytes;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibility of integer overflow in write_context_len whenever you do any arithmetic operation please make sure total length is not crossing integer boundary otherwise integer wrap around can happen. Please all the places

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also try to make this function more modular. Dont write very big function as it difficult to read/ maintain as well as cyclomatic matrix is very high. Check all other place also

}

if (fdo_tpm_nvwrite(write_context, write_context_len, nv)) {
LOG(LOG_ERROR, "Failed to write in TPM NV!\n");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fdo_tpm_nvwrite operation has no check on returned length and no guarantee that full write has been performed without error

#else
size_t dev_cred_len =
fdo_blob_size((char *)FDO_CRED_NORMAL, FDO_SDK_NORMAL_DATA);
#endif
// Device has not yet been initialized.
// Since, Normal.blob is empty, the file size will be 0
if (dev_cred_len == 0) {
LOG(LOG_DEBUG,
LOG(LOG_INFO,
"DeviceCredential is empty. Set state to run DI\n");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is change to LOG_INFO as this might reveal extra info.. Please make sure if you are dealing with sensitive info like key, password please put log at LOG_DEBUG level. Check other places also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants