大网数据广告活动
账户与安全

Diffie-Hellman Key BLOBs

· 52CE 我爱测

BLOBs are used with the Diffie-Hellman provider to export keys from, and import keys into, the cryptographic service provider (CSP).

BLOBs are used with the Diffie-Hellman provider to export keys from, and import keys into, the cryptographic service provider (CSP).

Public Key BLOBs

Diffie-Hellman public key BLOBs, type PUBLICKEYBLOB, are used to exchange the (G^X) mod P value in a Diffie-Hellman key exchange. These keys are exported and imported as a sequence of bytes with the following format.

PUBLICKEYSTRUC  publickeystruc; 
DHPUBKEY dhpubkey;
BYTE y[dhpubkey.bitlen/8]; // Where y = (G^X) mod P

The following table describes each component of the key BLOB.

Field Description
dhpubkey A DHPUBKEY structure. The magic member should be set to 0x31484400. This hexadecimal value is the ASCII encoding of "DH1".
publickeystruc A PUBLICKEYSTRUC structure.
y A BYTE sequence. The Y value, (G^X) mod P, is located directly after the DHPUBKEY structure, and should always be the length, in bytes, of the DHPUBKEY bitlen field (bit length of P) divided by eight. If the length of the data that results from the calculation of (G^X) mod P is one or more bytes shorter than P divided by eight, the data must be padded with the necessary bytes (of zero value) to make the data the desired length (little-endian format).

Private Key BLOBs

Diffie-Hellman private key BLOBs, type PRIVATEKEYBLOB, are used to store the public/private information of a Diffie-Hellman key. These keys are exported and imported as a sequence of bytes with the following format.

PUBLICKEYSTRUC  publickeystruc; 
DHPUBKEY        dhpubkey;
BYTE            prime[dhpubkey.bitlen/8];
BYTE            generator[dhpubkey.bitlen/8];
BYTE            secret[dhpubkey.bitlen/8];

The following table describes each component of the key BLOB.

Field Description
dhpubkey A DHPUBKEY structure. The magic member must be set to 0x32484400. This hexadecimal value is the ASCII encoding of "DH2".
generator A BYTE sequence. The generator, G.
publickeystruc A PUBLICKEYSTRUC structure.
prime A BYTE sequence. The prime modulus, P. This data must always have the most significant bit of the most significant byte set to one.
secret A BYTE sequence. The secret exponent, X.

Note:
The generator and secret must always have the same length, in bytes. If either is one byte or more shorter than the other, it must be padded with the necessary number of zero value bytes to make them the same. Both the generator and the secret are in little-endian format.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。