* Copyright 2022 Bytedance CO., LTD.
   */
 
-#include <linux/mpi.h>
-#include <linux/scatterlist.h>
-#include <crypto/algapi.h>
+#include <crypto/engine.h>
 #include <crypto/internal/akcipher.h>
 #include <crypto/internal/rsa.h>
-#include <linux/err.h>
 #include <crypto/scatterwalk.h>
-#include <linux/atomic.h>
-
+#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/mpi.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/string.h>
 #include <uapi/linux/virtio_crypto.h>
 #include "virtio_crypto_common.h"
 
 };
 
 struct virtio_crypto_akcipher_ctx {
-       struct crypto_engine_ctx enginectx;
        struct virtio_crypto *vcrypto;
        struct crypto_akcipher *tfm;
        bool session_valid;
        uint32_t algonum;
        uint32_t service;
        unsigned int active_devs;
-       struct akcipher_alg algo;
+       struct akcipher_engine_alg algo;
 };
 
 static DEFINE_MUTEX(algs_lock);
        struct virtio_crypto_akcipher_ctx *ctx = akcipher_tfm_ctx(tfm);
 
        ctx->tfm = tfm;
-       ctx->enginectx.op.do_one_request = virtio_crypto_rsa_do_req;
 
        akcipher_set_reqsize(tfm,
                             sizeof(struct virtio_crypto_akcipher_request));
        {
                .algonum = VIRTIO_CRYPTO_AKCIPHER_RSA,
                .service = VIRTIO_CRYPTO_SERVICE_AKCIPHER,
-               .algo = {
+               .algo.base = {
                        .encrypt = virtio_crypto_rsa_encrypt,
                        .decrypt = virtio_crypto_rsa_decrypt,
                        .set_pub_key = virtio_crypto_rsa_raw_set_pub_key,
                                .cra_ctxsize = sizeof(struct virtio_crypto_akcipher_ctx),
                        },
                },
+               .algo.op = {
+                       .do_one_request = virtio_crypto_rsa_do_req,
+               },
        },
        {
                .algonum = VIRTIO_CRYPTO_AKCIPHER_RSA,
                .service = VIRTIO_CRYPTO_SERVICE_AKCIPHER,
-               .algo = {
+               .algo.base = {
                        .encrypt = virtio_crypto_rsa_encrypt,
                        .decrypt = virtio_crypto_rsa_decrypt,
                        .sign = virtio_crypto_rsa_sign,
                                .cra_ctxsize = sizeof(struct virtio_crypto_akcipher_ctx),
                        },
                },
+               .algo.op = {
+                       .do_one_request = virtio_crypto_rsa_do_req,
+               },
        },
 };
 
                        continue;
 
                if (virtio_crypto_akcipher_algs[i].active_devs == 0) {
-                       ret = crypto_register_akcipher(&virtio_crypto_akcipher_algs[i].algo);
+                       ret = crypto_engine_register_akcipher(&virtio_crypto_akcipher_algs[i].algo);
                        if (ret)
                                goto unlock;
                }
 
                virtio_crypto_akcipher_algs[i].active_devs++;
                dev_info(&vcrypto->vdev->dev, "Registered akcipher algo %s\n",
-                        virtio_crypto_akcipher_algs[i].algo.base.cra_name);
+                        virtio_crypto_akcipher_algs[i].algo.base.base.cra_name);
        }
 
 unlock:
                        continue;
 
                if (virtio_crypto_akcipher_algs[i].active_devs == 1)
-                       crypto_unregister_akcipher(&virtio_crypto_akcipher_algs[i].algo);
+                       crypto_engine_unregister_akcipher(&virtio_crypto_akcipher_algs[i].algo);
 
                virtio_crypto_akcipher_algs[i].active_devs--;
        }
 
   * Copyright 2016 HUAWEI TECHNOLOGIES CO., LTD.
   */
 
-#include <linux/scatterlist.h>
-#include <crypto/algapi.h>
+#include <crypto/engine.h>
 #include <crypto/internal/skcipher.h>
-#include <linux/err.h>
 #include <crypto/scatterwalk.h>
-#include <linux/atomic.h>
-
+#include <linux/err.h>
+#include <linux/scatterlist.h>
 #include <uapi/linux/virtio_crypto.h>
 #include "virtio_crypto_common.h"
 
 
 struct virtio_crypto_skcipher_ctx {
-       struct crypto_engine_ctx enginectx;
        struct virtio_crypto *vcrypto;
        struct crypto_skcipher *tfm;
 
        uint32_t algonum;
        uint32_t service;
        unsigned int active_devs;
-       struct skcipher_alg algo;
+       struct skcipher_engine_alg algo;
 };
 
 /*
        crypto_skcipher_set_reqsize(tfm, sizeof(struct virtio_crypto_sym_request));
        ctx->tfm = tfm;
 
-       ctx->enginectx.op.do_one_request = virtio_crypto_skcipher_crypt_req;
        return 0;
 }
 
 static struct virtio_crypto_algo virtio_crypto_algs[] = { {
        .algonum = VIRTIO_CRYPTO_CIPHER_AES_CBC,
        .service = VIRTIO_CRYPTO_SERVICE_CIPHER,
-       .algo = {
+       .algo.base = {
                .base.cra_name          = "cbc(aes)",
                .base.cra_driver_name   = "virtio_crypto_aes_cbc",
                .base.cra_priority      = 150,
                .max_keysize            = AES_MAX_KEY_SIZE,
                .ivsize                 = AES_BLOCK_SIZE,
        },
+       .algo.op = {
+               .do_one_request = virtio_crypto_skcipher_crypt_req,
+       },
 } };
 
 int virtio_crypto_skcipher_algs_register(struct virtio_crypto *vcrypto)
                        continue;
 
                if (virtio_crypto_algs[i].active_devs == 0) {
-                       ret = crypto_register_skcipher(&virtio_crypto_algs[i].algo);
+                       ret = crypto_engine_register_skcipher(&virtio_crypto_algs[i].algo);
                        if (ret)
                                goto unlock;
                }
 
                virtio_crypto_algs[i].active_devs++;
                dev_info(&vcrypto->vdev->dev, "Registered algo %s\n",
-                        virtio_crypto_algs[i].algo.base.cra_name);
+                        virtio_crypto_algs[i].algo.base.base.cra_name);
        }
 
 unlock:
                        continue;
 
                if (virtio_crypto_algs[i].active_devs == 1)
-                       crypto_unregister_skcipher(&virtio_crypto_algs[i].algo);
+                       crypto_engine_unregister_skcipher(&virtio_crypto_algs[i].algo);
 
                virtio_crypto_algs[i].active_devs--;
        }