DPAPI 会自动执行 Dynamic Salt 吗?

Does DPAPI automatically do Dynamic Salt?

我正在考虑使用 Windows' 数据保护 API (DPAPI) 来加密一些数据。我的一个要求是在加密值时使用动态盐。

我通过测试注意到,如果我多次加密同一个字符串,我会得到不同的结果。这是使用相同的字符串、空熵值和相同的范围。

这让我感觉好像已经包含了动态盐。我没有看到任何说明这一点的文档。

这是我调用的方法https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.protecteddata.protect?view=netframework-4.7.2 .

DPAPI 是否已经处理动态加盐?如果不是,是什么导致加密值每次都改变?

The MasterKey, however, is not used explicitly to protect the data. Instead, a symmetric session key is generated based on the MasterKey, some random data, and any additional entropy, if an application chooses to supply it. It is this session key that is used to protect the data.

[...]

The session key is never stored. Instead, DPAPI stores the random data it used to generate the key in the opaque data BLOB. When the data BLOB is passed back in to DPAPI, the random data is used to re-derive the key and unprotect the data.

https://msdn.microsoft.com/en-us/library/ms995355.aspx

加密数据中包含的随机数据充当盐。

optionalEntropy 参数的目的是允许单个应用程序保护自己免受同一用户帐户下的其他应用程序 运行 的影响,并且不需要提高已经执行的加盐的有效性。