77 * Copyright 2022 Bytedance CO., LTD.
88 */
99
10- #include <linux/mpi.h>
11- #include <linux/scatterlist.h>
12- #include <crypto/algapi.h>
10+ #include <crypto/engine.h>
1311#include <crypto/internal/akcipher.h>
1412#include <crypto/internal/rsa.h>
15- #include <linux/err.h>
1613#include <crypto/scatterwalk.h>
17- #include <linux/atomic.h>
18-
14+ #include <linux/err.h>
15+ #include <linux/kernel.h>
16+ #include <linux/mpi.h>
17+ #include <linux/scatterlist.h>
18+ #include <linux/slab.h>
19+ #include <linux/string.h>
1920#include <uapi/linux/virtio_crypto.h>
2021#include "virtio_crypto_common.h"
2122
@@ -24,7 +25,6 @@ struct virtio_crypto_rsa_ctx {
2425};
2526
2627struct virtio_crypto_akcipher_ctx {
27- struct crypto_engine_ctx enginectx ;
2828 struct virtio_crypto * vcrypto ;
2929 struct crypto_akcipher * tfm ;
3030 bool session_valid ;
@@ -47,7 +47,7 @@ struct virtio_crypto_akcipher_algo {
4747 uint32_t algonum ;
4848 uint32_t service ;
4949 unsigned int active_devs ;
50- struct akcipher_alg algo ;
50+ struct akcipher_engine_alg algo ;
5151};
5252
5353static DEFINE_MUTEX (algs_lock );
@@ -475,7 +475,6 @@ static int virtio_crypto_rsa_init_tfm(struct crypto_akcipher *tfm)
475475 struct virtio_crypto_akcipher_ctx * ctx = akcipher_tfm_ctx (tfm );
476476
477477 ctx -> tfm = tfm ;
478- ctx -> enginectx .op .do_one_request = virtio_crypto_rsa_do_req ;
479478
480479 akcipher_set_reqsize (tfm ,
481480 sizeof (struct virtio_crypto_akcipher_request ));
@@ -498,7 +497,7 @@ static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
498497 {
499498 .algonum = VIRTIO_CRYPTO_AKCIPHER_RSA ,
500499 .service = VIRTIO_CRYPTO_SERVICE_AKCIPHER ,
501- .algo = {
500+ .algo . base = {
502501 .encrypt = virtio_crypto_rsa_encrypt ,
503502 .decrypt = virtio_crypto_rsa_decrypt ,
504503 .set_pub_key = virtio_crypto_rsa_raw_set_pub_key ,
@@ -514,11 +513,14 @@ static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
514513 .cra_ctxsize = sizeof (struct virtio_crypto_akcipher_ctx ),
515514 },
516515 },
516+ .algo .op = {
517+ .do_one_request = virtio_crypto_rsa_do_req ,
518+ },
517519 },
518520 {
519521 .algonum = VIRTIO_CRYPTO_AKCIPHER_RSA ,
520522 .service = VIRTIO_CRYPTO_SERVICE_AKCIPHER ,
521- .algo = {
523+ .algo . base = {
522524 .encrypt = virtio_crypto_rsa_encrypt ,
523525 .decrypt = virtio_crypto_rsa_decrypt ,
524526 .sign = virtio_crypto_rsa_sign ,
@@ -536,6 +538,9 @@ static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
536538 .cra_ctxsize = sizeof (struct virtio_crypto_akcipher_ctx ),
537539 },
538540 },
541+ .algo .op = {
542+ .do_one_request = virtio_crypto_rsa_do_req ,
543+ },
539544 },
540545};
541546
@@ -554,14 +559,14 @@ int virtio_crypto_akcipher_algs_register(struct virtio_crypto *vcrypto)
554559 continue ;
555560
556561 if (virtio_crypto_akcipher_algs [i ].active_devs == 0 ) {
557- ret = crypto_register_akcipher (& virtio_crypto_akcipher_algs [i ].algo );
562+ ret = crypto_engine_register_akcipher (& virtio_crypto_akcipher_algs [i ].algo );
558563 if (ret )
559564 goto unlock ;
560565 }
561566
562567 virtio_crypto_akcipher_algs [i ].active_devs ++ ;
563568 dev_info (& vcrypto -> vdev -> dev , "Registered akcipher algo %s\n" ,
564- virtio_crypto_akcipher_algs [i ].algo .base .cra_name );
569+ virtio_crypto_akcipher_algs [i ].algo .base .base . cra_name );
565570 }
566571
567572unlock :
@@ -584,7 +589,7 @@ void virtio_crypto_akcipher_algs_unregister(struct virtio_crypto *vcrypto)
584589 continue ;
585590
586591 if (virtio_crypto_akcipher_algs [i ].active_devs == 1 )
587- crypto_unregister_akcipher (& virtio_crypto_akcipher_algs [i ].algo );
592+ crypto_engine_unregister_akcipher (& virtio_crypto_akcipher_algs [i ].algo );
588593
589594 virtio_crypto_akcipher_algs [i ].active_devs -- ;
590595 }
0 commit comments