From: "Gonglei \(Arei\) via Virtualization" <virtualization@lists.linux-foundation.org>
To: zhenwei pi <pizhenwei@bytedance.com>
Cc: "helei.sig11@bytedance.com" <helei.sig11@bytedance.com>,
"mst@redhat.com" <mst@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
kernel test robot <lkp@intel.com>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>
Subject: RE: PING: [PATCH v2 3/3] virtio-crypto: implement RSA algorithm
Date: Tue, 1 Mar 2022 11:13:02 +0000 [thread overview]
Message-ID: <786ae1572eb643a5b7eeaf6f47bfc698@huawei.com> (raw)
In-Reply-To: <0c148ada-9f32-3272-8a89-591299ab098d@bytedance.com>
> -----Original Message-----
> From: zhenwei pi [mailto:pizhenwei@bytedance.com]
> Sent: Tuesday, March 1, 2022 6:26 PM
> To: Gonglei (Arei) <arei.gonglei@huawei.com>
> Cc: jasowang@redhat.com; mst@redhat.com;
> virtualization@lists.linux-foundation.org; linux-crypto@vger.kernel.org;
> linux-kernel@vger.kernel.org; helei.sig11@bytedance.com;
> herbert@gondor.apana.org.au; kernel test robot <lkp@intel.com>
> Subject: PING: [PATCH v2 3/3] virtio-crypto: implement RSA algorithm
>
> PING!
>
> Hi, Lei
> I also take a look at other crypto drivers qat/ccp/hisilicon, they separate
> akcipher/skcipher algo. If you consider that reusing
> virtio_crypto_algs_register/unregister seems better, I will try to merge them
> into a single function.
>
I'm fine with separating them in different c files. Then should we rename virtio_crypto_algs.c
to virtio_crypto_skcipher_algo.c?
Regards,
-Gonglei
> On 2/23/22 6:17 PM, zhenwei pi wrote:
> >
> > On 2/18/22 11:12 AM, zhenwei pi wrote:
> >>>> +void virtio_crypto_akcipher_algs_unregister(struct virtio_crypto
> >>>> +*vcrypto) {
> >>>> + int i = 0;
> >>>> +
> >>>> + mutex_lock(&algs_lock);
> >>>> +
> >>>> + for (i = 0; i < ARRAY_SIZE(virtio_crypto_akcipher_algs); i++)
> >>>> +{
> >>>> + uint32_t service = virtio_crypto_akcipher_algs[i].service;
> >>>> + uint32_t algonum = virtio_crypto_akcipher_algs[i].algonum;
> >>>> +
> >>>> + if (virtio_crypto_akcipher_algs[i].active_devs == 0 ||
> >>>> + !virtcrypto_algo_is_supported(vcrypto, service,
> >>>> +algonum))
> >>>> + continue;
> >>>> +
> >>>> + if (virtio_crypto_akcipher_algs[i].active_devs == 1)
> >>>> +
> >>>>
> >>>> crypto_unregister_akcipher(&virtio_crypto_akcipher_algs[i].algo);
> >>>> +
> >>>> + virtio_crypto_akcipher_algs[i].active_devs--;
> >>>> + }
> >>>> +
> >>>> + mutex_unlock(&algs_lock);
> >>>> +}
> >>>
> >>> Why don't you reuse the virtio_crypto_algs_register/unregister
> >>> functions?
> >>> The current code is too repetitive. Maybe we don't need create the
> >>> new file virtio_crypto_akcipher_algo.c because we had
> >>> virtio_crypto_algs.c which includes all algorithms.
> >>>
> >>
> >> Yes, this looks similar to virtio_crypto_algs_register/unregister.
> >>
> >> Let's look at the difference:
> >> struct virtio_crypto_akcipher_algo {
> >> uint32_t algonum;
> >> uint32_t service;
> >> unsigned int active_devs;
> >> struct akcipher_alg algo;
> >> };
> >>
> >> struct virtio_crypto_algo {
> >> uint32_t algonum;
> >> uint32_t service;
> >> unsigned int active_devs;
> >> struct skcipher_alg algo; /* akcipher_alg VS skcipher_alg */
> >> };
> >>
> >> If reusing virtio_crypto_algs_register/unregister, we need to modify
> >> the data structure like this:
> >> struct virtio_crypto_akcipher_algo {
> >> uint32_t algonum;
> >> uint32_t service; /* use service to distinguish
> >> akcipher/skcipher */
> >> unsigned int active_devs;
> >> union {
> >> struct skcipher_alg skcipher;
> >> struct akcipher_alg akcipher;
> >> } alg;
> >> };
> >>
> >> int virtio_crypto_akcipher_algs_register(struct virtio_crypto
> >> *vcrypto) {
> >> ...
> >> for (i = 0; i < ARRAY_SIZE(virtio_crypto_akcipher_algs);
> >> i++) {
> >> uint32_t service =
> >> virtio_crypto_akcipher_algs[i].service;
> >> ...
> >> /* test service type then call
> >> crypto_register_akcipher/crypto_register_skcipher */
> >> if (service == VIRTIO_CRYPTO_SERVICE_AKCIPHER)
> >> crypto_register_akcipher(&virtio_crypto_akcipher_algs[i].algo.akciphe
> >> r);
> >> else
> >> crypto_register_skcipher(&virtio_crypto_skcipher_algs[i].algo.skciphe
> >> r);
> >> ...
> >> }
> >> ...
> >> }
> >>
> >> Also test service type and call
> >> crypto_unregister_skcipher/crypto_unregister_akcipher.
> >>
> >> This gets unclear from current v2 version.
> >>
> >> On the other hand, the kernel side prefers to separate skcipher and
> >> akcipher(separated header files and implementations).
> >>
> >
>
> --
> zhenwei pi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2022-03-01 11:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 8:41 [PATCH v2 0/3] Introduce akcipher service for virtio-crypto zhenwei pi
2022-02-11 8:41 ` [PATCH v2 1/3] virtio_crypto: Introduce VIRTIO_CRYPTO_NOSPC zhenwei pi
2022-02-11 8:41 ` [PATCH v2 2/3] virtio-crypto: introduce akcipher service zhenwei pi
2022-02-17 12:08 ` Gonglei (Arei) via Virtualization
2022-02-11 8:41 ` [PATCH v2 3/3] virtio-crypto: implement RSA algorithm zhenwei pi
2022-02-17 12:07 ` Gonglei (Arei) via Virtualization
2022-02-18 3:12 ` zhenwei pi
2022-02-23 10:17 ` zhenwei pi
2022-03-01 10:25 ` PING: " zhenwei pi
2022-03-01 11:13 ` Gonglei (Arei) via Virtualization [this message]
2022-02-16 1:36 ` PING: [PATCH v2 0/3] Introduce akcipher service for virtio-crypto zhenwei pi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=786ae1572eb643a5b7eeaf6f47bfc698@huawei.com \
--to=virtualization@lists.linux-foundation.org \
--cc=arei.gonglei@huawei.com \
--cc=helei.sig11@bytedance.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mst@redhat.com \
--cc=pizhenwei@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).