mirror of
https://gitee.com/openharmony/security_huks
synced 2024-12-14 01:59:03 +00:00
commit
e5c343e076
@ -35,12 +35,6 @@ int32_t hks_bn_export(const mbedtls_mpi *bn, unsigned char *data, size_t size)
|
||||
return mbedtls_mpi_write_binary(bn, data, size);
|
||||
}
|
||||
|
||||
int32_t hks_bn_write_string(const mbedtls_mpi *bn, int radix,
|
||||
char *buf, size_t buf_len, size_t *o_len)
|
||||
{
|
||||
return mbedtls_mpi_write_string(bn, radix, buf, buf_len, o_len);
|
||||
}
|
||||
|
||||
int32_t hks_bn_mpi_exp_mod(mbedtls_mpi *x, const mbedtls_mpi *a,
|
||||
const mbedtls_mpi *e, const mbedtls_mpi *n)
|
||||
{
|
||||
|
@ -32,7 +32,4 @@ int32_t hks_bn_export(const mbedtls_mpi *bn, unsigned char *data, size_t size);
|
||||
int32_t hks_bn_mpi_exp_mod(mbedtls_mpi *x, const mbedtls_mpi *a,
|
||||
const mbedtls_mpi *e, const mbedtls_mpi *n);
|
||||
|
||||
int32_t hks_bn_write_string(const mbedtls_mpi *bn, int radix, char *buf,
|
||||
size_t buf_len, size_t *o_len);
|
||||
|
||||
#endif /* HKS_BN_H */
|
||||
|
@ -324,89 +324,6 @@ int32_t hks_u8_buf_2_u32(const uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
return HKS_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert uint64 variable to uint8 buffer data.
|
||||
* parameter:
|
||||
* u64_var - [in] - uint64 variable.
|
||||
* u8_buf - [out] - uint8 buffer.
|
||||
* u8_buf_len - [in] - uint8 buffer length.
|
||||
* u8_buf_offset - [in/out] - uint8 buffer offset.
|
||||
* return value:
|
||||
* success or error code.
|
||||
*/
|
||||
int32_t hks_u64_2_u8_buf(uint64_t u64_var, uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
uint32_t *u8_buf_offset)
|
||||
{
|
||||
int32_t rc = hks_chk_u8_buf_para(HKS_U64_BYTE_NUM, u8_buf, u8_buf_len, u8_buf_offset);
|
||||
|
||||
if (rc != HKS_STATUS_OK)
|
||||
return rc;
|
||||
|
||||
uint8_t endian = hks_get_endian();
|
||||
|
||||
union hks_u8_u64 tmp;
|
||||
|
||||
tmp.u64_var = u64_var;
|
||||
|
||||
uint32_t i = 0;
|
||||
|
||||
for (; i < HKS_U64_BYTE_NUM; i++) {
|
||||
uint32_t offset = *u8_buf_offset + g_hks_u64_byte_offset[endian][i];
|
||||
|
||||
if (offset >= u8_buf_len) {
|
||||
log_error("impossible error,offset=%u,buf_offset=%u, buf_len=%u", offset, *u8_buf_offset, u8_buf_len);
|
||||
return HKS_ERROR_INTERNAL_UNKOWN;
|
||||
}
|
||||
u8_buf[offset] = tmp.u8_var[i];
|
||||
}
|
||||
*u8_buf_offset += HKS_U64_BYTE_NUM;
|
||||
|
||||
return HKS_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert uint8 buffer data to uint64 variable.
|
||||
* parameter:
|
||||
* u8_buf - [in] - uint8 buffer.
|
||||
* u8_buf_len - [in] - uint8 buffer length.
|
||||
* u8_buf_offset - [in/out] - uint8 buffer offset.
|
||||
* u64_var - [out] - uint64 variable.
|
||||
* return value:
|
||||
* success or error code.
|
||||
*/
|
||||
int32_t hks_u8_buf_2_u64(const uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
uint32_t *u8_buf_offset, uint64_t *u64_var)
|
||||
{
|
||||
if (u64_var == NULL) {
|
||||
log_error("invalid u64 var");
|
||||
return HKS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
int32_t rc = hks_chk_u8_buf_para(HKS_U64_BYTE_NUM, u8_buf, u8_buf_len, u8_buf_offset);
|
||||
|
||||
if (rc != HKS_STATUS_OK)
|
||||
return rc;
|
||||
|
||||
uint8_t endian = hks_get_endian();
|
||||
|
||||
union hks_u8_u64 tmp;
|
||||
uint32_t i = 0;
|
||||
|
||||
for (; i < HKS_U64_BYTE_NUM; i++) {
|
||||
uint32_t offset = *u8_buf_offset + g_hks_u64_byte_offset[endian][i];
|
||||
|
||||
if (offset >= u8_buf_len) {
|
||||
log_error("impossible error,offset=%u,buf_offset=%u, buf_len=%u", offset, *u8_buf_offset, u8_buf_len);
|
||||
return HKS_ERROR_INTERNAL_UNKOWN;
|
||||
}
|
||||
tmp.u8_var[i] = u8_buf[offset];
|
||||
}
|
||||
*u64_var = tmp.u64_var;
|
||||
*u8_buf_offset += HKS_U64_BYTE_NUM;
|
||||
|
||||
return HKS_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert uint8 variable to uint8 buffer data.
|
||||
* parameter:
|
||||
|
@ -162,32 +162,6 @@ int32_t hks_u32_2_u8_buf(uint32_t u32_var, uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
int32_t hks_u8_buf_2_u32(const uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
uint32_t *u8_buf_offset, uint32_t *u32_var);
|
||||
|
||||
/*
|
||||
* convert uint64 variable to uint8 buffer data.
|
||||
* parameter:
|
||||
* u64_var - [in] - uint64 variable.
|
||||
* u8_buf - [out] - uint8 buffer.
|
||||
* u8_buf_len - [in] - uint8 buffer length.
|
||||
* u8_buf_offset - [in/out] - uint8 buffer offset.
|
||||
* return value:
|
||||
* success or error code.
|
||||
*/
|
||||
int32_t hks_u64_2_u8_buf(uint64_t u64_var, uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
uint32_t *u8_buf_offset);
|
||||
|
||||
/*
|
||||
* convert uint8 buffer data to uint64 variable.
|
||||
* parameter:
|
||||
* u8_buf - [in] - uint8 buffer.
|
||||
* u8_buf_len - [in] - uint8 buffer length.
|
||||
* u8_buf_offset - [in/out] - uint8 buffer offset.
|
||||
* u64_var - [out] - uint64 variable.
|
||||
* return value:
|
||||
* success or error code.
|
||||
*/
|
||||
int32_t hks_u8_buf_2_u64(const uint8_t *u8_buf, uint32_t u8_buf_len,
|
||||
uint32_t *u8_buf_offset, uint64_t *u64_var);
|
||||
|
||||
/*
|
||||
* convert uint8 variable to uint8 buffer data.
|
||||
* parameter:
|
||||
|
@ -131,20 +131,6 @@ static int32_t hks_file_init_data(const char *file_name, uint32_t file_size,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* cancel callbacks
|
||||
* parameter: none
|
||||
* return value: none
|
||||
*/
|
||||
void hks_file_cancel_callbacks(void)
|
||||
{
|
||||
g_file_callbacks.file_size = NULL;
|
||||
g_file_callbacks.read = NULL;
|
||||
g_file_callbacks.write = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* delete file safely
|
||||
* parameter:
|
||||
|
@ -38,13 +38,6 @@ int32_t hks_file_write(const char *file_name, uint32_t offset,
|
||||
|
||||
int32_t hks_file_size(const char *file_name, uint32_t *size);
|
||||
|
||||
/*
|
||||
* cancel callbacks
|
||||
* parameter: none
|
||||
* return value: none
|
||||
*/
|
||||
void hks_file_cancel_callbacks(void);
|
||||
|
||||
/*
|
||||
* delete file safely
|
||||
* parameter:
|
||||
|
Loading…
Reference in New Issue
Block a user