<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Cryptography_API%3A_Next_Generation</id>
	<title>Cryptography API: Next Generation - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Cryptography_API%3A_Next_Generation"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Cryptography_API:_Next_Generation&amp;action=history"/>
	<updated>2026-06-27T08:37:37Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=Cryptography_API:_Next_Generation&amp;diff=3464535&amp;oldid=prev</id>
		<title>imported&gt;InternetArchiveBot：​补救6个来源，并将0个来源标记为失效。) #IABot (v2.0.8</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Cryptography_API:_Next_Generation&amp;diff=3464535&amp;oldid=prev"/>
		<updated>2021-02-05T15:21:59Z</updated>

		<summary type="html">&lt;p&gt;补救6个来源，并将0个来源标记为失效。) #IABot (v2.0.8&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{noteTA|G1=IT}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;下一代密码学API&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Cryptography API: Next Generation， CNG&amp;#039;&amp;#039;&amp;#039;) 是[[微軟]]从[[Windows Vista]]开始在[[作業系統]]中包含的密碼学编程接口。替代了当时已经发布了十年的[[Cryptographic API]]。&lt;br /&gt;
&lt;br /&gt;
CNG允许同一个函数可用更多的密码学算法，并包含了[[美国国家安全局]]{{tsl|en|NSA Suite B Cryptography}}中发布的新算法。&amp;lt;ref&amp;gt;{{Cite web |url=http://www.nsa.gov/ia/programs/suiteb_cryptography/index.shtml |title=Suite B |accessdate=2020-07-15 |archive-date=2009-02-07 |archive-url=https://web.archive.org/web/20090207005135/http://www.nsa.gov/ia/programs/suiteb_cryptography/index.shtml |dead-url=no }}&amp;lt;/ref&amp;gt;并灵活地支持插件定制密码学API到CNG的运行时中。但CNG的密钥存储机制仍然不支持存储对称密钥。&amp;lt;ref&amp;gt;{{Cite web |url=https://msdn.microsoft.com/en-us/library/bb204778%28v=vs.85%29.aspx |title=Key Storage and Retrieval, Microsoft |accessdate=2020-07-15 |archive-date=2017-09-21 |archive-url=https://web.archive.org/web/20170921001832/https://msdn.microsoft.com/en-us/library/bb204778%28v=vs.85%29.aspx |dead-url=no }}&amp;lt;/ref&amp;gt; CNG既可以工作在用户模式下，也可以工作在内核模式下，支持CryptoAPI的所有算法。其运行代码在Bcrypt.dll文件中。&lt;br /&gt;
&lt;br /&gt;
CNG也支持[[椭圆曲线密码学]]非对称加密。&amp;lt;ref&amp;gt;{{Cite web |url=https://www.nsa.gov/business/programs/elliptic_curve.shtml |title=The Case for Elliptic Curve Cryptography, NSA |accessdate=2020-07-15 |archive-date=2018-09-18 |archive-url=https://web.archive.org/web/20180918145859/https://www.nsa.gov/business/programs/elliptic_curve.shtml |dead-url=no }}&amp;lt;/ref&amp;gt;CNG API集成了[[智能卡]]子系统，包括Base Smart Card Cryptographic Service Provider (Base CSP) 模块，封装了智能卡API。智能卡制造商只需要使其产品兼容与该API，而不需要从头写解决方案。 &lt;br /&gt;
&lt;br /&gt;
CNG增加了[[双椭圆曲线确定性随机比特生成器]]&amp;lt;ref name=&amp;quot;Schneier&amp;quot;&amp;gt;{{cite web |url=http://www.schneier.com/blog/archives/2007/12/dual_ec_drbg_ad.html |title=Dual_EC_DRBG Added to Windows Vista |last=Schneier |first=Bruce |authorlink=Bruce Schneier |date=December 17, 2007 |work=Schneier on Security |accessdate=January 13, 2010 |archive-date=2020-07-10 |archive-url=https://web.archive.org/web/20200710065457/https://www.schneier.com/blog/archives/2007/12/dual_ec_drbg_ad.html |dead-url=no }}&amp;lt;/ref&amp;gt;，一套定义于{{tsl|en|NIST SP 800-90A}}中的[[伪随机数生成器]]，被认为存在NSA的安全后门。除非开发者记得每次都用其它伪随机数生成器或[[真随机数生成器]]产生初始化种子。该算法也很慢。&amp;lt;ref name=&amp;quot;Schneier2&amp;quot;&amp;gt;{{cite web |url=http://www.schneier.com/blog/archives/2007/11/the_strange_sto.html |title=The Strange Story of Dual_EC_DRBG |last=Schneier |first=Bruce |authorlink=Bruce Schneier |date=November 15, 2007 |work=Schneier on Security |accessdate=January 12, 2010 |archive-date=2020-07-10 |archive-url=https://web.archive.org/web/20200710065535/https://www.schneier.com/blog/archives/2007/11/the_strange_sto.html |dead-url=no }}&amp;lt;/ref&amp;gt;该算法只在明确调用时才会被使用。&lt;br /&gt;
&lt;br /&gt;
CNG的缺省的[[伪随机数生成算法]]已经被使用AES作为块加密器的{{tsl|en|CTR_DRBG}}替代了。因为老的算法使用[[資料加密標準|DES]]与[[SHA-1]]，都已经被攻破。&amp;lt;ref&amp;gt;{{cite web |url=http://csrc.nist.gov/publications/fips/archive/fips186-2/fips186-2.pdf |title=FIPS PUB 186-2 |publisher=[[National Institute of Standards and Technology]] |work=[[Federal Information Processing Standard]]s |date=January 27, 2000 |accessdate=January 13, 2010 |archive-date=2011-08-12 |archive-url=https://web.archive.org/web/20110812232347/http://csrc.nist.gov/publications/fips/archive/fips186-2/fips186-2.pdf |dead-url=no }}&amp;lt;/ref&amp;gt; CTR_DRBG定义在NIST SP 800-90中的两种算法之一，由[[布魯斯·施奈爾]]捐赠。&amp;lt;ref name=&amp;quot;Schneier2&amp;quot; /&amp;gt;&lt;br /&gt;
==示例源代码==&lt;br /&gt;
产生指定字节长度的伪随机数：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;lt;Windows.h&amp;gt;&lt;br /&gt;
#include &amp;lt;bcrypt.h&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#pragma comment(lib, &amp;quot;bcrypt.lib&amp;quot;)&lt;br /&gt;
using namespace std;&lt;br /&gt;
unsigned long getSeed(ULONG buffer_size) {&lt;br /&gt;
	NTSTATUS status = 0;&lt;br /&gt;
	ULONG flags = 0;&lt;br /&gt;
	UCHAR c_seed[128] = { 0 };&lt;br /&gt;
	BCRYPT_ALG_HANDLE handle;&lt;br /&gt;
	status = BCryptOpenAlgorithmProvider(&lt;br /&gt;
		&amp;amp;handle, BCRYPT_RNG_ALGORITHM, NULL, 0&lt;br /&gt;
	);&lt;br /&gt;
	if (!BCRYPT_SUCCESS(status)) {&lt;br /&gt;
		cout &amp;lt;&amp;lt; &amp;quot;BCryptOpenAlgorithmProvider&amp;quot;;&lt;br /&gt;
		printf(&amp;quot;%X&amp;quot;, status);&lt;br /&gt;
	}&lt;br /&gt;
	status = BCryptGenRandom(&lt;br /&gt;
		handle, c_seed, buffer_size, 0&lt;br /&gt;
	);&lt;br /&gt;
	if (!BCRYPT_SUCCESS(status)) {&lt;br /&gt;
		cout &amp;lt;&amp;lt; &amp;quot;Error in BCryptGenRandom&amp;quot;;&lt;br /&gt;
		printf(&amp;quot;%X&amp;quot;, status);&lt;br /&gt;
	}&lt;br /&gt;
	status = BCryptCloseAlgorithmProvider(&lt;br /&gt;
		handle, 0&lt;br /&gt;
	);&lt;br /&gt;
	if (!BCRYPT_SUCCESS(status)) {&lt;br /&gt;
		cout &amp;lt;&amp;lt; &amp;quot;BCryptCloseAlgorithmProvider&amp;quot;;&lt;br /&gt;
		printf(&amp;quot;%X&amp;quot;, status);&lt;br /&gt;
	}&lt;br /&gt;
	unsigned long seedNo = (unsigned long)c_seed;&lt;br /&gt;
	return seedNo;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==参考文献==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Windows API]]&lt;/div&gt;</summary>
		<author><name>imported&gt;InternetArchiveBot</name></author>
	</entry>
</feed>