/* Writes a re-keying token to a file for a pair of keys and a ciphertext */
Writes a re-keying token to a file for a pair of keys and a ciphertext
Writes a re - keying token to a file for a pair of keys and a ciphertext
fn rekeygen<In: Read, Out: Write>(k1: Self::K, k2: Self::K, ct_hdr: &mut In, token: &mut Out) -> Result<()> {
        let mut buf = Vec::new();
        // buf contains chi || tau
        A::decrypt(k1, ct_hdr, &mut buf)?;
        let x_new = KhPrf::keygen();
        let y_new = KhPrf::keygen();
        let mut reader = Cursor::new(buf);
        let chi = KhKey::read_key(&mut reader)?;
        let chi_new = &chi + &(&x_new + &y_new);
        buf = Vec::new();
        // buf contains chi'
        chi_new.write_key(&mut buf)?;
        let mut tau = Vec::new();
        reader.read_to_end(&mut tau)?;
        let tau_new = kh_prf::update_block(x_new.0, &tau, 0);
        buf.extend_from_slice(&tau_new);
        // buf should contain (chi' || tau')
        // Write out to token x', y'
        x_new.write_key(token)?;
        y_new.write_key(token)?;
        // Write out to token E(k2, chi' || tau)
        A::encrypt(k2, &mut (&buf[..]), token)
    }
fn rekeygen < In : Read , Out : Write > ( k1 : Self :: K , k2 : Self :: K , ct_hdr : & mut In , token : & mut Out ) -> Result < ( ) > { let mut buf = Vec :: new ( ) ; // buf contains chi || tau A :: decrypt ( k1 , ct_hdr , & mut buf ) ? ; let x_new = KhPrf :: keygen ( ) ; let y_new = KhPrf :: keygen ( ) ; let mut reader = Cursor :: new ( buf ) ; let chi = KhKey :: read_key ( & mut reader ) ? ; let chi_new = & chi + & ( & x_new + & y_new ) ; buf = Vec :: new ( ) ; // buf contains chi' chi_new . write_key ( & mut buf ) ? ; let mut tau = Vec :: new ( ) ; reader . read_to_end ( & mut tau ) ? ; let tau_new = kh_prf :: update_block ( x_new . 0 , & tau , 0 ) ; buf . extend_from_slice ( & tau_new ) ; // buf should contain (chi' || tau') // Write out to token x', y' x_new . write_key ( token ) ? ; y_new . write_key ( token ) ? ; // Write out to token E(k2, chi' || tau) A :: encrypt ( k2 , & mut ( & buf [ .. ] ) , token ) }
Writes a re-keying token to a file for a pair of keys and a ciphertext
Writes a re - keying token to a file for a pair of keys and a ciphertext
k1
Self::K
k2
Self::K
ct_hdr
&mut In
token
&mut Out