Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp785805pxb; Wed, 15 Sep 2021 13:10:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCrrFtG3cntUQSaZXvSJKT3yHEjSaMohz3nzuu725Jl2VDrmt8iMY6oEKic2CBe9lgksIS X-Received: by 2002:a17:906:d1d6:: with SMTP id bs22mr1993834ejb.554.1631736650136; Wed, 15 Sep 2021 13:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631736650; cv=none; d=google.com; s=arc-20160816; b=O9OpnU2m88jldVYbrrUYTMqA+KKpZ8aJQE9zNkkvyo/RqfFc+FrKBro+7/yQdbRbtr HrnqElTnCm7hNeTcRk94HSD6Xce2A+Lz1bXVv5Shmk28ywlWFZ1NwGjSk5tGUdGko/12 +1pMD2OEdbijKivATdS7bofiGvFnXO036bVumhz9Psh5h52mbrqcDQGMStnFlaSHaUgn iLuaJb/XEbOCzYUISgo2mFv6da0izu5oDp/QIoiz78RurHuQbQ8aZVYtTSWC6wwfAjr4 aMULzLqcyBkmD4HqWBhWf+QiEgGnrgL9KLYmpwO3RS6mb2sDXOwpmM94zXk9j7DID2fA eiHQ== 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:subject:cc:to:from:date :dkim-signature; bh=/9K4dbOjmfA8gY2JI6lOx+yRxlhLL3pfG5+GeO9QC90=; b=pcsXxI8YmeYqychP0LIEz8q/CNZF4AuNB26fvM22YoSIR/yTr4Itaj5mvGfBWCJ6qU Jaej4GdT3Bn+CcCkt++Wjv8JQIRd+OVwwazkOYaYa4x9bn5FGG9HPuGsnXTjOrEb8T2J joL9IQhYn86HJCX7N+FqhBpli1IZ72BlyEg7WhVPpokqTseiBzsjCkqE+8bX6YXkD3EQ fUMpNiX7Xpv5YzAt3WGenR6SX07GNdgKANN5tWNvP7k2APlg5I6Je68BbUGyeJMoeayg FXaxjHjvUeS14PnL/YfRmNYDrRFtEt+K5NQ63DIFz/ajbfvUJHv2tgRJBMcgop6MjrNu jNng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kGe9nnPP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 21si1065905eji.148.2021.09.15.13.10.26; Wed, 15 Sep 2021 13:10:50 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kGe9nnPP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbhIOUHW (ORCPT + 99 others); Wed, 15 Sep 2021 16:07:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:35858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbhIOUHV (ORCPT ); Wed, 15 Sep 2021 16:07:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E71936105A; Wed, 15 Sep 2021 20:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631736362; bh=8SclDOmEAsuCPQ73+HLpv4VnpVbI6YbjsONFU4p1ccA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kGe9nnPPxyelBecpDHTZMZZ15laqi6E1iO0HE62/hhloDo5zwAFhKUKolzhg690lz etne0Wg0D+HZLoJDyp1hdVfV1gkOHIuXWIO3EaKSuMyhX2W0gC3mVlliHjzZiBC8Sl clH52ZplmUDI1jZTxvalqUmMqsG/CYpWJw4jbYBDJkMdzK/lFuUiN2B1z2LyloJY4c UuHnaxR4gZLTxeprhr6VoFBmnuH/Mxq63nBQZwzWR6CsBsZ75Tycvzp6vo/G1Bp0A5 R1l8C5YlPGt/YUNVfrI5FOYzeQOdogPDNNUiYNvMn57LC96kBQoGVJqML1mnUpn6G+ HYMPUdlDeU98w== Date: Wed, 15 Sep 2021 13:06:00 -0700 From: Jakub Kicinski To: Tianjia Zhang Cc: Boris Pismenny , John Fastabend , Daniel Borkmann , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang , "YiLin . Li" Subject: Re: [PATCH] net/tls: support SM4 GCM/CCM algorithm Message-ID: <20210915130600.66ce8b26@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210915111242.32413-1-tianjia.zhang@linux.alibaba.com> References: <20210915111242.32413-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.