类:DiffieHellmanGroup


【Class: DiffieHellmanGroup

DiffieHellmanGroup 类以一个众所周知的 modp 组作为其参数。它的工作方式与 DiffieHellman 相同,只是创建后不允许更改其密钥。换句话说,它不实现 setPublicKey()setPrivateKey() 方法。

【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('modp16');const { createDiffieHellmanGroup } = require('node:crypto');
const dh = createDiffieHellmanGroup('modp16');

支持以下组:

【The following groups are supported:】

  • 'modp14'(2048 位,RFC 3526 第 3 节)
  • 'modp15'(3072 位,RFC 3526 第 4 节)
  • 'modp16'(4096 位,RFC 3526 第 5 节)
  • 'modp17'(6144 位,RFC 3526 第 6 节)
  • 'modp18'(8192 位,RFC 3526 第 7 节)

以下组仍然受支持,但已弃用(参见 注意事项):

【The following groups are still supported but deprecated (see Caveats):】

  • 'modp1' (768 bits, RFC 2409 Section 6.1)
  • 'modp2' (1024 bits, RFC 2409 Section 6.2)
  • 'modp5' (1536 bits, RFC 3526 Section 2)

这些已弃用的组可能会在 Node.js 的未来版本中被删除。

【These deprecated groups might be removed in future versions of Node.js.】