Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2 removing test case #17

Merged
merged 2 commits into from
Dec 28, 2023
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
18 changes: 0 additions & 18 deletions src/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,6 @@ pub extern "C" fn rsa_decrypt_bytes(
return result;
}

#[test]
fn rsa_decrypt_bytes_test() {
let data_to_hash = "This is a test hash";
let data_to_hash_bytes = data_to_hash.as_bytes();
let data_to_hash_length: usize = data_to_hash_bytes.len();
let key_pair = get_key_pair(4096);
let encryped = rsa_encrypt_bytes(key_pair.pub_key, data_to_hash_bytes.as_ptr(), data_to_hash_length);
let decrypred = rsa_decrypt_bytes(key_pair.priv_key, encryped.encrypted_result_ptr, encryped.length);
unsafe {
let size_of_result = std::mem::size_of_val(&decrypred.decrypted_result_ptr);
let result_raw_ptr = libc::malloc(size_of_result) as *mut c_uchar;
std::ptr::copy_nonoverlapping(decrypred.decrypted_result_ptr, result_raw_ptr, size_of_result);
let mut_slice = std::slice::from_raw_parts(result_raw_ptr, size_of_result);
assert_eq!(data_to_hash_bytes, mut_slice);
}

}

#[no_mangle]
pub extern "C" fn get_key_pair(key_size: usize) -> RsaKeyPair {
let mut rng: OsRng = OsRng;
Expand Down