pub fn sign_file(image_filename: &str, key: SigningKey) -> Result<usize, Error> {
    let mut file = open_image(image_filename)?;
    let plaintext = read_file(&mut file)?;
    let signature = key.sign(&plaintext);
    let bytes_written =
        file.write(signature.as_bytes()).map_err(|_| Error::FileWriteFailed(error::File::Image))?;

    if bytes_written == signature.as_bytes().len() {
        Ok(bytes_written)
    } else {
        Err(Error::FileWriteFailed(error::File::Image))
    }
}
/// Reads the contents of `file` and signs it using P256 ECDSA/SHA256 with the key in `key_file`.
Reads the contents of `file` and signs it using P256 ECDSA/SHA256 with the key in `key_file`.
Reads the contents of ` file ` and signs it using P256 ECDSA / SHA256 with the key in ` key_file ` .
pub fn sign_file(image_filename: &str, key: SigningKey) -> Result<usize, Error> {
    let mut file = open_image(image_filename)?;
    let plaintext = read_file(&mut file)?;
    let signature = key.sign(&plaintext);
    let bytes_written =
        file.write(signature.as_bytes()).map_err(|_| Error::FileWriteFailed(error::File::Image))?;
    if bytes_written == signature.as_bytes().len() {
        Ok(bytes_written)
    } else {
        Err(Error::FileWriteFailed(error::File::Image))
    }
}
pub fn sign_file ( image_filename : & str , key : SigningKey ) -> Result < usize , Error > { let mut file = open_image ( image_filename ) ? ; let plaintext = read_file ( & mut file ) ? ; let signature = key . sign ( & plaintext ) ; let bytes_written = file . write ( signature . as_bytes ( ) ) . map_err ( | _ | Error :: FileWriteFailed ( error :: File :: Image ) ) ? ; if bytes_written == signature . as_bytes ( ) . len ( ) { Ok ( bytes_written ) } else { Err ( Error :: FileWriteFailed ( error :: File :: Image ) ) } }
Reads the contents of `file` and signs it using P256 ECDSA/SHA256 with the key in `key_file`.
Reads the contents of ` file ` and signs it using P256 ECDSA / SHA256 with the key in ` key_file ` .
image_filename
&str
key
SigningKey
image_filename
&str
key
SigningKey