encryption: do not allow password and hint to be the same
This commit is contained in:
+3
-1
@@ -304,6 +304,7 @@ async function setEncryption(backupSite, data, auditSource) {
|
||||
if (data.encryptionPassword) {
|
||||
const encryptionPasswordError = validateEncryptionPassword(data.encryptionPassword);
|
||||
if (encryptionPasswordError) throw encryptionPasswordError;
|
||||
if (data.encryptionPassword === data.encryptionPasswordHint) throw new BoxError(BoxError.BAD_FIELD, 'password hint cannot be the same as password');
|
||||
encryption = hush.generateEncryptionKeysSync(data.encryptionPassword);
|
||||
encryption.encryptedFilenames = !!data.encryptedFilenames;
|
||||
encryption.encryptionPasswordHint = data.encryptionPasswordHint || '';
|
||||
@@ -519,7 +520,7 @@ async function add(data, auditSource) {
|
||||
const limits = data.limits || null,
|
||||
encryptionPassword = data.encryptionPassword || null,
|
||||
encryptedFilenames = data.encryptedFilenames || false,
|
||||
encryptionPasswordHint = data.encryptionPasswordHint || null;
|
||||
encryptionPasswordHint = data.encryptionPasswordHint || '';
|
||||
|
||||
const formatError = backupFormats.validateFormat(format);
|
||||
if (formatError) throw formatError;
|
||||
@@ -534,6 +535,7 @@ async function add(data, auditSource) {
|
||||
if (encryptionPassword) {
|
||||
const encryptionPasswordError = validateEncryptionPassword(encryptionPassword);
|
||||
if (encryptionPasswordError) throw encryptionPasswordError;
|
||||
if (data.encryptionPassword === data.encryptionPasswordHint) throw new BoxError(BoxError.BAD_FIELD, 'Password hint cannot be the same as password');
|
||||
encryption = hush.generateEncryptionKeysSync(encryptionPassword);
|
||||
encryption.encryptedFilenames = !!encryptedFilenames;
|
||||
encryption.encryptionPasswordHint = encryptionPasswordHint;
|
||||
|
||||
Reference in New Issue
Block a user