separate DB connection for each transaction (just for the record, will be reverted probably)

This commit is contained in:
azivner
2017-11-28 17:04:47 -05:00
parent 4d95eb0762
commit fd764f6163
21 changed files with 326 additions and 429 deletions

View File

@@ -11,18 +11,18 @@ async function verifyPassword(password) {
return givenPasswordHash === dbPasswordHash;
}
async function setDataKey(password, plainTextDataKey) {
async function setDataKey(db, password, plainTextDataKey) {
const passwordDerivedKey = await my_scrypt.getPasswordDerivedKey(password);
const encryptedDataKeyIv = utils.randomSecureToken(16).slice(0, 16);
await options.setOption('encrypted_data_key_iv', encryptedDataKeyIv);
await options.setOption(db, 'encrypted_data_key_iv', encryptedDataKeyIv);
const buffer = Buffer.from(plainTextDataKey);
const newEncryptedDataKey = data_encryption.encrypt(passwordDerivedKey, encryptedDataKeyIv, buffer);
await options.setOption('encrypted_data_key', newEncryptedDataKey);
await options.setOption(db, 'encrypted_data_key', newEncryptedDataKey);
}
async function getDataKey(password) {