mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[bug] Set authTagLength param in createCipheriv; Fix bug 72354
This commit is contained in:
@ -1078,7 +1078,8 @@ exports.encryptPassword = async function (ctx, password) {
|
||||
const iterations = Math.floor(Math.random() * (greaterNumber - lowerNumber)) + lowerNumber;
|
||||
|
||||
const encryptionKey = await pbkdf2Promise(tenSecret, salt, iterations, keyByteLength, 'sha512');
|
||||
const cipher = crypto.createCipheriv('aes-256-gcm', encryptionKey, initializationVector);
|
||||
//todo chacha20-poly1305 (clean db)
|
||||
const cipher = crypto.createCipheriv('aes-256-gcm', encryptionKey, initializationVector, {authTagLength:16});
|
||||
const encryptedData = Buffer.concat([cipher.update(password, 'utf8'), cipher.final()]);
|
||||
const authTag = cipher.getAuthTag();
|
||||
const predicate = iterations.toString(16);
|
||||
@ -1120,7 +1121,7 @@ exports.decryptPassword = async function (ctx, password) {
|
||||
] = pointerArray;
|
||||
|
||||
const decryptionKey = await pbkdf2Promise(tenSecret, salt, parseInt(iterations, 16), keyByteLength, 'sha512');
|
||||
const decipher = crypto.createDecipheriv('aes-256-gcm', decryptionKey, initializationVector);
|
||||
const decipher = crypto.createDecipheriv('aes-256-gcm', decryptionKey, initializationVector, {authTagLength:16});
|
||||
decipher.setAuthTag(authTag);
|
||||
|
||||
return Buffer.concat([decipher.update(encryptedData, 'binary'), decipher.final()]).toString();
|
||||
|
||||
Reference in New Issue
Block a user