Use old passwords decryption for protocols < 4

This commit is contained in:
Grégory Soutadé 2017-04-17 20:39:53 +02:00
parent 6dfcab813d
commit 416a4d9581

View File

@ -175,7 +175,7 @@ async function ask_server(form, field, logins, domain, wdomain, mkey, submit)
case 3: case 3:
// Version 3 : nothing special to do // Version 3 : nothing special to do
case 4: case 4:
// Version 3 : nothing special to do // Version 4 : nothing special to do
break; break;
} }
} }
@ -216,13 +216,7 @@ async function ask_server(form, field, logins, domain, wdomain, mkey, submit)
if (ciphered_password != "") if (ciphered_password != "")
{ {
debug("Ciphered password : " + ciphered_password); debug("Ciphered password : " + ciphered_password);
if (matched_key < logins.length) if (matched_key >= logins.logins || server_protocol_version < 4)
{
clear_password = await decrypt_cbc(mkey, global_iv, hex2a(ciphered_password));
clear_password = clear_password.replace(/\0*$/, "");
clear_password = clear_password.substr(3, clear_password.length);
}
else
// Crypto v1 // Crypto v1
{ {
clear_password = await decrypt_ecb(mkey, hex2a(ciphered_password)); clear_password = await decrypt_ecb(mkey, hex2a(ciphered_password));
@ -230,6 +224,12 @@ async function ask_server(form, field, logins, domain, wdomain, mkey, submit)
clear_password = clear_password.replace(/\0*$/, ""); clear_password = clear_password.replace(/\0*$/, "");
clear_password = clear_password.substr(0, clear_password.length-3); clear_password = clear_password.substr(0, clear_password.length-3);
} }
else
{
clear_password = await decrypt_cbc(mkey, global_iv, hex2a(ciphered_password));
clear_password = clear_password.replace(/\0*$/, "");
clear_password = clear_password.substr(3, clear_password.length);
}
debug("Clear password " + clear_password); debug("Clear password " + clear_password);
field.value = clear_password; field.value = clear_password;
// Remove gPass event listener and submit again with clear password // Remove gPass event listener and submit again with clear password