t_wの輪郭

Feedlyでフォローするボタン

HMAC

2022/4/20 16:21:00

crypto.pbkdf2の概要

2022/4/20 17:03:00

Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by digest is applied to derive a key of the requested byte length (keylen) from the password, salt and iterations.

The supplied callback function is called with two arguments: err and derivedKey. If an error occurs while deriving the key, err will be set; otherwise err will be null. By default, the successfully generated derivedKey will be passed to the callback as a Buffer. 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 関数はerrderivedKey の2つの引数で呼び出されます。鍵の導出中にエラーが発生した場合は err がセットされ、それ以外の場合は errnull となる。デフォルトでは、正常に生成された derivedKeyBuffer としてコールバックに渡される。入力引数に無効な値や型が指定された場合は、エラーがスローされます。

This function is based on a constant-time algorithm. Returns true if a is equal to b, 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.

a and b must both be Buffers, TypedArrays, or DataViews, and they must have the same byte length. An error is thrown if a and b have different byte lengths.

If at least one of a and b is a TypedArray with more than one byte per entry, such as Uint16Array, the result will be computed using the platform byte order.

Use of crypto.timingSafeEqual does 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訳
この関数は、定数時間アルゴリズムに基づいている。攻撃者がどちらかの値を推測できるようなタイミング情報を漏らすことなく、 ab が等しい場合に true を返します。これは、HMACダイジェストや、認証クッキーやケイパビリティURLのような秘密の値を比較するのに適しています。

ab は両方とも Buffers, TypedArrays, または DataViews でなければならず、同じバイト長でなければなりません。ab が異なるバイト長を持つ場合はエラーがスローされます。

ab の少なくとも一方が Uint16Array のようなエントリごとに複数のバイトを持つ TypedArray である場合、結果はプラットフォームのバイトオーダーを使用して計算されます。

crypto.timingSafeEqualを使用することは、周囲のコードがタイミングセーフであることを保証するものではありません。周囲のコードがタイミングに関する脆弱性をもたらさないように注意する必要がある。