Skip to content

Conversation

@carolinecreamer
Copy link
Contributor

@carolinecreamer carolinecreamer commented Nov 17, 2025

Add VBS-Protected Key Attestation Sample.

{
cout << "Creating VBS NCrypt (Key Guard) key...";

wil::unique_ncrypt_key key_guard_key = create_key(MS_KEY_STORAGE_PROVIDER, nullptr, NCRYPT_OVERWRITE_KEY_FLAG | NCRYPT_USE_VIRTUAL_ISOLATION_FLAG);
Copy link
Collaborator

Choose a reason for hiding this comment

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

NCRYPT_OVERWRITE_KEY_FLAG should not be required as the key is ephemeral (name = nullptr).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping NCRYPT_OVERWRITE_KEY_FLAG because key is no longer ephemeral.

}

return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should have a comment explaining what the report will contain, similar to the comment on sample_tpm_key_att.cpp.

@carolinecreamer carolinecreamer changed the title Add VBS NCrypt (Key Guard) Key Attestation Sample. Add VBS-Protected Key Attestation Sample. Nov 25, 2025
// These properties are described in the NCrypt library documentation (https://learn.microsoft.com/en-us/windows/win32/api/ncrypt/nf-ncrypt-ncryptverifyclaim#protectingattesting-private-keys-using-virtualization-based-security-vbs).
// A relying party (RP) should validate several important fields inside "vbs_ncrypt.vbs_trustlet_report" to ensure the key was generated and protected inside a trusted VBS-protected environment:
//
// trustlet_identity - Identifies the VBS trustlet that created or protects the key. The RP should compare this value against an expected trustlet identity to ensure the key originates from a trusted environment.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I should remove descriptions, like for enclave descriptions, let me know. Added descriptions since documentation is limited right now, but I'm assuming that these values will all be properly documented once VBS-protected keys GA

try
{
auto tpm_aik = load_tpm_key(AIK_NAME, true);
auto vbs_protected_key = create_vbs_protected_key(L"att_sample_vbs_key", false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used "att_sample_vbs_key" to distinguish from the key in the tpm key attestation sample, but I wanted to not make the name such a mouthful ("att_sample_vbs_protected_key"). If I should change the name for correctness, let me know.

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.

2 participants