From patchwork Wed Nov 8 13:38:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lesokhin X-Patchwork-Id: 835824 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yX6qk3Zk9z9s7C for ; Thu, 9 Nov 2017 00:40:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673AbdKHNkL (ORCPT ); Wed, 8 Nov 2017 08:40:11 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:43326 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752468AbdKHNi5 (ORCPT ); Wed, 8 Nov 2017 08:38:57 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ilyal@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Nov 2017 15:38:54 +0200 Received: from gen-l-vrt-094.mtl.labs.mlnx (gen-l-vrt-094.mtl.labs.mlnx [10.137.9.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id vA8DcqFE004219; Wed, 8 Nov 2017 15:38:54 +0200 From: Ilya Lesokhin To: netdev@vger.kernel.org, davem@davemloft.net Cc: davejwatson@fb.com, tom@herbertland.com, hannes@stressinduktion.org, aviadye@mellanox.com, liranl@mellanox.com, Ilya Lesokhin Subject: [PATCH v2 net-next 04/12] tls: Move tls_make_aad to header to allow sharing Date: Wed, 8 Nov 2017 15:38:29 +0200 Message-Id: <1510148317-84661-5-git-send-email-ilyal@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510148317-84661-1-git-send-email-ilyal@mellanox.com> References: <1510148317-84661-1-git-send-email-ilyal@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org move tls_make_aad as it is going to be reused by the device offload code Signed-off-by: Ilya Lesokhin --- include/net/tls.h | 15 +++++++++++++++ net/tls/tls_sw.c | 18 +----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 7cb58a6..70becd0 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -214,6 +214,21 @@ static inline void tls_fill_prepend(struct tls_context *ctx, ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, iv_size); } +static inline void tls_make_aad(char *buf, + size_t size, + char *record_sequence, + int record_sequence_size, + unsigned char record_type) +{ + memcpy(buf, record_sequence, record_sequence_size); + + buf[8] = record_type; + buf[9] = TLS_1_2_VERSION_MAJOR; + buf[10] = TLS_1_2_VERSION_MINOR; + buf[11] = size >> 8; + buf[12] = size & 0xFF; +} + static inline struct tls_context *tls_get_ctx(const struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index fcd92a9..73d1921 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -39,22 +39,6 @@ #include -static inline void tls_make_aad(int recv, - char *buf, - size_t size, - char *record_sequence, - int record_sequence_size, - unsigned char record_type) -{ - memcpy(buf, record_sequence, record_sequence_size); - - buf[8] = record_type; - buf[9] = TLS_1_2_VERSION_MAJOR; - buf[10] = TLS_1_2_VERSION_MINOR; - buf[11] = size >> 8; - buf[12] = size & 0xFF; -} - static void trim_sg(struct sock *sk, struct scatterlist *sg, int *sg_num_elem, unsigned int *sg_size, int target_size) { @@ -249,7 +233,7 @@ static int tls_push_record(struct sock *sk, int flags, sg_mark_end(ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem - 1); sg_mark_end(ctx->sg_encrypted_data + ctx->sg_encrypted_num_elem - 1); - tls_make_aad(0, ctx->aad_space, ctx->sg_plaintext_size, + tls_make_aad(ctx->aad_space, ctx->sg_plaintext_size, tls_ctx->rec_seq, tls_ctx->rec_seq_size, record_type);