// Runs create-encrypt-update-decrypt-diff on the given plaintext bytes
// using a random keys.
Runs create-encrypt-update-decrypt-diff on the given plaintext bytes
using a random keys.
Runs create - encrypt - update - decrypt - diff on the given plaintext bytes using a random keys .
pub fn enc_upd_rt_buffer<Scheme: UpEnc>(pt_bytes: &[u8], update_cnt: u16) {
    test_setup();
    let key = Scheme::keygen();
    // // Write the input file
    // let pt_path = get_tmp_fname("upenc");
    // create_test_file(&pt_path, pt_bytes);
    // Encrypt
    let mut ct_hdr = Vec::new();
    let mut ct_body= Vec::new();
    Scheme::encrypt(key.clone(), &mut (&pt_bytes[..]), &mut ct_hdr, &mut ct_body).unwrap();
    // println!("({:?}, {:?})", ct_hdr, ct_body);
    assert!(ct_body != pt_bytes);
    // Update
    let mut cur_key = key;
    for _ in 0..update_cnt {
        let newkey = Scheme::keygen();
        let mut upd_hdr = Vec::new();
        let mut upd_body = Vec::new();
        let mut rk_buf = Vec::new();
        Scheme::rekeygen(cur_key, newkey.clone(), &mut (&ct_hdr[..]), &mut rk_buf).unwrap();
        Scheme::reencrypt(&mut (&rk_buf[..]), &mut (&ct_hdr[..]), &mut (&ct_body[..]), &mut upd_hdr, &mut upd_body).unwrap();
        ct_hdr = upd_hdr;
        ct_body = upd_body;
        // transform_file::<Scheme>(cur_key, Some(newkey.clone()), &cur_ct_path, "rekeygen");
        // cur_ct_path = transform_file::<Scheme>(newkey.clone(), None, &cur_ct_path, "reencrypt");
        cur_key = newkey;
    }
    // Decrypt
    let mut pt_buf = Vec::new();
    Scheme::decrypt(cur_key, &mut (&ct_hdr[..]), &mut (&ct_body[..]), &mut pt_buf).unwrap();
    // let rec_path = transform_file::<Scheme>(cur_key, None, &cur_ct_path, "decrypt");
    assert_eq!(pt_bytes, &pt_buf[..]);
}
pub fn enc_upd_rt_buffer < Scheme : UpEnc > ( pt_bytes : & [ u8 ] , update_cnt : u16 ) { test_setup ( ) ; let key = Scheme :: keygen ( ) ; // // Write the input file // let pt_path = get_tmp_fname("upenc"); // create_test_file(&pt_path, pt_bytes); // Encrypt let mut ct_hdr = Vec :: new ( ) ; let mut ct_body = Vec :: new ( ) ; Scheme :: encrypt ( key . clone ( ) , & mut ( & pt_bytes [ .. ] ) , & mut ct_hdr , & mut ct_body ) . unwrap ( ) ; // println!("({:?}, {:?})", ct_hdr, ct_body); assert ! ( ct_body pt_bytes ) ; // Update let mut cur_key = key ; for _ in 0 .. update_cnt { let newkey = Scheme :: keygen ( ) ; let mut upd_hdr = Vec :: new ( ) ; let mut upd_body = Vec :: new ( ) ; let mut rk_buf = Vec :: new ( ) ; Scheme :: rekeygen ( cur_key , newkey . clone ( ) , & mut ( & ct_hdr [ .. ] ) , & mut rk_buf ) . unwrap ( ) ; Scheme :: reencrypt ( & mut ( & rk_buf [ .. ] ) , & mut ( & ct_hdr [ .. ] ) , & mut ( & ct_body [ .. ] ) , & mut upd_hdr , & mut upd_body ) . unwrap ( ) ; ct_hdr = upd_hdr ; ct_body = upd_body ; // transform_file::<Scheme>(cur_key, Some(newkey.clone()), &cur_ct_path, "rekeygen"); // cur_ct_path = transform_file::<Scheme>(newkey.clone(), None, &cur_ct_path, "reencrypt"); cur_key = newkey ; } // Decrypt let mut pt_buf = Vec :: new ( ) ; Scheme :: decrypt ( cur_key , & mut ( & ct_hdr [ .. ] ) , & mut ( & ct_body [ .. ] ) , & mut pt_buf ) . unwrap ( ) ; // let rec_path = transform_file::<Scheme>(cur_key, None, &cur_ct_path, "decrypt"); assert_eq ! ( pt_bytes pt_buf [ ] ) ; }
Runs create-encrypt-update-decrypt-diff on the given plaintext bytes
using a random keys.
Runs create - encrypt - update - decrypt - diff on the given plaintext bytes using a random keys .
pt_bytes
&[u8]
update_cnt
u16