Should I do key differentiation separately for both, with different salts?
You can do this, but a faster alternative with about the same security would be to use something like this:
var master = crypto.pbkdf2Sync(password, randomSalt, 60000, 256, 'sha256');
var hmac = crypto.createHmac('sha256', master);
hmac.update("key");
var key = hmac.digest();
hmac = crypto.createHmac('sha256', master);
hmac.update("nonce");
var nonce = hmac.digest().slice(0,12);
Should I draw one key conclusion and then cut it in half?
, , . AES-256 (256 ) nonce (IV) 64 128 , SHA-384 (sha384) SHA-512 (sha512) digest, node.js.
?
, , , , + nonce.
, nonce. , nonce randomly () .
, , . , , ...
. , .
, MAC :
hmac = crypto.createHmac('sha256', master);
hmac.update("hmac");
var hmacKey = hmac.digest();
hmac = crypto.createHmac('sha256', hmacKey);
hmac.update(ciphertext);
var authenticationTag = hmac.digest();
, .
, GCM, node.js.