/* This function performs a symmetric encryption or decryption operation.  */
rt_err_t rt_hwcrypto_symmetric_crypt(struct rt_hwcrypto_ctx *ctx, hwcrypto_mode mode, rt_size_t length, const rt_uint8_t *in, rt_uint8_t *out)
/* This function performs a symmetric encryption or decryption operation.  */
rt_err_t rt_hwcrypto_symmetric_crypt(struct rt_hwcrypto_ctx *ctx, hwcrypto_mode mode, rt_size_t length, const rt_uint8_t *in, rt_uint8_t *out)
{
    struct hwcrypto_symmetric *symmetric_ctx;
    struct hwcrypto_symmetric_info symmetric_info;
    rt_err_t err;
    if (ctx == RT_NULL)
    {
        return -RT_EINVAL;
    }
    symmetric_ctx = (struct hwcrypto_symmetric *)ctx;
    if (symmetric_ctx->ops->crypt == RT_NULL)
    {
        return -RT_ERROR;
    }
    if (mode != HWCRYPTO_MODE_ENCRYPT && mode != HWCRYPTO_MODE_DECRYPT)
    {
        return -EINVAL;
    }
    symmetric_info.mode = mode;
    symmetric_info.in = in;
    symmetric_info.out = out;
    symmetric_info.length = length;
    err = symmetric_ctx->ops->crypt(symmetric_ctx, &symmetric_info);
    symmetric_ctx->flags &= ~(SYMMTRIC_MODIFY_KEY | SYMMTRIC_MODIFY_IV | SYMMTRIC_MODIFY_IVOFF);
    return err;
}