Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Password verification fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Sep 5, 2022
1 parent 737ca9a commit 484cfaf
Show file tree
Hide file tree
Showing 9 changed files with 1,067 additions and 70 deletions.
18 changes: 10 additions & 8 deletions core/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ pub fn encrypt_password(password: String) -> String {
.unwrap()
.to_string();

let parsed_hash = PasswordHash::new(&password_hash).unwrap();

assert!(Argon2::default()
.verify_password(password.as_bytes(), &parsed_hash)
.is_ok());

password_hash.into()
}

Expand Down Expand Up @@ -77,11 +71,19 @@ pub fn get_entry(name: String) -> String {
let service = "authme_dev";
let entry = keyring::Entry::new(&service, &name);

let item = entry.get_password().unwrap();
let item = entry.get_password().unwrap_or_else(|error| "error".into());

item.into()
}

#[tauri::command]
pub fn delete_entry(name: String) {
let service = "authme_dev";
let entry = keyring::Entry::new(&service, &name);

let item = entry.delete_password();
}

#[tauri::command]
pub fn receive_encryption_key(key: String) {
*ENCRYPTION_KEY.lock().unwrap() = key
Expand All @@ -90,4 +92,4 @@ pub fn receive_encryption_key(key: String) {
#[tauri::command]
pub fn set_encryption_key() {
*ENCRYPTION_KEY.lock().unwrap() = get_entry("encryptionKey".to_string())
}
}
1 change: 1 addition & 0 deletions core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn main() {
encryption::get_entry,
encryption::receive_encryption_key,
encryption::set_encryption_key,
encryption::delete_entry,
])
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
println!("{}, {argv:?}, {cwd}", app.package_info().name);
Expand Down
14 changes: 7 additions & 7 deletions interface/libraries/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ export const setEntry = async (name: string, data: string) => {
await invoke("set_entry", { name, data })
}

/**
* Gets an entry on the system keychain
*/
export const getEntry = async (name: string): Promise<string> => {
return await invoke("get_entry", { name })
}

/**
* Encrypts a string with the encryption key
*/
Expand Down Expand Up @@ -48,3 +41,10 @@ export const setEncryptionKey = async () => {
export const sendEncryptionKey = async (key: string) => {
return await invoke("receive_encryption_key", { key })
}

/**
* Delete encryption key
*/
export const deleteEncryptionKey = async (name: string) => {
return await invoke("delete_entry", { name })
}
16 changes: 16 additions & 0 deletions interface/libraries/password/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { passwords } from "./passwords.json"

/**
* Match the input with the top 1000 password
*/
export const search = (input: string): boolean => {
let match = false

for (let i = 0; i < passwords.length; i++) {
if (passwords[i] === input) {
return (match = true)
}
}

return match
}
Loading

0 comments on commit 484cfaf

Please sign in to comment.