You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何提取UWP应用通过KeyCredentialManager生成的公钥?

Great question—let's break this down based on the Windows UWP security model and how KeyCredentialManager works:

Can you extract the public key?

For your own application

Absolutely. The UWP API explicitly allows your app to retrieve the public key associated with a KeyCredential you've created. Here's how:

After creating a key pair via KeyCredentialManager.RequestCreateAsync, you can use the RetrievePublicKeyAsync method on the resulting KeyCredential object to get the raw public key bytes. You can then process these bytes (like calculating their hash, as you mentioned) or store them as needed.

Example code snippet:

var createResult = await KeyCredentialManager.RequestCreateAsync("MyAppSecretKey", KeyCredentialCreationOption.ReplaceExisting);
if (createResult.Status == KeyCredentialStatus.Success)
{
    KeyCredential credential = createResult.Credential;
    IBuffer publicKeyBuffer = await credential.RetrievePublicKeyAsync();
    byte[] publicKeyBytes = publicKeyBuffer.ToArray();
    
    // Use the public key bytes here (e.g., compute hash, encrypt data)
}

Note that the private key remains locked in the TPM and cannot be exported—this is by design to maintain security.

For another application's public key

No, you cannot retrieve the public key of a KeyCredential owned by another application through legitimate means. Here's why:

  • The KeyCredential system enforces strict package identity isolation. Each app's key container is tied to its unique package SID (security identifier), and Windows blocks cross-app access to these containers at the system level.
  • Even with administrative privileges, you can't bypass this restriction. The TPM itself binds the key pair to the app's identity, so it will only allow the owning app to access the public key (and use the private key for operations like signing).

This isolation is exactly what makes the TPM-backed KeyCredential approach secure—applications can't snoop on each other's credential material.

内容的提问来源于stack exchange,提问作者Chris Berland

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:20:07