]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: virtio - Drop superfluous [as]kcipher_ctx pointer
authorLukas Wunner <lukas@wunner.de>
Mon, 3 Feb 2025 13:37:04 +0000 (14:37 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 22 Feb 2025 07:56:02 +0000 (15:56 +0800)
The request context virtio_crypto_{akcipher,sym}_request contains a
pointer to the transform context virtio_crypto_[as]kcipher_ctx.

The pointer is superfluous as it can be calculated with the cheap
crypto_akcipher_reqtfm() + akcipher_tfm_ctx() and
crypto_skcipher_reqtfm() + crypto_skcipher_ctx() combos.

Drop the superfluous pointer.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
drivers/crypto/virtio/virtio_crypto_skcipher_algs.c

index aa8255786d6cadfaed4fec9b8c514c54a69f1899..ac8eb3d07c93908fec9dbc85796154f036e8cfe4 100644 (file)
@@ -35,7 +35,6 @@ struct virtio_crypto_akcipher_ctx {
 
 struct virtio_crypto_akcipher_request {
        struct virtio_crypto_request base;
-       struct virtio_crypto_akcipher_ctx *akcipher_ctx;
        struct akcipher_request *akcipher_req;
        void *src_buf;
        void *dst_buf;
@@ -212,7 +211,8 @@ out:
 static int __virtio_crypto_akcipher_do_req(struct virtio_crypto_akcipher_request *vc_akcipher_req,
                struct akcipher_request *req, struct data_queue *data_vq)
 {
-       struct virtio_crypto_akcipher_ctx *ctx = vc_akcipher_req->akcipher_ctx;
+       struct crypto_akcipher *atfm = crypto_akcipher_reqtfm(req);
+       struct virtio_crypto_akcipher_ctx *ctx = akcipher_tfm_ctx(atfm);
        struct virtio_crypto_request *vc_req = &vc_akcipher_req->base;
        struct virtio_crypto *vcrypto = ctx->vcrypto;
        struct virtio_crypto_op_data_req *req_data = vc_req->req_data;
@@ -272,7 +272,8 @@ static int virtio_crypto_rsa_do_req(struct crypto_engine *engine, void *vreq)
        struct akcipher_request *req = container_of(vreq, struct akcipher_request, base);
        struct virtio_crypto_akcipher_request *vc_akcipher_req = akcipher_request_ctx(req);
        struct virtio_crypto_request *vc_req = &vc_akcipher_req->base;
-       struct virtio_crypto_akcipher_ctx *ctx = vc_akcipher_req->akcipher_ctx;
+       struct crypto_akcipher *atfm = crypto_akcipher_reqtfm(req);
+       struct virtio_crypto_akcipher_ctx *ctx = akcipher_tfm_ctx(atfm);
        struct virtio_crypto *vcrypto = ctx->vcrypto;
        struct data_queue *data_vq = vc_req->dataq;
        struct virtio_crypto_op_header *header;
@@ -318,7 +319,6 @@ static int virtio_crypto_rsa_req(struct akcipher_request *req, uint32_t opcode)
 
        vc_req->dataq = data_vq;
        vc_req->alg_cb = virtio_crypto_dataq_akcipher_callback;
-       vc_akcipher_req->akcipher_ctx = ctx;
        vc_akcipher_req->akcipher_req = req;
        vc_akcipher_req->opcode = opcode;
 
index 495fc655a51cdf79b10dbf97677e4522a3b24949..e2a481a29b7774721b66517c9c827b0e2217996e 100644 (file)
@@ -27,7 +27,6 @@ struct virtio_crypto_sym_request {
 
        /* Cipher or aead */
        uint32_t type;
-       struct virtio_crypto_skcipher_ctx *skcipher_ctx;
        struct skcipher_request *skcipher_req;
        uint8_t *iv;
        /* Encryption? */
@@ -324,7 +323,7 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
                struct data_queue *data_vq)
 {
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
-       struct virtio_crypto_skcipher_ctx *ctx = vc_sym_req->skcipher_ctx;
+       struct virtio_crypto_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
        struct virtio_crypto_request *vc_req = &vc_sym_req->base;
        unsigned int ivsize = crypto_skcipher_ivsize(tfm);
        struct virtio_crypto *vcrypto = ctx->vcrypto;
@@ -480,7 +479,6 @@ static int virtio_crypto_skcipher_encrypt(struct skcipher_request *req)
 
        vc_req->dataq = data_vq;
        vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
-       vc_sym_req->skcipher_ctx = ctx;
        vc_sym_req->skcipher_req = req;
        vc_sym_req->encrypt = true;
 
@@ -505,7 +503,6 @@ static int virtio_crypto_skcipher_decrypt(struct skcipher_request *req)
 
        vc_req->dataq = data_vq;
        vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
-       vc_sym_req->skcipher_ctx = ctx;
        vc_sym_req->skcipher_req = req;
        vc_sym_req->encrypt = false;