Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2577881pxb; Thu, 10 Feb 2022 00:18:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6xzFFuPNlZ09uAfe+4fx5H/bSNQ7oXhOD6CrVaWWGP22yUyr6vWXvpmn44ry+KTkGFkDQ X-Received: by 2002:aa7:cdc5:: with SMTP id h5mr7247992edw.398.1644481090861; Thu, 10 Feb 2022 00:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644481090; cv=none; d=google.com; s=arc-20160816; b=iIrJrpaGVe/S4jpY0nMyeruPqTBvwxW3q6jB+LV0F2Q8Io+/6NT59zy9Np3p4wlzhn u5OBjvJa62OvQ5mYJ+Sw31tQLto2lks8boQkhi7s71I5RP5Fh8G5aGEa+CiPD+FTD0ed 8ratkmmEoVOeAKntyVy25p4mFo7E5dyfJD9FGYiIgXUyPjaRvSPoRp+2XKNxPtwgICqn ugdxH1UTUwiA56NWpXckWAoDdZlAWZdTmBOSLnjcj5MyeJukaaZmf+DETiKOhSXDuN1g 23Yyxo5q5sUHrJsqj+NxrsfuJlJiB0RxQEyqUxKe1kCngt82XwpzCtQIMTn3YLc3uT5s 1ZNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=ZZnOB+kqeZZuoGForbrWeRASqHL3+yAojT2jGeYeGfw=; b=O2DA++FG/gjQv1HJIgHWgENqH1Xz0Rw74EwSbOjAreOtqI9MZPIO45gjtbf3uLd7O/ RBPCPR48hzgWJgzc7E41MbnHUDkX9QLyDD4mFVZqQiW251gqhT+KUWK/dojl+NNC6J0e x/+XSGTtGijI+bXV2B9aA9olvKC63ONettDJ21agkvuyom8G37Z/5Y/OEragmPActfz5 gl2U1DPtH9dWIE7GdC2eg7OqtsSbKZHrg3iR0rYjesSbVto2KrhoBeIxCEeTwbRsz9/H y1Wasf/DqKyAhe+MemBDfCbzkNpdBc18G65IBJKavps9gbXHKTPoS/p90x8BxBngEYP7 lROg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf18si4646364ejc.77.2022.02.10.00.17.45; Thu, 10 Feb 2022 00:18:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236706AbiBJHwE convert rfc822-to-8bit (ORCPT + 99 others); Thu, 10 Feb 2022 02:52:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236684AbiBJHwB (ORCPT ); Thu, 10 Feb 2022 02:52:01 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8843C1083; Wed, 9 Feb 2022 23:52:00 -0800 (PST) Received: from dggeme761-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JvTPD3SvgzZfNX; Thu, 10 Feb 2022 15:47:44 +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, 10 Feb 2022 15:51:58 +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, 10 Feb 2022 15:51:58 +0800 From: "Gonglei (Arei)" To: zhenwei pi , "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" Subject: RE: [PATCH 2/3] virtio-crypto: introduce akcipher service Thread-Topic: [PATCH 2/3] virtio-crypto: introduce akcipher service Thread-Index: AQHYDm47poB50P1RmUal7n5E+2vGlKyMgQ2Q Date: Thu, 10 Feb 2022 07:51:57 +0000 Message-ID: <15e960491a684b649e5d0179a32848a2@huawei.com> References: <20220121022438.1042547-1-pizhenwei@bytedance.com> <20220121022438.1042547-3-pizhenwei@bytedance.com> In-Reply-To: <20220121022438.1042547-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] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: zhenwei pi [mailto:pizhenwei@bytedance.com] > Sent: Friday, January 21, 2022 10:25 AM > To: mst@redhat.com; Gonglei (Arei) > Cc: jasowang@redhat.com; virtualization@lists.linux-foundation.org; > linux-crypto@vger.kernel.org; linux-kernel@vger.kernel.org; > helei.sig11@bytedance.com; zhenwei pi > Subject: [PATCH 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 | 99 +++++++++++++++++++++++++++--- > 1 file changed, 89 insertions(+), 10 deletions(-) > > diff --git a/include/uapi/linux/virtio_crypto.h > b/include/uapi/linux/virtio_crypto.h > index 1166a49084b0..050578d61d85 100644 > --- a/include/uapi/linux/virtio_crypto.h > +++ b/include/uapi/linux/virtio_crypto.h > @@ -33,10 +33,11 @@ > #include > > > -#define VIRTIO_CRYPTO_SERVICE_CIPHER 0 > -#define VIRTIO_CRYPTO_SERVICE_HASH 1 > -#define VIRTIO_CRYPTO_SERVICE_MAC 2 > -#define VIRTIO_CRYPTO_SERVICE_AEAD 3 > +#define VIRTIO_CRYPTO_SERVICE_CIPHER 0 > +#define VIRTIO_CRYPTO_SERVICE_HASH 1 > +#define VIRTIO_CRYPTO_SERVICE_MAC 2 > +#define VIRTIO_CRYPTO_SERVICE_AEAD 3 > +#define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4 > Only need to add the last line Pls. > #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,57 @@ 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; > +}; > + 64-bit alignment is required. > +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 > +303,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 +324,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 +456,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,16 +475,18 @@ 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; > }; > > -#define VIRTIO_CRYPTO_OK 0 > -#define VIRTIO_CRYPTO_ERR 1 > -#define VIRTIO_CRYPTO_BADMSG 2 > -#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_OK 0 > +#define VIRTIO_CRYPTO_ERR 1 > +#define VIRTIO_CRYPTO_BADMSG 2 > +#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 > +*/ > Same above. Do not modify irrelevant information. > /* The accelerator hardware is ready */ #define > VIRTIO_CRYPTO_S_HW_READY (1 << 0) @@ -442,6 +520,7 @@ struct > virtio_crypto_config { > __le32 reserve; > /* Maximum size of each crypto request's content */ > __le64 max_size; > + __le32 akcipher_algo; > }; > You can use the reserve attribute. Keeping 64-bit aligned. > struct virtio_crypto_inhdr { > -- > 2.25.1