feat: v1.1.11, piv sign works, add piv generate
This commit is contained in:
@@ -35,4 +35,25 @@ pub fn sha512_bytes(input: &[u8]) -> Vec<u8> {
|
||||
let mut challenge = Sha512::default();
|
||||
Digest::update(&mut challenge, input);
|
||||
challenge.finalize().to_vec()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! define_copy_array {
|
||||
($fn_name: ident, $len: tt) => (
|
||||
pub fn $fn_name(in_arr: &[u8]) -> rust_util::XResult<[u8; $len]> {
|
||||
if in_arr.len() != $len {
|
||||
return simple_error!("Array length is not: {}, but is: {}", $len, in_arr.len());
|
||||
}
|
||||
let mut out_arr = [0_u8; $len];
|
||||
for i in 0..$len {
|
||||
out_arr[i] = in_arr[i];
|
||||
}
|
||||
Ok(out_arr)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
define_copy_array!(copy_sha256, 0x20);
|
||||
define_copy_array!(copy_sha384, 0x30);
|
||||
define_copy_array!(copy_sha512, 0x40);
|
||||
|
||||
define_copy_array!(copy_rsa2048, 0x100);
|
||||
|
||||
Reference in New Issue
Block a user