.Net RNGCryptoServiceProvider 类与 Win32 CryptGenRandom() 函数
我有一个用 .Net 编写的新应用程序。我还有一个必须维护的应用程序旧版本(暂时),它是用 VB6 编写的并使用 C++ DLL。某些 C++ 本机 DLL 必须继续由新的 .Net 应用程序通过 P/Invoke 使用和共享。
旧版应用程序当前使用随机数生成器,该生成器将被替换为使用通过 Win32 API 提供的 CryptGenRandom() 函数。新的 .Net 应用程序具有相同的需求,并且可以利用 RNGCryptoServiceProvider 类。
问题: .Net RNGCryptoServiceProvider 类在幕后是否利用 Win32 CryptGenRandom() 函数?如果是这样,我会对与此相关的可用文档的任何链接感兴趣。
I have a new application being written in .Net. I also have a legacy version of the application that must be maintained (for the meantime), which has been written in VB6 and utilizes C++ DLLs. Certain C++ native DLLs must continue to be utilized and shared by the new .Net application via P/Invoke.
The legacy app currently utilizes a random number generator, which will be replaced to use CryptGenRandom() function available through Win32 APIs. The new .Net app has the same need and can utilize the RNGCryptoServiceProvider class.
Question:
Under the hood does the .Net RNGCryptoServiceProvider class utilize the Win32 CryptGenRandom() function? If so, I would be interested in any links on available documentation in regards to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,.Net
RNGCryptoServiceProvider
类从“加密服务提供商”(CSP) 获取随机数据(如 文档)。在CryptoAPI中,CSP是一个可加载的DLL,它提供一些加密服务,主要是私钥存储、签名计算......以及随机数生成。 CSP 仅在已(由 Microsoft)签名并注册(通过写入某些特定注册表项)后才能使用。CryptGenRandom() 函数使用默认 CSP(默认注册为使用的 CSP,通常是操作系统本身附带的 CSP 之一)并调用 CPGenRandom()< /code> 该 CSP 上的函数。
RNGCryptoServiceProvider
执行相同的操作。因此,它不调用CryptGenRandom()
,但它以相同的加密强源为基础。Actually, the .Net
RNGCryptoServiceProvider
class obtains random data from a "Cryptographic Service Provider" (CSP) (so says the documentation). In the CryptoAPI, a CSP is a loadable DLL which provides some cryptographic services, mainly private key storage, signature computations... and also random number generation. A CSP can be used only if it has been signed (by Microsoft) and registered (by writing in some specific registry keys).The
CryptGenRandom()
function uses the default CSP (the one registered as to be used by default, normally one of the CSP which come with the operating system itself) and invokes theCPGenRandom()
function on that CSP.RNGCryptoServiceProvider
does the same. Hence, it does not callCryptGenRandom()
, but it feeds on the same cryptographically strong source.