From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E5D0C433EF for ; Thu, 17 Feb 2022 12:08:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D38F0813F6; Thu, 17 Feb 2022 12:08:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r06TOLUVrY1m; Thu, 17 Feb 2022 12:08:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 45046813E8; Thu, 17 Feb 2022 12:08:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 28E03C0021; Thu, 17 Feb 2022 12:08:55 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8916CC000B for ; Thu, 17 Feb 2022 12:08:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 85EAD60B00 for ; Thu, 17 Feb 2022 12:08:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wO-2cEcIJqg0 for ; Thu, 17 Feb 2022 12:08:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by smtp3.osuosl.org (Postfix) with ESMTPS id 43D7260A6A for ; Thu, 17 Feb 2022 12:08:52 +0000 (UTC) Received: from dggeme761-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Jztm75Jx0zZfh1; Thu, 17 Feb 2022 20:04:23 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggeme761-chm.china.huawei.com (10.3.19.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Thu, 17 Feb 2022 20:08:46 +0800 Received: from dggpemm500006.china.huawei.com ([7.185.36.236]) by dggpemm500006.china.huawei.com ([7.185.36.236]) with mapi id 15.01.2308.021; Thu, 17 Feb 2022 20:08:46 +0800 To: zhenwei pi , "mst@redhat.com" Subject: RE: [PATCH v2 2/3] virtio-crypto: introduce akcipher service Thread-Topic: [PATCH v2 2/3] virtio-crypto: introduce akcipher service Thread-Index: AQHYHyNalD1cHiTHcEC6jHoAY2t9YayXr91g Date: Thu, 17 Feb 2022 12:08:46 +0000 Message-ID: <66bcc483973d4af49da0624607d63cf4@huawei.com> References: <20220211084108.1254218-1-pizhenwei@bytedance.com> <20220211084108.1254218-3-pizhenwei@bytedance.com> In-Reply-To: <20220211084108.1254218-3-pizhenwei@bytedance.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.149.11] MIME-Version: 1.0 X-CFilter-Loop: Reflected Cc: "helei.sig11@bytedance.com" , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "linux-crypto@vger.kernel.org" , "herbert@gondor.apana.org.au" X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "Gonglei \(Arei\) via Virtualization" Reply-To: "Gonglei \(Arei\)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" > -----Original Message----- > From: zhenwei pi [mailto:pizhenwei@bytedance.com] > Sent: Friday, February 11, 2022 4:41 PM > To: Gonglei (Arei) ; mst@redhat.com > Cc: jasowang@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; zhenwei pi > > Subject: [PATCH v2 2/3] virtio-crypto: introduce akcipher service > > Introduce asymmetric service definition, asymmetric operations and several > well known algorithms. > > Co-developed-by: lei he > Signed-off-by: lei he > Signed-off-by: zhenwei pi > --- > include/uapi/linux/virtio_crypto.h | 81 +++++++++++++++++++++++++++++- > 1 file changed, 80 insertions(+), 1 deletion(-) > Reviewed-by: Gonglei > diff --git a/include/uapi/linux/virtio_crypto.h > b/include/uapi/linux/virtio_crypto.h > index 1166a49084b0..71a54a6849ca 100644 > --- a/include/uapi/linux/virtio_crypto.h > +++ b/include/uapi/linux/virtio_crypto.h > @@ -37,6 +37,7 @@ > #define VIRTIO_CRYPTO_SERVICE_HASH 1 > #define VIRTIO_CRYPTO_SERVICE_MAC 2 > #define VIRTIO_CRYPTO_SERVICE_AEAD 3 > +#define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4 > > #define VIRTIO_CRYPTO_OPCODE(service, op) (((service) << 8) | (op)) > > @@ -57,6 +58,10 @@ struct virtio_crypto_ctrl_header { > VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02) > #define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION \ > VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03) > +#define VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION \ > + VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x04) > #define > +VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION \ > + VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, > 0x05) > __le32 opcode; > __le32 algo; > __le32 flag; > @@ -180,6 +185,58 @@ struct virtio_crypto_aead_create_session_req { > __u8 padding[32]; > }; > > +struct virtio_crypto_rsa_session_para { > +#define VIRTIO_CRYPTO_RSA_RAW_PADDING 0 > +#define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1 > + __le32 padding_algo; > + > +#define VIRTIO_CRYPTO_RSA_NO_HASH 0 > +#define VIRTIO_CRYPTO_RSA_MD2 1 > +#define VIRTIO_CRYPTO_RSA_MD3 2 > +#define VIRTIO_CRYPTO_RSA_MD4 3 > +#define VIRTIO_CRYPTO_RSA_MD5 4 > +#define VIRTIO_CRYPTO_RSA_SHA1 5 > +#define VIRTIO_CRYPTO_RSA_SHA256 6 > +#define VIRTIO_CRYPTO_RSA_SHA384 7 > +#define VIRTIO_CRYPTO_RSA_SHA512 8 > +#define VIRTIO_CRYPTO_RSA_SHA224 9 > + __le32 hash_algo; > +}; > + > +struct virtio_crypto_ecdsa_session_para { > +#define VIRTIO_CRYPTO_CURVE_UNKNOWN 0 > +#define VIRTIO_CRYPTO_CURVE_NIST_P192 1 #define > +VIRTIO_CRYPTO_CURVE_NIST_P224 2 #define > VIRTIO_CRYPTO_CURVE_NIST_P256 3 > +#define VIRTIO_CRYPTO_CURVE_NIST_P384 4 #define > +VIRTIO_CRYPTO_CURVE_NIST_P521 5 > + __le32 curve_id; > + __le32 padding; > +}; > + > +struct virtio_crypto_akcipher_session_para { > +#define VIRTIO_CRYPTO_NO_AKCIPHER 0 > +#define VIRTIO_CRYPTO_AKCIPHER_RSA 1 > +#define VIRTIO_CRYPTO_AKCIPHER_DSA 2 > +#define VIRTIO_CRYPTO_AKCIPHER_ECDSA 3 > + __le32 algo; > + > +#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC 1 #define > +VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2 > + __le32 keytype; > + __le32 keylen; > + > + union { > + struct virtio_crypto_rsa_session_para rsa; > + struct virtio_crypto_ecdsa_session_para ecdsa; > + } u; > +}; > + > +struct virtio_crypto_akcipher_create_session_req { > + struct virtio_crypto_akcipher_session_para para; > + __u8 padding[36]; > +}; > + > struct virtio_crypto_alg_chain_session_para { #define > VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER 1 > #define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH 2 > @@ -247,6 +304,8 @@ struct virtio_crypto_op_ctrl_req { > mac_create_session; > struct virtio_crypto_aead_create_session_req > aead_create_session; > + struct virtio_crypto_akcipher_create_session_req > + akcipher_create_session; > struct virtio_crypto_destroy_session_req > destroy_session; > __u8 padding[56]; > @@ -266,6 +325,14 @@ struct virtio_crypto_op_header { > VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00) > #define VIRTIO_CRYPTO_AEAD_DECRYPT \ > VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01) > +#define VIRTIO_CRYPTO_AKCIPHER_ENCRYPT \ > + VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x00) > #define > +VIRTIO_CRYPTO_AKCIPHER_DECRYPT \ > + VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x01) > #define > +VIRTIO_CRYPTO_AKCIPHER_SIGN \ > + VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02) > #define > +VIRTIO_CRYPTO_AKCIPHER_VERIFY \ > + VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03) > __le32 opcode; > /* algo should be service-specific algorithms */ > __le32 algo; > @@ -390,6 +457,16 @@ struct virtio_crypto_aead_data_req { > __u8 padding[32]; > }; > > +struct virtio_crypto_akcipher_para { > + __le32 src_data_len; > + __le32 dst_data_len; > +}; > + > +struct virtio_crypto_akcipher_data_req { > + struct virtio_crypto_akcipher_para para; > + __u8 padding[40]; > +}; > + > /* The request of the data virtqueue's packet */ struct > virtio_crypto_op_data_req { > struct virtio_crypto_op_header header; @@ -399,6 +476,7 @@ struct > virtio_crypto_op_data_req { > struct virtio_crypto_hash_data_req hash_req; > struct virtio_crypto_mac_data_req mac_req; > struct virtio_crypto_aead_data_req aead_req; > + struct virtio_crypto_akcipher_data_req akcipher_req; > __u8 padding[48]; > } u; > }; > @@ -409,6 +487,7 @@ struct virtio_crypto_op_data_req { > #define VIRTIO_CRYPTO_NOTSUPP 3 > #define VIRTIO_CRYPTO_INVSESS 4 /* Invalid session id */ > #define VIRTIO_CRYPTO_NOSPC 5 /* no free session ID */ > +#define VIRTIO_CRYPTO_KEY_REJECTED 6 /* Signature verification failed > +*/ > > /* The accelerator hardware is ready */ #define > VIRTIO_CRYPTO_S_HW_READY (1 << 0) @@ -439,7 +518,7 @@ struct > virtio_crypto_config { > __le32 max_cipher_key_len; > /* Maximum length of authenticated key */ > __le32 max_auth_key_len; > - __le32 reserve; > + __le32 akcipher_algo; > /* Maximum size of each crypto request's content */ > __le64 max_size; > }; > -- > 2.20.1 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization