Skip to content

Commit 116bef8

Browse files
committed
#50 fixing test cases
1 parent 3d352c8 commit 116bef8

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/aes.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,11 @@ pub fn aes_256_key_and_nonce_from_x25519_diffie_hellman_shared_secret_test() {
111111
bob_shared_secret.shared_secret_length,
112112
);
113113

114-
115-
116-
let alice_public_key_cstr = unsafe { CString::from_raw(alice_aes.aes_key_ptr) };
117-
let alice_public_key_ptr = alice_public_key_cstr.as_bytes_with_nul().as_ptr() as *const c_char;
118-
119114
let password = "DontUseThisPassword";
120115
let password_cstr = password.as_bytes();
121116
let password_ptr = password.as_ptr();
122-
let cipher_text_result = aes_256_encrypt_bytes_with_key(alice_aes.aes_nonce_ptr, alice_aes.aes_nonce_ptr_length, alice_public_key_ptr, password_ptr, password_cstr.len());
123-
let plain_text_result = aes_256_decrypt_bytes_with_key(bob_aes.aes_nonce_ptr, bob_aes.aes_nonce_ptr_length, bob_aes.aes_key_ptr, cipher_text_result.ciphertext, cipher_text_result.length);
117+
let cipher_text_result = aes_256_encrypt_bytes_with_key(alice_aes.aes_nonce_ptr, alice_aes.aes_nonce_ptr_length, alice_aes.aes_key_ptr, alice_aes.aes_key_ptr_length, password_ptr, password_cstr.len());
118+
let plain_text_result = aes_256_decrypt_bytes_with_key(bob_aes.aes_nonce_ptr, bob_aes.aes_nonce_ptr_length, bob_aes.aes_key_ptr, bob_aes.aes_key_ptr_length, cipher_text_result.ciphertext, cipher_text_result.length);
124119
let plain_text_result_slice: &[u8] = unsafe {
125120
std::slice::from_raw_parts(
126121
plain_text_result.plaintext,
@@ -203,15 +198,11 @@ pub fn aes_128_key_and_nonce_from_x25519_diffie_hellman_shared_secret_test() {
203198
bob_shared_secret.shared_secret_length,
204199
);
205200

206-
207-
let alice_public_key_cstr = unsafe { CString::from_raw(alice_aes.aes_key_ptr) };
208-
let alice_public_key_ptr = alice_public_key_cstr.as_bytes_with_nul().as_ptr() as *const c_char;
209-
210201
let password = "DontUseThisPassword";
211202
let password_cstr = password.as_bytes();
212203
let password_ptr = password.as_ptr();
213-
let cipher_text_result = aes_128_encrypt_bytes_with_key(alice_aes.aes_nonce_ptr, alice_aes.aes_nonce_ptr_length, alice_public_key_ptr, password_ptr, password_cstr.len());
214-
let plain_text_result = aes_128_decrypt_bytes_with_key(bob_aes.aes_nonce_ptr, bob_aes.aes_nonce_ptr_length, bob_aes.aes_key_ptr, cipher_text_result.ciphertext, cipher_text_result.length);
204+
let cipher_text_result = aes_128_encrypt_bytes_with_key(alice_aes.aes_nonce_ptr, alice_aes.aes_nonce_ptr_length, alice_aes.aes_key_ptr, alice_aes.aes_key_ptr_length, password_ptr, password_cstr.len());
205+
let plain_text_result = aes_128_decrypt_bytes_with_key(bob_aes.aes_nonce_ptr, bob_aes.aes_nonce_ptr_length, bob_aes.aes_key_ptr, bob_aes.aes_key_ptr_length, cipher_text_result.ciphertext, cipher_text_result.length);
215206
let plain_text_result_slice: &[u8] = unsafe {
216207
std::slice::from_raw_parts(
217208
plain_text_result.plaintext,

0 commit comments

Comments
 (0)