/* Import n from unsigned binary data, big endian.  */
rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
/* Import n from unsigned binary data, big endian.  */
rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
{
    int cp_len, i, j;
    void *temp_p;
    if (n == RT_NULL || buf == RT_NULL)
    {
        return 0;
    }
    if (n->total < len)
    {
        temp_p = rt_malloc(len);
        if (temp_p == RT_NULL)
        {
            return 0;
        }
        rt_memset(temp_p, 0, len);
        rt_free(n->p);
        n->p = temp_p;
        n->total = len;
    }
    cp_len = n->total > len ? len : n->total;
    for(i = cp_len, j = 0; i > 0; i--, j++)
    {
        n->p[j] = buf[i - 1];
    }
    return cp_len;
}