/// Updates the manifest of an image.
// TODO: This function must use a public key.
Updates the manifest of an image.
TODO: This function must use a public key.
Updates the manifest of an image . TODO : This function must use a public key .
fn update_image_manifest(image: &mut Image, key: &PrivateKey) -> Result<()> {
    *image.manifest = Manifest {
        identifier: 0x4552544f,
        image_length: u32::try_from(image.bytes().len())?,
        ..Default::default()
    };
    let exponent_be = key.public_exponent_be();
    let dest = image.manifest.exponent.as_bytes_mut().iter_mut();
    let src = exponent_be.iter().rev().copied();
    ensure!(dest.len() >= src.len(), "Unexpected exponent length.");
    for (d, s) in Iterator::zip(dest, src) {
        *d = s;
    }
    let modulus_be = key.public_modulus_be();
    let dest = image.manifest.modulus.as_bytes_mut().iter_mut();
    let src = modulus_be.iter().rev().copied();
    ensure!(dest.len() == src.len(), "Unexpected modulus length.");
    for (d, s) in Iterator::zip(dest, src) {
        *d = s;
    }
    Ok(())
}
fn update_image_manifest ( image : & mut Image , key : & PrivateKey ) -> Result < ( ) > { * image . manifest = Manifest { identifier : 0x4552544f , image_length : u32 :: try_from ( image . bytes ( ) . len ( ) ) ? , .. Default :: default ( ) } ; let exponent_be = key . public_exponent_be ( ) ; let dest = image . manifest . exponent . as_bytes_mut ( ) . iter_mut ( ) ; let src = exponent_be . iter ( ) . rev ( ) . copied ( ) ; ensure ! ( dest len ( ) src len ( ) " " ) ; for ( d , s ) in Iterator :: zip ( dest , src ) { * d = s ; } let modulus_be = key . public_modulus_be ( ) ; let dest = image . manifest . modulus . as_bytes_mut ( ) . iter_mut ( ) ; let src = modulus_be . iter ( ) . rev ( ) . copied ( ) ; ensure ! ( dest len ( ) src len ( ) " " ) ; for ( d , s ) in Iterator :: zip ( dest , src ) { * d = s ; } Ok ( ( ) ) }
Updates the manifest of an image.
Updates the manifest of an image .
image
&mut Image
key
&PrivateKey