mirror of
https://gitee.com/openharmony/security_asset
synced 2024-11-30 03:20:23 +00:00
fix vec capacity problem
Signed-off-by: zhangwenzhi <zhangwenzhi3@huawei.com>
This commit is contained in:
parent
5f500fa90e
commit
bb7bc19596
@ -30,5 +30,6 @@ void Sha256(const uint8_t* input, uint32_t intputLen, uint8_t* output)
|
||||
LOGE("invalid input for sha256");
|
||||
return;
|
||||
}
|
||||
|
||||
(void)SHA256((const unsigned char *)input, intputLen, (unsigned char *)output);
|
||||
}
|
||||
|
@ -142,9 +142,8 @@ const SHA256_OUTPUT_LEN: usize = 32;
|
||||
|
||||
/// the function to execute sha256 by openssl.
|
||||
fn sha256_new(message: &[u8]) -> Vec<u8> {
|
||||
let mut res = Vec::with_capacity(SHA256_OUTPUT_LEN);
|
||||
let mut res = vec![0; SHA256_OUTPUT_LEN];
|
||||
unsafe { Sha256(message.as_ptr(), message.len() as u32, res.as_mut_ptr()) }
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user