|
@@ -78,6 +78,7 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n)
|
|
{
|
|
{
|
|
if (n)
|
|
if (n)
|
|
{
|
|
{
|
|
|
|
+ rt_memset(n->p, 0xFF, n->total);
|
|
rt_free(n->p);
|
|
rt_free(n->p);
|
|
n->sign = 0;
|
|
n->sign = 0;
|
|
n->total = 0;
|
|
n->total = 0;
|
|
@@ -144,9 +145,9 @@ int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int
|
|
* @param buf Buffer for the binary number
|
|
* @param buf Buffer for the binary number
|
|
* @param len Length of the buffer
|
|
* @param len Length of the buffer
|
|
*
|
|
*
|
|
- * @return RT_EOK on success.
|
|
|
|
|
|
+ * @return import length.
|
|
*/
|
|
*/
|
|
-rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
|
|
|
|
|
|
+int rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
|
|
{
|
|
{
|
|
int cp_len, i, j;
|
|
int cp_len, i, j;
|
|
void *temp_p;
|
|
void *temp_p;
|
|
@@ -162,11 +163,13 @@ rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf,
|
|
{
|
|
{
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
- rt_memset(temp_p, 0, len);
|
|
|
|
rt_free(n->p);
|
|
rt_free(n->p);
|
|
n->p = temp_p;
|
|
n->p = temp_p;
|
|
n->total = len;
|
|
n->total = len;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ n->sign = 1;
|
|
|
|
+ rt_memset(n->p, 0, n->total);
|
|
cp_len = n->total > len ? len : n->total;
|
|
cp_len = n->total > len ? len : n->total;
|
|
|
|
|
|
for(i = cp_len, j = 0; i > 0; i--, j++)
|
|
for(i = cp_len, j = 0; i > 0; i--, j++)
|