简体   繁体   English

如何从桌面应用解密Windows Store DPAPI保护的数据

[英]How to decrypt Windows Store DPAPI protected data from desktop app

We are writing a tool to migrate data from a Windows Store application to a Windows Desktop one. 我们正在编写一种工具,用于将数据从Windows应用商店应用迁移到Windows桌面应用。 The store app protects some data using DPAPI which we need to be able to decrypt from the desktop application. 商店应用程序使用DPAPI保护了一些数据,我们需要能够从桌面应用程序解密这些数据。

When calling ProtectedData.Unprotect method we are getting a CryptographicException stating "the parameter is invalid". 当调用ProtectedData.Unprotect方法时,我们得到一个CryptographicException声明“参数无效”。 Looking at the store application code I can see that the DPAPI API is different from the desktop .NET framework. 查看商店应用程序代码,我可以看到DPAPI API与桌面.NET框架不同。 The store app API is used as follows: 商店应用API的使用方式如下:

provider = new DataProtectionProvider("LOCAL=user");
...
IBuffer origBuffer = await this.provider.UnprotectAsync(encryptedBuffer);

The desktop API looks like the following 桌面API如下所示

byte[] ProtectedData.Unprotect(byte[] encryptedBytes, 
                               byte[] entropy, 
                               DataProtectionScope scope);

We have tried to use DataProtectionScope.CurrentUser and entropy null but this results in the above CryptographicException. 我们尝试使用DataProtectionScope.CurrentUser和entropy null但这会导致上述CryptographicException。 At a guess, internally, the store API uses a specific entropy without which we cannot decrypt the data. 可以猜测,在内部,商店API使用特定的熵,否则我们无法解密数据。

Does anyone know what the store DPAPI API is doing behind the scenes that would allow us to decrypt the store data? 有谁知道商店DPAPI API在后台进行的操作使我们可以解密商店数据?

Sorry to not have a direct answer but can't you reference the WinRT API from your desktop application in order to decrypt this secured bytes ? 抱歉,没有直接答案,但是您不能从桌面应用程序引用WinRT API来解密此安全字节吗?

Here is a guide to reference the WinRT API in a WPF application : http://www.hanselman.com/blog/HowToCallWinRTAPIsInWindows8FromCDesktopApplicationsWinRTDiagram.aspx 这是在WPF应用程序中引用WinRT API的指南: http : //www.hanselman.com/blog/HowToCallWinRTAPIsInWindows8FromCDesktopApplicationsWinRTDiagram.aspx

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM