Skip to content

Commit

Permalink
Fix C-API, on vpuh, return old hash on failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
samscott89 committed Dec 16, 2017
1 parent a26e490 commit dd722a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Binary file removed libpasta-capi/ctest/test
Binary file not shown.
3 changes: 3 additions & 0 deletions libpasta-capi/ctest/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ int main(void) {
// free_string(hash) // dont need to free this since it's static
free_string(newhash);

assert (!verify_password_update_hash(hash, "not my password", &newhash));
printf("New hash: %s\n", newhash);
free_string(newhash);

printf("\x1b[1;32mC test passed\x1b[m\n");
return 0;
Expand Down
12 changes: 4 additions & 8 deletions libpasta-capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,11 @@ pub extern "C" fn verify_password_update_hash(hash: *const c_char, password: *co
assert!(!password.is_null());
CStr::from_ptr(password).to_str().unwrap()
};
if libpasta::verify_password_update_hash(&mut hash, password) {
unsafe {
*new_hash = CString::new(hash).unwrap().into_raw();
}
// mem::forget(hash);
true
} else {
false
let res = libpasta::verify_password_update_hash(&mut hash, password);
unsafe {
*new_hash = CString::new(hash).unwrap().into_raw();
}
res
}

#[no_mangle]
Expand Down

0 comments on commit dd722a8

Please sign in to comment.