I want to store and retrieve a password with Windows Hello
. The user can choose at login time if he wants to input his password manually, or if he wants to use Windows Hello
to unlock (which then retrieves the last used password, and fills it in for the user).
If Windows Hello
is setup correctly there are two use cases in the doc.
One to just unlock:
UserConsentVerificationResult consentResult = await UserConsentVerifier.RequestVerificationAsync("userMessage");
if (consentResult.Equals(UserConsentVerificationResult.Verified))
{
// continue
}
and one to sign a message from the server:
var openKeyResult = await KeyCredentialManager.OpenAsync(AccountId);
if (openKeyResult.Status == KeyCredentialStatus.Success)
{
var userKey = openKeyResult.Credential;
var publicKey = userKey.RetrievePublicKey();
//the message is the challenge from the server
var signResult = await userKey.RequestSignAsync(message);
if (signResult.Status == KeyCredentialStatus.Success)
{
//the with the private key of the user signed message
return signResult.Result;
}
}
Both is not very useful for my use-case: I want a symmetric way to store and retrieve the password.
My question in short:
Is there a way to symmetrically store data with Windows Hello
?
relevant docs:
https://learn.microsoft.com/en-us/windows/uwp/security/microsoft-passport
I have solved this problem by encrypting / decrypting the secret I wanted to store using a password generated with Windows Hello. The password was a signature over a fixed message.
A complete code example (untested) to illustrate my point:
The full source is on github, and shows how I have integrated these concepts into the application.
However, this abuses cryptographic primitives intended for different purposes, which is very dangerous. Consider looking for a more sound approach before resorting to this workaround.
Concrete caveats:
key = sha256(signature);