7
7
* Copyright 2022 Bytedance CO., LTD.
8
8
*/
9
9
10
- #include <linux/mpi.h>
11
- #include <linux/scatterlist.h>
12
- #include <crypto/algapi.h>
10
+ #include <crypto/engine.h>
13
11
#include <crypto/internal/akcipher.h>
14
12
#include <crypto/internal/rsa.h>
15
- #include <linux/err.h>
16
13
#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>
19
20
#include <uapi/linux/virtio_crypto.h>
20
21
#include "virtio_crypto_common.h"
21
22
@@ -24,7 +25,6 @@ struct virtio_crypto_rsa_ctx {
24
25
};
25
26
26
27
struct virtio_crypto_akcipher_ctx {
27
- struct crypto_engine_ctx enginectx ;
28
28
struct virtio_crypto * vcrypto ;
29
29
struct crypto_akcipher * tfm ;
30
30
bool session_valid ;
@@ -47,7 +47,7 @@ struct virtio_crypto_akcipher_algo {
47
47
uint32_t algonum ;
48
48
uint32_t service ;
49
49
unsigned int active_devs ;
50
- struct akcipher_alg algo ;
50
+ struct akcipher_engine_alg algo ;
51
51
};
52
52
53
53
static DEFINE_MUTEX (algs_lock );
@@ -475,7 +475,6 @@ static int virtio_crypto_rsa_init_tfm(struct crypto_akcipher *tfm)
475
475
struct virtio_crypto_akcipher_ctx * ctx = akcipher_tfm_ctx (tfm );
476
476
477
477
ctx -> tfm = tfm ;
478
- ctx -> enginectx .op .do_one_request = virtio_crypto_rsa_do_req ;
479
478
480
479
akcipher_set_reqsize (tfm ,
481
480
sizeof (struct virtio_crypto_akcipher_request ));
@@ -498,7 +497,7 @@ static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
498
497
{
499
498
.algonum = VIRTIO_CRYPTO_AKCIPHER_RSA ,
500
499
.service = VIRTIO_CRYPTO_SERVICE_AKCIPHER ,
501
- .algo = {
500
+ .algo . base = {
502
501
.encrypt = virtio_crypto_rsa_encrypt ,
503
502
.decrypt = virtio_crypto_rsa_decrypt ,
504
503
.set_pub_key = virtio_crypto_rsa_raw_set_pub_key ,
@@ -514,11 +513,14 @@ static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
514
513
.cra_ctxsize = sizeof (struct virtio_crypto_akcipher_ctx ),
515
514
},
516
515
},
516
+ .algo .op = {
517
+ .do_one_request = virtio_crypto_rsa_do_req ,
518
+ },
517
519
},
518
520
{
519
521
.algonum = VIRTIO_CRYPTO_AKCIPHER_RSA ,
520
522
.service = VIRTIO_CRYPTO_SERVICE_AKCIPHER ,
521
- .algo = {
523
+ .algo . base = {
522
524
.encrypt = virtio_crypto_rsa_encrypt ,
523
525
.decrypt = virtio_crypto_rsa_decrypt ,
524
526
.sign = virtio_crypto_rsa_sign ,
@@ -536,6 +538,9 @@ static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
536
538
.cra_ctxsize = sizeof (struct virtio_crypto_akcipher_ctx ),
537
539
},
538
540
},
541
+ .algo .op = {
542
+ .do_one_request = virtio_crypto_rsa_do_req ,
543
+ },
539
544
},
540
545
};
541
546
@@ -554,14 +559,14 @@ int virtio_crypto_akcipher_algs_register(struct virtio_crypto *vcrypto)
554
559
continue ;
555
560
556
561
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 );
558
563
if (ret )
559
564
goto unlock ;
560
565
}
561
566
562
567
virtio_crypto_akcipher_algs [i ].active_devs ++ ;
563
568
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 );
565
570
}
566
571
567
572
unlock :
@@ -584,7 +589,7 @@ void virtio_crypto_akcipher_algs_unregister(struct virtio_crypto *vcrypto)
584
589
continue ;
585
590
586
591
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 );
588
593
589
594
virtio_crypto_akcipher_algs [i ].active_devs -- ;
590
595
}
0 commit comments