From patchwork Sun Nov 22 01:57:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 330547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22C4CC6379D for ; Sun, 22 Nov 2020 01:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E40BD2076B for ; Sun, 22 Nov 2020 01:58:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=novek.ru header.i=@novek.ru header.b="HFf3G5Tp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727174AbgKVB6G (ORCPT ); Sat, 21 Nov 2020 20:58:06 -0500 Received: from novek.ru ([213.148.174.62]:39836 "EHLO novek.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727139AbgKVB6F (ORCPT ); Sat, 21 Nov 2020 20:58:05 -0500 Received: from nat1.ooonet.ru (gw.zelenaya.net [91.207.137.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by novek.ru (Postfix) with ESMTPSA id 82E95502F58; Sun, 22 Nov 2020 04:58:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 novek.ru 82E95502F58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=novek.ru; s=mail; t=1606010298; bh=JaKBmAii1rHQ+q6NunxburW8C6uTz+KMrxIZNkVsGmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HFf3G5TpxEXubbFWbSjlHZvRNrBG8zGgsL5/M5bSNtteLrtPyFNojPvdxodV1tiJA cMVZxWZDKUaV/Jt9A9Ax7yEqKN8A0bw22/APPSJICaobWxgajCio8p02qvz5gNImiC ChA24peeBn9HBTJmE1RC1/ASgPD2qPV8Kx02/NTA= From: Vadim Fedorenko To: Jakub Kicinski , Boris Pismenny , Aviad Yehezkel Cc: Vadim Fedorenko , netdev@vger.kernel.org Subject: [net-next 4/5] net/tls: add CHACHA20-POLY1305 configuration Date: Sun, 22 Nov 2020 04:57:44 +0300 Message-Id: <1606010265-30471-5-git-send-email-vfedorenko@novek.ru> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1606010265-30471-1-git-send-email-vfedorenko@novek.ru> References: <1606010265-30471-1-git-send-email-vfedorenko@novek.ru> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add ChaCha-Poly specific configuration code. Signed-off-by: Vadim Fedorenko --- net/tls/tls_main.c | 3 +++ net/tls/tls_sw.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 8d93cea..47b7c53 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -521,6 +521,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, case TLS_CIPHER_AES_CCM_128: optsize = sizeof(struct tls12_crypto_info_aes_ccm_128); break; + case TLS_CIPHER_CHACHA20_POLY1305: + optsize = sizeof(struct tls12_crypto_info_chacha20_poly1305); + break; default: rc = -EINVAL; goto err_crypto_info; diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index b4eefdb..6bb33d5 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -2290,6 +2290,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) struct tls12_crypto_info_aes_gcm_128 *gcm_128_info; struct tls12_crypto_info_aes_gcm_256 *gcm_256_info; struct tls12_crypto_info_aes_ccm_128 *ccm_128_info; + struct tls12_crypto_info_chacha20_poly1305 *chacha20_poly1305_info; struct tls_sw_context_tx *sw_ctx_tx = NULL; struct tls_sw_context_rx *sw_ctx_rx = NULL; struct cipher_context *cctx; @@ -2402,6 +2403,23 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) cipher_name = "ccm(aes)"; break; } + case TLS_CIPHER_CHACHA20_POLY1305: { + nonce_size = 0; + tag_size = TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE; + iv_size = TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE; + iv = ((struct tls12_crypto_info_chacha20_poly1305 *)crypto_info)->iv; + rec_seq_size = TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE; + rec_seq = + ((struct tls12_crypto_info_chacha20_poly1305 *)crypto_info)->rec_seq; + chacha20_poly1305_info = + (struct tls12_crypto_info_chacha20_poly1305 *)crypto_info; + keysize = TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE; + key = chacha20_poly1305_info->key; + salt = chacha20_poly1305_info->salt; + salt_size = TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE; + cipher_name = "rfc7539(chacha20,poly1305)"; + break; + } default: rc = -EINVAL; goto free_priv;