pub fn enc_upd_rt<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 ct_path = transform_file::<Scheme>(key.clone(), None, &pt_path, "encrypt");
    assert!(!diff_files(&pt_path, &ct_path));

    // Update
    let mut cur_ct_path = ct_path;
    let mut cur_key = key;
    for _ in 0..update_cnt {
        let newkey = Scheme::keygen();
        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 rec_path = transform_file::<Scheme>(cur_key, None, &cur_ct_path, "decrypt");

    // Useful for debugging.
    println!("Plaintext file: {}", &pt_path.display());
    println!("Ciphertext file: {}", &cur_ct_path.display());
    println!("Recovered file: {}", &rec_path.display());

    // Verify the result.
    assert!(diff_files(&pt_path, &rec_path));
}
// 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<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 ct_path = transform_file::<Scheme>(key.clone(), None, &pt_path, "encrypt");
    assert!(!diff_files(&pt_path, &ct_path));
    // Update
    let mut cur_ct_path = ct_path;
    let mut cur_key = key;
    for _ in 0..update_cnt {
        let newkey = Scheme::keygen();
        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 rec_path = transform_file::<Scheme>(cur_key, None, &cur_ct_path, "decrypt");
    // Useful for debugging.
    println!("Plaintext file: {}", &pt_path.display());
    println!("Ciphertext file: {}", &cur_ct_path.display());
    println!("Recovered file: {}", &rec_path.display());
    // Verify the result.
    assert!(diff_files(&pt_path, &rec_path));
}
pub fn enc_upd_rt < Scheme : UpEnc > ( pt_bytes : & [ u8 ] , update_cnt : u16 ) { test_setup ( ) ; let key = Scheme :: keygen ( ) ; // Write the input file let pt_path = get_tmp_fname ( " " ) ; create_test_file ( & pt_path , pt_bytes ) ; // Encrypt let ct_path = transform_file :: < Scheme > ( key . clone ( ) , None , & pt_path , " " ) ; assert ! ( diff_files ( pt_path ct_path ) ) ; // Update let mut cur_ct_path = ct_path ; let mut cur_key = key ; for _ in 0 .. update_cnt { let newkey = Scheme :: keygen ( ) ; transform_file :: < Scheme > ( cur_key , Some ( newkey . clone ( ) ) , & cur_ct_path , " " ) ; cur_ct_path = transform_file :: < Scheme > ( newkey . clone ( ) , None , & cur_ct_path , " " ) ; cur_key = newkey ; } // Decrypt let rec_path = transform_file :: < Scheme > ( cur_key , None , & cur_ct_path , " " ) ; // Useful for debugging. println ! ( " " pt_path display ( ) ) ; println ! ( " " cur_ct_path display ( ) ) ; println ! ( " " rec_path display ( ) ) ; // Verify the result. assert ! ( diff_files ( pt_path rec_path ) ) ; }
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
pt_bytes
&[u8]
update_cnt
u16