crypto.encapsulate(key[, callback])
¥Stability: 1.2 - Release candidate
-
key
<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> 公钥¥
key
<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject> Public Key -
callback
<Function> -
返回:如果未提供
callback
函数,则为 <Object>。¥Returns: <Object> if the
callback
function is not provided.
使用公钥的 KEM 算法进行密钥封装。
¥Key encapsulation using a KEM algorithm with a public key.
支持的密钥类型及其 KEM 算法如下:
¥Supported key types and their KEM algorithms are:
-
'rsa'
1 RSA 密钥值封装¥
'rsa'
1 RSA Secret Value Encapsulation -
'ec'
2 DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256) -
'x25519'
2 DHKEM(X25519, HKDF-SHA256) -
'x448'
2 DHKEM(X448, HKDF-SHA512) -
'ml-kem-512'
3 ML-KEM -
'ml-kem-768'
3 ML-KEM -
'ml-kem-1024'
3 ML-KEM
如果 key
不是 KeyObject
,则此函数的行为就像将 key
传给 crypto.createPublicKey()
一样。
¥If key
is not a KeyObject
, this function behaves as if key
had been
passed to crypto.createPublicKey()
.
如果提供了 callback
函数,则该函数使用 libuv 的线程池。
¥If the callback
function is provided this function uses libuv's threadpool.