Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3976346pxb; Fri, 11 Feb 2022 12:02:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOCPY3UXb1IMUscTREauMA07A+1j2SGNQbVjGT2MwpBjQzK322a1Ar/Nzq0p2/XWNmgHhM X-Received: by 2002:a17:906:b848:: with SMTP id ga8mr2750982ejb.268.1644609729673; Fri, 11 Feb 2022 12:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644609729; cv=none; d=google.com; s=arc-20160816; b=U/AYwowsd/O/gabV7M5FDhiTn7yjRcIHuVjZUUr2DiLGeD+8sSlWzTHGgAUY6QCUQB z+2MBXA7PPsvEMyYWg5WPbEXqmFXA/3a2eNI9VLmfVhVL+mahDIkBml2FCKGmwShkV3O FgC9mgOYogrkNV6cLtvqwrfXCTUViphKRpSx+wHCOE8q91H/GFVaFsVSKqNatxmxx0L5 xfabyFK56tUO5unCc2Az5DNDHgq0IJa65h6+pq+POBAEYA27otA/FRIAMqjH7PpbCHWP PCQaQmNLrePqTyptXXjVnl13tlb2ne+LLMZjVvFu3+ruNHKF+4zjZSoMSP2It72J42uU 3LNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1YUUEgbKT5E8ArafBlTdhEpSwGDviZA6oIz5a+XwpPM=; b=Gua1L3J1okpug9IB8ZnRdXmYUH9+AVB6Pd8IMn6/91p31BBIFY4QiZW9qFnCDe8V+a Dxw30yNk7/rjFcZqRPzqWRL5n5VLKoF0F7kMi/E8vAc0zelec54+P5adHHAQlof0wENI ryJONNHLzYZslhdTrm2MImar7dR3JjfTWdnptYv0qdsQD3Lv7y725l5DFv4liSbI+rAP 9RB3JjSCBA95Zze2nl6y3bWPupprlSR7aDFvuhASFhiSQwnHJpY+wMM9Qf+9AdXBDP1T +3QoAggfAK3r4S57nUacOukq/2VrlzxcgHK8awWoxTNq51wwa+igmcMrqcakW28WRBJl lzIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=0oAjqplY; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn11si16905786ejc.626.2022.02.11.12.01.38; Fri, 11 Feb 2022 12:02:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=0oAjqplY; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237541AbiBKIpL (ORCPT + 99 others); Fri, 11 Feb 2022 03:45:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244156AbiBKIpL (ORCPT ); Fri, 11 Feb 2022 03:45:11 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA604E67 for ; Fri, 11 Feb 2022 00:45:10 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id m7so7537099pjk.0 for ; Fri, 11 Feb 2022 00:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1YUUEgbKT5E8ArafBlTdhEpSwGDviZA6oIz5a+XwpPM=; b=0oAjqplYNLMWICcrHeQjBdyutmnnlHMmThim5ZJF8kipGWzVHnNCy5Prycxm4OuZvp JcNXCx6po3z1kHXAVdEEWRbGBksAMyNwzJoRs04r8PY8NiT+23idoQsS4eEn/z2ORiKv 6ftzQN5tVH72P81P7NQ3cKgY0tT4SvOguNm9Matwnd5L83k7HsDoyjii35eIwFogbato Tc7ZWif6dnotY903l4eu1E0AQqe1T2LNVO4zC7qqT1oNQbDw3I3fvWc+yb/yAU8rmqk4 13x0u2/ubiVg/GVgontGpRVNdIZ0voPzXb3cJtu2IsqWCxGLDAZW8gs/6J5KEFqUk5Tu Vs8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1YUUEgbKT5E8ArafBlTdhEpSwGDviZA6oIz5a+XwpPM=; b=GTZnb8z2GEhETXbPc7mx+mjdnhakCKdlvrhNSZtwcd9Re3lVt2EJriaAb1ZwDGqOZP TbKSFSF/sH+U95d0wmsanqIXH5bsPB/Nq3vIq8K9dCFj31Ch96WqeY8qtZoxjI1YulWB 41K0g2BiJ8v6xx2FYjjLU33dffDV9VtmA/CYd3Eud5YtRWWUFGI85pFEFILYgp+HXAl8 8kH1co2z9TIjuFCYh17IsLZUuzW49ZE/5gqYKvlrjGoSLorjMB2nnuZBCPqzMPuk4iiT 0ZPtL4JOuk1TkswtSpnyFa/1CQC53gTkfIFjSHJkdGjFWhbFlco5UssITH0oZ7TGAVLX pIVA== X-Gm-Message-State: AOAM533TqEjaktnHoLRNPQsf8oUFKY22WpB3X560L4QqsCtHV1/8V0MD +1vsbwtgzo8QTLaOiC19RZ7eqg== X-Received: by 2002:a17:902:d707:: with SMTP id w7mr450632ply.159.1644569110334; Fri, 11 Feb 2022 00:45:10 -0800 (PST) Received: from libai.bytedance.net ([61.120.150.72]) by smtp.gmail.com with ESMTPSA id u7sm3832686pgc.93.2022.02.11.00.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 00:45:09 -0800 (PST) From: zhenwei pi To: arei.gonglei@huawei.com, mst@redhat.com Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-crypto@vger.kernel.org, qemu-devel@nongnu.org, helei.sig11@bytedance.com, herbert@gondor.apana.org.au, zhenwei pi Subject: [PATCH v2 1/3] virtio-crypto: header update Date: Fri, 11 Feb 2022 16:43:33 +0800 Message-Id: <20220211084335.1254281-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211084335.1254281-1-pizhenwei@bytedance.com> References: <20220211084335.1254281-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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-crypto@vger.kernel.org Update header from linux, support akcipher service. Signed-off-by: lei he Signed-off-by: zhenwei pi --- .../standard-headers/linux/virtio_crypto.h | 82 ++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/include/standard-headers/linux/virtio_crypto.h b/include/standard-headers/linux/virtio_crypto.h index 5ff0b4ee59..68066dafb6 100644 --- a/include/standard-headers/linux/virtio_crypto.h +++ b/include/standard-headers/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) uint32_t opcode; uint32_t algo; uint32_t flag; @@ -180,6 +185,58 @@ struct virtio_crypto_aead_create_session_req { uint8_t padding[32]; }; +struct virtio_crypto_rsa_session_para { +#define VIRTIO_CRYPTO_RSA_RAW_PADDING 0 +#define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1 + uint32_t 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 + uint32_t 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 + uint32_t curve_id; + uint32_t 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 + uint32_t algo; + +#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC 1 +#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2 + uint32_t keytype; + uint32_t 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; + uint8_t 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; uint8_t 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) uint32_t opcode; /* algo should be service-specific algorithms */ uint32_t algo; @@ -390,6 +457,16 @@ struct virtio_crypto_aead_data_req { uint8_t padding[32]; }; +struct virtio_crypto_akcipher_para { + uint32_t src_data_len; + uint32_t dst_data_len; +}; + +struct virtio_crypto_akcipher_data_req { + struct virtio_crypto_akcipher_para para; + uint8_t 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; uint8_t padding[48]; } u; }; @@ -408,6 +486,8 @@ struct virtio_crypto_op_data_req { #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 */ /* The accelerator hardware is ready */ #define VIRTIO_CRYPTO_S_HW_READY (1 << 0) @@ -438,7 +518,7 @@ struct virtio_crypto_config { uint32_t max_cipher_key_len; /* Maximum length of authenticated key */ uint32_t max_auth_key_len; - uint32_t reserve; + uint32_t akcipher_algo; /* Maximum size of each crypto request's content */ uint64_t max_size; }; -- 2.20.1