@@ -2949,35 +2949,34 @@ Does not perform any other validation checks on the certificate.
29492949
29502950## ` node:crypto ` module methods and properties
29512951
2952- ### ` crypto.argon2(password, salt, keylen, options, callback) `
2952+ ### ` crypto.argon2(options, callback) `
29532953
29542954<!-- YAML
29552955added: REPLACEME
29562956-->
29572957
29582958> Stability: 1.2 - Release candidate
29592959
2960- * ` password ` {string|ArrayBuffer|Buffer|TypedArray|DataView}
2961- * ` salt ` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must be at
2962- least 8 bytes long.
2963- * ` keylen ` {number} The length of the key to generate. Must be greater than 4 and less
2964- than ` 2**32-1 ` .
29652960* ` options ` {Object}
2966- * ` algorithm ` {string} Variant of Argon2, one of ` "argon2d" ` , ` "argon2i" ` or
2967- ` "argon2id" ` .
2968- * ` iterations ` {number} Number of iterations (passes). Must be greater than 1 and
2969- less than ` 2**32-1 ` .
2961+ * ` message ` {string|ArrayBuffer|Buffer|TypedArray|DataView}
2962+ * ` nonce ` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must be at
2963+ least 8 bytes long.
29702964 * ` parallelism ` {number} Parallelization parameter (number of lanes and threads).
29712965 Must be greater than 1 and less than ` 2**24-1 ` .
2966+ * ` tagLength ` {number} The length of the key to generate. Must be greater than 4 and
2967+ less than ` 2**32-1 ` .
29722968 * ` memory ` {number} Memory cost in 1KiB blocks. Must be greater than
29732969 ` 8 * parallelism ` and less than ` 2**32-1 ` . The actual number of blocks is rounded
29742970 down to the nearest multiple of ` 4 * parallelism ` .
2971+ * ` passes ` {number} Number of passes (iterations). Must be greater than 1 and less
2972+ than ` 2**32-1 ` .
29752973 * ` secret ` {string|ArrayBuffer|Buffer|TypedArray|DataView} Random additional input,
29762974 similar to the salt, that should ** NOT** be stored with the derived key. Also known
29772975 as a pepper. If used, must have a length not greater than ` 2**32-1 ` bytes.
29782976 * ` associatedData ` {string|ArrayBuffer|Buffer|TypedArray|DataView} Additional data to
29792977 be added to the hash, functionally equivalent to salt or secret, but meant for
29802978 non-random data. If used, must have a length not greater than ` 2**32-1 ` bytes.
2979+ * ` type ` {string} Variant of Argon2, one of ` "argon2d" ` , ` "argon2i" ` or ` "argon2id" ` .
29812980* ` callback ` {Function}
29822981 * ` err ` {Error}
29832982 * ` derivedKey ` {Buffer}
@@ -2986,10 +2985,10 @@ Provides an asynchronous [argon2][] implementation. Argon2 is a password-based
29862985key derivation function that is designed to be expensive computationally and
29872986memory-wise in order to make brute-force attacks unrewarding.
29882987
2989- The ` salt ` should be as unique as possible. It is recommended that a salt is
2988+ The ` nonce ` should be as unique as possible. It is recommended that a nonce is
29902989random and at least 16 bytes long. See [ NIST SP 800-132] [ ] for details.
29912990
2992- When passing strings for ` password ` , ` salt ` , ` secret ` or ` associatedData ` , please
2991+ When passing strings for ` message ` , ` nonce ` , ` secret ` or ` associatedData ` , please
29932992consider [ caveats when using strings as inputs to cryptographic APIs] [ ] .
29942993
29952994The ` callback ` function is called with two arguments: ` err ` and ` derivedKey ` .
@@ -3005,8 +3004,8 @@ const {
30053004 randomBytes ,
30063005} = await import (' node:crypto' );
30073006
3008- const salt = randomBytes (16 );
3009- argon2 (' password' , salt, 64 , { iterations : 3 , parallelism : 4 , memory: 65536 }, (err , derivedKey ) => {
3007+ const nonce = randomBytes (16 );
3008+ argon2 ({ message : ' password' , nonce, parallelism : 4 , tagLength : 64 , memory: 65536 , passes : 3 }, (err , derivedKey ) => {
30103009 if (err) throw err;
30113010 console .log (derivedKey .toString (' hex' )); // '0de3036...22afcc5'
30123011});
@@ -3018,9 +3017,9 @@ const {
30183017 randomBytes ,
30193018} = require (' node:crypto' );
30203019
3021- randomBytes (16 , (err , salt ) => {
3020+ randomBytes (16 , (err , nonce ) => {
30223021 if (err) throw err;
3023- argon2 (' password' , salt, 64 , { iterations : 3 , parallelism : 4 , memory: 65536 }, (err , derivedKey ) => {
3022+ argon2 ({ message : ' password' , nonce, parallelism : 4 , tagLength : 64 , memory: 65536 , passes : 3 }, (err , derivedKey ) => {
30243023 if (err) throw err;
30253024 console .log (derivedKey .toString (' hex' )); // '0de3036...22afcc5'
30263025 });
@@ -3035,37 +3034,36 @@ added: REPLACEME
30353034
30363035> Stability: 1.2 - Release candidate
30373036
3038- * ` password ` {string|Buffer|TypedArray|DataView}
3039- * ` salt ` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must be at
3040- least 8 bytes long.
3041- * ` keylen ` {number} The length of the key to generate. Must be greater than 4 and less
3042- than ` 2**32-1 ` .
30433037* ` options ` {Object}
3044- * ` algorithm ` {string} Variant of Argon2, one of ` "argon2d" ` , ` "argon2i" ` or
3045- ` "argon2id" ` .
3046- * ` iterations ` {number} Number of iterations (passes). Must be greater than 1 and
3047- less than ` 2**32-1 ` .
3038+ * ` message ` {string|ArrayBuffer|Buffer|TypedArray|DataView}
3039+ * ` nonce ` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must be at
3040+ least 8 bytes long.
30483041 * ` parallelism ` {number} Parallelization parameter (number of lanes and threads).
30493042 Must be greater than 1 and less than ` 2**24-1 ` .
3043+ * ` tagLength ` {number} The length of the key to generate. Must be greater than 4 and
3044+ less than ` 2**32-1 ` .
30503045 * ` memory ` {number} Memory cost in 1KiB blocks. Must be greater than
30513046 ` 8 * parallelism ` and less than ` 2**32-1 ` . The actual number of blocks is rounded
30523047 down to the nearest multiple of ` 4 * parallelism ` .
3048+ * ` passes ` {number} Number of passes (iterations). Must be greater than 1 and less
3049+ than ` 2**32-1 ` .
30533050 * ` secret ` {string|ArrayBuffer|Buffer|TypedArray|DataView} Random additional input,
30543051 similar to the salt, that should ** NOT** be stored with the derived key. Also known
30553052 as a pepper. If used, must have a length not greater than ` 2**32-1 ` bytes.
30563053 * ` associatedData ` {string|ArrayBuffer|Buffer|TypedArray|DataView} Additional data to
30573054 be added to the hash, functionally equivalent to salt or secret, but meant for
30583055 non-random data. If used, must have a length not greater than ` 2**32-1 ` bytes.
3056+ * ` type ` {string} Variant of Argon2, one of ` "argon2d" ` , ` "argon2i" ` or ` "argon2id" ` .
30593057* Returns: {Buffer}
30603058
30613059Provides a synchronous [ argon2] [ ] implementation. Argon2 is a password-based
30623060key derivation function that is designed to be expensive computationally and
30633061memory-wise in order to make brute-force attacks unrewarding.
30643062
3065- The ` salt ` should be as unique as possible. It is recommended that a salt is
3063+ The ` nonce ` should be as unique as possible. It is recommended that a nonce is
30663064random and at least 16 bytes long. See [ NIST SP 800-132] [ ] for details.
30673065
3068- When passing strings for ` password ` , ` salt ` , ` secret ` or ` associatedData ` , please
3066+ When passing strings for ` message ` , ` nonce ` , ` secret ` or ` associatedData ` , please
30693067consider [ caveats when using strings as inputs to cryptographic APIs] [ ] .
30703068
30713069An exception is thrown when key derivation fails, otherwise the derived key is
@@ -3079,10 +3077,9 @@ const {
30793077 argon2Sync ,
30803078 randomBytes ,
30813079} = await import (' node:crypto' );
3082- // Using the factory defaults.
30833080
3084- const salt = randomBytes (16 );
3085- const key = argon2Sync (' password' , salt, 64 , { iterations : 3 , parallelism : 4 , memory: 65536 });
3081+ const nonce = randomBytes (16 );
3082+ const key = argon2Sync ({ message : ' password' , nonce, parallelism : 4 , tagLength : 64 , memory: 65536 , passes : 3 });
30863083console .log (key .toString (' hex' )); // '3745e48...08d59ae'
30873084```
30883085
@@ -3091,10 +3088,9 @@ const {
30913088 argon2Sync ,
30923089 randomBytes ,
30933090} = require (' node:crypto' );
3094- // Using the factory defaults.
30953091
3096- const salt = randomBytes (16 );
3097- const key = argon2Sync (' password' , salt, 64 , { iterations : 3 , parallelism : 4 , memory: 65536 });
3092+ const nonce = randomBytes (16 );
3093+ const key = argon2Sync ({ message : ' password' , nonce, parallelism : 4 , tagLength : 64 , memory: 65536 , passes : 3 });
30983094console .log (key .toString (' hex' )); // '3745e48...08d59ae'
30993095```
31003096
0 commit comments