Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1257900pxb; Thu, 4 Mar 2021 07:13:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJywcI3H5y/BK+3CVJ4q2y8ig/BeNWBy2kVBbASia/wtlUwCQa2bDS8AoyIw+O13d8c08XcV X-Received: by 2002:a17:906:3cf1:: with SMTP id d17mr4753382ejh.343.1614870783401; Thu, 04 Mar 2021 07:13:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614870783; cv=none; d=google.com; s=arc-20160816; b=juRsZYT00r4EWScLfxD7Pq9flVdMZ/skwbYxC0J1oj93B3vfUjywP7UihgNYtAV+tG 2s2IK7Jx3AIPzYLdONS2f0SQQ1oAVfJYvPB4RdOI5xeLI52foBj1YSLX8CNFXwG1kXEj F7LHCboxPlZWH/Gth1+VUfAHketcc2RF4TB1vPoAHUvEAWqagUOn+vj8Nit1BdPijCr7 QZLD/+k76yyLVQ2W44YwZherjktX77bn5aH76FnJYLk6Un2PXPCJI8QWF94H7jkDQhl5 6w1MfONS5wtk3z9/d/s1Jdn/FR2C/zfbAfeaHZNqrjWVC6lyJAYs1lOu9h4YGTfY/HI6 Wt3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=msj+ClQhxi320mG4bJU7Q3pKn4F3BuHCbz4idR3Z8gE=; b=L+dX3UZdoJt4K7s5qMxBEJMhDhApUZ0qXbseCBtq/GkLN78jdD3DxxLcQsjchkXydi /2bb9dfToGmpf4nA0+/elKpCq2NS7Kl0YETH8+SeTA1vq7DFyS7DJiL1q8kTE2TGePSo 6asMloKl76jFfpYUAt5RKwG+AMPhIpSBoE01ytFDsV8oPQ5B1KtTcFGjvq3htp3cEz4e VB3Qcz2sUN/rVOovQ3sAHap6t6Vfv3jg0U2iMwldDxBi1gRF8ePSgURir6XJAdxUTINb iCpG2SgScLp2OXiBV+TxM7/my3qfRr9opXhHSRoBcNEc5uEP+Dd3bdcWcpjI687S6XiA GHPw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si17385403ejh.440.2021.03.04.07.12.36; Thu, 04 Mar 2021 07:13:03 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235456AbhCDGjg (ORCPT + 99 others); Thu, 4 Mar 2021 01:39:36 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12683 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235372AbhCDGjN (ORCPT ); Thu, 4 Mar 2021 01:39:13 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Drh334P0kzlSXW; Thu, 4 Mar 2021 14:36:15 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Thu, 4 Mar 2021 14:38:14 +0800 From: Meng Yu To: , , , , , CC: , , , , Subject: [PATCH v10 6/7] crypto: add curve25519 params and expose them Date: Thu, 4 Mar 2021 14:35:49 +0800 Message-ID: <1614839750-29670-7-git-send-email-yumeng18@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1614839750-29670-1-git-send-email-yumeng18@huawei.com> References: <1614839750-29670-1-git-send-email-yumeng18@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 1. Add curve 25519 parameters in 'crypto/ecc_curve_defs.h'; 2. Add curve25519 interface 'ecc_get_curve25519_param' in 'include/crypto/ecc_curve.h', to make its parameters be exposed to everyone in kernel tree. Signed-off-by: Meng Yu Reviewed-by: Zaibo Xu --- crypto/ecc.c | 6 ++++++ crypto/ecc_curve_defs.h | 17 +++++++++++++++++ include/crypto/ecc_curve.h | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/crypto/ecc.c b/crypto/ecc.c index 4b55ad0..0798a18 100644 --- a/crypto/ecc.c +++ b/crypto/ecc.c @@ -43,6 +43,12 @@ typedef struct { u64 m_high; } uint128_t; +/* Returns curv25519 curve param */ +const struct ecc_curve *ecc_get_curve25519(void) +{ + return &ecc_25519; +} +EXPORT_SYMBOL(ecc_get_curve25519); const struct ecc_curve *ecc_get_curve(unsigned int curve_id) { diff --git a/crypto/ecc_curve_defs.h b/crypto/ecc_curve_defs.h index 69be6c7..d7769cc 100644 --- a/crypto/ecc_curve_defs.h +++ b/crypto/ecc_curve_defs.h @@ -54,4 +54,21 @@ static struct ecc_curve nist_p256 = { .b = nist_p256_b }; +/* curve25519 */ +static u64 curve25519_g_x[] = { 0x0000000000000009, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000 }; +static u64 curve25519_p[] = { 0xffffffffffffffed, 0xffffffffffffffff, + 0xffffffffffffffff, 0x7fffffffffffffff }; +static u64 curve25519_a[] = { 0x000000000001DB41, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000 }; +static const struct ecc_curve ecc_25519 = { + .name = "curve25519", + .g = { + .x = curve25519_g_x, + .ndigits = 4, + }, + .p = curve25519_p, + .a = curve25519_a, +}; + #endif diff --git a/include/crypto/ecc_curve.h b/include/crypto/ecc_curve.h index 19a35da..7096478 100644 --- a/include/crypto/ecc_curve.h +++ b/include/crypto/ecc_curve.h @@ -50,4 +50,11 @@ struct ecc_curve { */ const struct ecc_curve *ecc_get_curve(unsigned int curve_id); +/** + * ecc_get_curve25519() - get curve25519 curve; + * + * Returns curve25519 + */ +const struct ecc_curve *ecc_get_curve25519(void); + #endif -- 2.8.1