DiffieHellmanGroup 类


DiffieHellmanGroup 类以著名的 modp 组为参数。 它的工作原理与 DiffieHellman 相同,不同之处在于它不允许在创建后更改其密钥。 换句话说,它没有实现 setPublicKey()setPrivateKey() 方法。

const { createDiffieHellmanGroup } = await import('node:crypto');
const dh = createDiffieHellmanGroup('modp1');const { createDiffieHellmanGroup } = require('node:crypto');
const dh = createDiffieHellmanGroup('modp1');

名称(例如 'modp1')取自 RFC 2412(modp1 和 2)和 RFC 3526

$ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h
modp1  #  768 位
modp2  # 1024 位
modp5  # 1536 位
modp14 # 2048 位
modp15 # 等等。
modp16
modp17
modp18

The DiffieHellmanGroup class takes a well-known modp group as its argument. It works the same as DiffieHellman, except that it does not allow changing its keys after creation. In other words, it does not implement setPublicKey() or setPrivateKey() methods.

const { createDiffieHellmanGroup } = await import('node:crypto');
const dh = createDiffieHellmanGroup('modp1');const { createDiffieHellmanGroup } = require('node:crypto');
const dh = createDiffieHellmanGroup('modp1');

The name (e.g. 'modp1') is taken from RFC 2412 (modp1 and 2) and RFC 3526:

$ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h
modp1  #  768 bits
modp2  # 1024 bits
modp5  # 1536 bits
modp14 # 2048 bits
modp15 # etc.
modp16
modp17
modp18