crypto.timingSafeEqualの概要
This function is based on a constant-time algorithm. Returns true if
ais equal tob, without leaking timing information that would allow an attacker to guess one of the values. This is suitable for comparing HMAC digests or secret values like authentication cookies or capability urls.
aandbmust both beBuffers,TypedArrays, orDataViews, and they must have the same byte length. An error is thrown ifaandbhave different byte lengths.If at least one of
aandbis aTypedArraywith more than one byte per entry, such asUint16Array, the result will be computed using the platform byte order.Use of
crypto.timingSafeEqualdoes not guarantee that the surrounding code is timing-safe. Care should be taken to ensure that the surrounding code does not introduce timing vulnerabilities.
DeepL訳
この関数は、定数時間アルゴリズムに基づいている。攻撃者がどちらかの値を推測できるようなタイミング情報を漏らすことなく、 a と b が等しい場合に true を返します。これは、HMACダイジェストや、認証クッキーやケイパビリティURLのような秘密の値を比較するのに適しています。
a と b は両方とも Buffers, TypedArrays, または DataViews でなければならず、同じバイト長でなければなりません。a と b が異なるバイト長を持つ場合はエラーがスローされます。
a と b の少なくとも一方が Uint16Array のようなエントリごとに複数のバイトを持つ TypedArray である場合、結果はプラットフォームのバイトオーダーを使用して計算されます。
crypto.timingSafeEqualを使用することは、周囲のコードがタイミングセーフであることを保証するものではありません。周囲のコードがタイミングに関する脆弱性をもたらさないように注意する必要がある。
crypto.pbkdf2の概要
Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by
digestis applied to derive a key of the requested byte length (keylen) from thepassword,saltanditerations.The supplied
callbackfunction is called with two arguments:errandderivedKey. If an error occurs while deriving the key,errwill be set; otherwiseerrwill benull. By default, the successfully generatedderivedKeywill be passed to the callback as aBuffer. An error will be thrown if any of the input arguments specify invalid values or types.
DeepL訳:
非同期のPassword-Based Key Derivation Function 2 (PBKDF2) の実装を提供する。digest で指定された HMAC ダイジェストアルゴリズムが適用され、 password, salt および iterations から要求されたバイト長 (keylen) の鍵を導出する。
与えられた callback 関数はerr と derivedKey の2つの引数で呼び出されます。鍵の導出中にエラーが発生した場合は err がセットされ、それ以外の場合は err は null となる。デフォルトでは、正常に生成された derivedKey は Buffer としてコールバックに渡される。入力引数に無効な値や型が指定された場合は、エラーがスローされます。