Use rust to calculate sha

This commit is contained in:
LoveSy
2023-06-25 03:50:21 +08:00
committed by John Wu
parent 46770db18b
commit 1f7c3e9f14
11 changed files with 155 additions and 29 deletions
+10
View File
@@ -5,6 +5,7 @@ pub use base;
use cpio::cpio_commands;
use patch::{hexpatch, patch_encryption, patch_verity};
use payload::extract_boot_from_payload;
use sha::{get_sha, sha_digest, SHA};
mod cpio;
mod patch;
@@ -13,6 +14,7 @@ mod payload;
#[allow(warnings)]
mod proto;
mod ramdisk;
mod sha;
#[cxx::bridge]
pub mod ffi {
@@ -37,4 +39,12 @@ pub mod ffi {
unsafe fn cpio_commands(argc: i32, argv: *const *const c_char) -> bool;
}
extern "Rust" {
type SHA;
fn get_sha(use_sha1: bool) -> Box<SHA>;
fn finalize(&mut self) -> Vec<u8>;
fn update(&mut self, data: &[u8]);
fn sha_digest(data: &[u8], use_sha1: bool) -> Vec<u8>;
}
}