Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/password_hashers/scrypt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
use std::ffi::{c_char, CStr, CString};
use cas_lib::password_hashers::{scrypt::CASScrypt};


#[no_mangle]
pub extern "C" fn scrypt_hash_with_parameters(
pass_to_hash: *const c_char,
cpu_memory_cost: u8,
block_size: u32,
parallelism: u32,
) -> *mut c_char {
let string_pass = unsafe {
assert!(!pass_to_hash.is_null());

CStr::from_ptr(pass_to_hash)
}
.to_str()
.unwrap()
.to_string();
let new_hash = CASScrypt::hash_password_customized(string_pass, cpu_memory_cost, block_size, parallelism);
return CString::new(new_hash).unwrap().into_raw();
}

#[no_mangle]
pub extern "C" fn scrypt_hash(pass_to_hash: *const c_char) -> *mut c_char {
let string_pass = unsafe {
Expand Down