salt_password does nothing with class state so move it out
This commit is contained in:
parent
9f33247d32
commit
b18c8820a2
1 changed files with 19 additions and 19 deletions
|
@ -1,3 +1,21 @@
|
|||
static void salt_password (string password, out string token, out string salt) {
|
||||
const int SALT_BYTES = 8;
|
||||
uchar salt_bytes[SALT_BYTES];
|
||||
GCrypt.Random.randomize (salt_bytes);
|
||||
uchar salt_chars[2*SALT_BYTES+1];
|
||||
for (int i = 0; i < SALT_BYTES; i += 1) {
|
||||
salt_chars[2*i+0] = "0123456789abcdef"[(salt_bytes[i]>>4)&0xf];
|
||||
salt_chars[2*i+1] = "0123456789abcdef"[(salt_bytes[i]>>0)&0xf];
|
||||
}
|
||||
salt_chars[2*SALT_BYTES] = 0;
|
||||
var checksum = new Checksum (ChecksumType.MD5);
|
||||
checksum.update ((uchar[]) password, -1);
|
||||
checksum.update (salt_chars, -1);
|
||||
|
||||
token = checksum.get_string ();
|
||||
salt = (string) salt_chars;
|
||||
}
|
||||
|
||||
[GtkTemplate (ui = "/eu/callcc/audrey/ui/setup.ui")]
|
||||
public class Ui.Setup : Adw.PreferencesDialog {
|
||||
public string status { get; private set; default = _("Not connected"); }
|
||||
|
@ -30,7 +48,7 @@ public class Ui.Setup : Adw.PreferencesDialog {
|
|||
this.status = _("Connecting...");
|
||||
|
||||
string new_token, new_salt;
|
||||
this.salt_password (this.password, out new_token, out new_salt);
|
||||
salt_password (this.password, out new_token, out new_salt);
|
||||
var api = new Subsonic.with_token (
|
||||
this.server_url,
|
||||
this.username,
|
||||
|
@ -99,24 +117,6 @@ public class Ui.Setup : Adw.PreferencesDialog {
|
|||
});
|
||||
}
|
||||
|
||||
private void salt_password (string password, out string token, out string salt) {
|
||||
const int SALT_BYTES = 8;
|
||||
uchar salt_bytes[SALT_BYTES];
|
||||
GCrypt.Random.randomize (salt_bytes);
|
||||
uchar salt_chars[2*SALT_BYTES+1];
|
||||
for (int i = 0; i < SALT_BYTES; i += 1) {
|
||||
salt_chars[2*i+0] = "0123456789abcdef"[(salt_bytes[i]>>4)&0xf];
|
||||
salt_chars[2*i+1] = "0123456789abcdef"[(salt_bytes[i]>>0)&0xf];
|
||||
}
|
||||
salt_chars[2*SALT_BYTES] = 0;
|
||||
var checksum = new Checksum (ChecksumType.MD5);
|
||||
checksum.update ((uchar[]) password, -1);
|
||||
checksum.update (salt_chars, -1);
|
||||
|
||||
token = checksum.get_string ();
|
||||
salt = (string) salt_chars;
|
||||
}
|
||||
|
||||
public void save () {
|
||||
this.authn_can_edit = false;
|
||||
Secret.password_store.begin (secret_schema, null, "Subsonic password", this.password, null, (obj, res) => {
|
||||
|
|
Loading…
Reference in a new issue