/* Setting context type (Direct calls are not recommended) 
Change Logs: Date Author Notes  tyx the first version */
rt_err_t rt_hwcrypto_set_type(struct rt_hwcrypto_ctx *ctx, hwcrypto_type type)
/* Setting context type (Direct calls are not recommended) 
Change Logs: Date Author Notes  tyx the first version */
rt_err_t rt_hwcrypto_set_type(struct rt_hwcrypto_ctx *ctx, hwcrypto_type type)
{
    if (ctx)
    {
        if ((ctx->type & HWCRYPTO_MAIN_TYPE_MASK) == (type & HWCRYPTO_MAIN_TYPE_MASK))
        {
            ctx->type = type;
            return RT_EOK;
        }
        else if (ctx->type == HWCRYPTO_TYPE_NULL)
        {
            ctx->type = type;
            return RT_EOK;
        }
        else
        {
            return -RT_ERROR;
        }
    }
    return -RT_EINVAL;
}