Building a clean cryptg
hi, i am trying to build a general perpose cryptg so it can be imported in any platform and be use anywere, i think i almost got it, but i am getting an error when importing and using it in python using CDLL , the import is fine but when i call the function "encrypt_ige" i get "OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF" i could realy use your help. here is the code:
/// Encrypts the input plain text with the 32 bytes key and IV.
#[no_mangle]
fn encrypt_ige(plain: &[u8], key: &[u8], iv: &[u8]) -> Vec<u8> {
let mut key_array = [0; 32];
key_array.copy_from_slice(key);
let mut iv_array = [0; 32];
iv_array.copy_from_slice(iv);
let cipher = grammers_crypto::encrypt_ige(plain, &key_array, &iv_array);
return cipher;
}
/// Decrypts the input cipher text with the 32 bytes key and IV.
#[no_mangle]
fn decrypt_ige(cipher: &[u8], key: &[u8], iv: &[u8]) -> Vec<u8> {
let mut key_array = [0; 32];
key_array.copy_from_slice(key);
let mut iv_array = [0; 32];
iv_array.copy_from_slice(iv);
let plain = grammers_crypto::decrypt_ige(cipher, &key_array, &iv_array);
return plain;
}
/// Factorizes the pair of primes ``pq`` into ``(p, q)``.
#[no_mangle]
fn factorize_pq_pair(pq: u64) -> (u64, u64) {
grammers_crypto::factorize::factorize(pq)
}
thank you very mush for your help.
You will probably have to use a debugger to find out the root cause. The code itself seems fine. I don't think we can offer much help, but you would need to provide more details (how are you compiling it? how are you running it? what operating system? platform? version of the compiler? of the library?) if you want others to be able to follow along.