Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1031156pxb; Wed, 15 Sep 2021 20:27:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZNHieUABPJHhL/HzwIm8zJZkvN/kgQGvanC+mE6bE8iGZultOOxoiJKrlaLEVOCtnOcl5 X-Received: by 2002:a6b:3b8c:: with SMTP id i134mr2568073ioa.29.1631762846527; Wed, 15 Sep 2021 20:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631762846; cv=none; d=google.com; s=arc-20160816; b=zgtPlUnpCEgIiEIlDBWTgrRI2NEUKmLDY2U5FhqWszmKtypT99h1SQj2aSfPSOo/mZ G+7mB01cORg0ozxinVv8ZMkWwf/fAbl1uAU8VGWAJ9lXnYqtV2IRrlOytbAZ1MWswj3c xEscoS06V93i5S8ohiOl9cVxsQshum6H9tLZZAhQAFhwQkZQpZvbgfgLgTD8MbWIcCVm TfYkTizB+5HFwQGB6fiBVN0ml2XroXrbDEQRYR8dPmh9ZteeUvNmrKvLii76TIuxe1fV Nk/3ktBwapWC5SMYHP6lZEjiiZFqeqlM9QYUuk7paddXLi7+HPDPIbZMiHkz87fPzsmX r3Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=fmtnEiYuHoEIGGLtAVBwhyqqHmXOabiSSD3liVVwZmo=; b=zdUMH6SYPd1p+2w7lIzi5pUz+t/981hqeI7cb/huNK6NRGLlJfnwnYw/C/dJU5Nl3/ rB3z3tZ/6ZZp3tTOoGBJ7pa/FvIcf96dbjcS2QR3B4tpXkG8hU+49A7Uflm9idpq2tnZ Sf7SLh1fHzvLXDhC7cF6X5FviBFufi7C37cnbPpYXUdAQO56T+Fg1rLPOiS9Zpxj9SUU +p0TNMM6xIAirVWPMlZrh3+QdCDp26kl70BPZTMlhHPk1Iebq9x7uDWHZYN3z5YUyqiv rGu6PViQwqG/4G7EXNv0NX7DUuems/RvgajDas/+juOYJ34O3i1TklfmJCSItJOBUJl9 6+Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si1635890ilv.123.2021.09.15.20.27.13; Wed, 15 Sep 2021 20:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234120AbhIPD1u (ORCPT + 99 others); Wed, 15 Sep 2021 23:27:50 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:42657 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbhIPD1u (ORCPT ); Wed, 15 Sep 2021 23:27:50 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R491e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UoXMJXX_1631762787; Received: from B-455UMD6M-2027.local(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UoXMJXX_1631762787) by smtp.aliyun-inc.com(127.0.0.1); Thu, 16 Sep 2021 11:26:28 +0800 Subject: Re: [PATCH] net/tls: support SM4 GCM/CCM algorithm To: Jakub Kicinski Cc: Boris Pismenny , John Fastabend , Daniel Borkmann , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang , "YiLin . Li" References: <20210915111242.32413-1-tianjia.zhang@linux.alibaba.com> <20210915130600.66ce8b26@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Tianjia Zhang Message-ID: Date: Thu, 16 Sep 2021 11:26:26 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210915130600.66ce8b26@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jakub, On 9/16/21 4:06 AM, Jakub Kicinski wrote: > On Wed, 15 Sep 2021 19:12:42 +0800 Tianjia Zhang wrote: >> + memcpy(sm4_gcm_info->iv, >> + cctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, >> + TLS_CIPHER_AES_GCM_128_IV_SIZE); >> + memcpy(sm4_gcm_info->rec_seq, cctx->rec_seq, >> + TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE); >> + release_sock(sk); >> + if (copy_to_user(optval, sm4_gcm_info, sizeof(*sm4_gcm_info))) >> + rc = -EFAULT; >> + break; >> + } >> + case TLS_CIPHER_SM4_CCM: { >> + struct tls12_crypto_info_sm4_ccm *sm4_ccm_info = >> + container_of(crypto_info, >> + struct tls12_crypto_info_sm4_ccm, info); >> + >> + if (len != sizeof(*sm4_ccm_info)) { >> + rc = -EINVAL; >> + goto out; >> + } >> + lock_sock(sk); >> + memcpy(sm4_ccm_info->iv, >> + cctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, >> + TLS_CIPHER_AES_GCM_128_IV_SIZE); >> + memcpy(sm4_ccm_info->rec_seq, cctx->rec_seq, >> + TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE); > > Doesn't matter from the functional perspective but perhaps use the SM4 > defines rather than the AES ones, since they exist, anyway? > > With that fixed feel free to add my ack. > Thanks for pointing it out, I forgot to modify the macro name, this is not my intention, I was careless. will fix it in v2. Best regards, Tianjia