Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3860192pxb; Mon, 8 Feb 2021 01:49:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSaPSY29xMDS0mYVumm9aoz9o9Wv6cAN/yZ1BmjAp/Rer2ImtUBa6jtXIgo6fkpQKUssSt X-Received: by 2002:aa7:d7d3:: with SMTP id e19mr8120100eds.288.1612777788585; Mon, 08 Feb 2021 01:49:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612777788; cv=none; d=google.com; s=arc-20160816; b=Yrl1VfD9G0xj1NHwvrTSK1pTuAkWknU6CjVRkcI56IDHl1AHODmzlw3+eIHVW5RFMk ITcqxEFIzMdXS9gA+/gAU2JxtMBEz8vTQPmsjeeXuq4HCepCXvNLCd9faJErHOJNu0gO slAKz1X+Hfnoujns9UKqdAOa9TIUDQQwtCtmhJzbrLW8U2v8iyXtwIpyppoSi09vJAc9 Tkztfq+dt4rHTRZuDWE0/FVineWMCUpBM7q6m3biDb4srHD8wevZOOX+7toznpKb/jwA FKrR+LNNNx+YZSgI2EM6b8+lqcUXOgWbUb4K34PhAI9Rof5yoqapi8n1wd6dkE5BHf+5 pmTg== 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=P8wQ/7pXtRfs0cMIKTIExdg2ddFDK/7dDjfKN2HgWZM=; b=OP9tTgLfbekSMoT8Skyzc7lTz11YaF74CTPk8K1v5yG4T99wxX4D8aa2sM3f7wrHuh tkhXgwZHAIlNlOp+4VC60Q4wOjyzkp/xw16xUnePch4+ZBhIjU3FNRaRlAyK4GKT0cSJ XZg3v4/UmnNl+5GcJZvDo+lmKa7glEwr94xUNvZpzZwNpEzwBF5gnTf6cQCvLiVnYffR b/A1a9h9u0Ki9L+rr4RfjFX6K8ZP7XoaIHQr7g6BqsXtXZoXhFNf+3ITLK9aWYNL3kEq fIcRNoSmJ6szrKYVcirooBW9eV4rzYLZQ9TrhIbTeGDG0b1xRl+A/sBa0K2eN0T8C3if F3pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 s20si11932768eji.387.2021.02.08.01.49.24; Mon, 08 Feb 2021 01:49:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbhBHJrf (ORCPT + 99 others); Mon, 8 Feb 2021 04:47:35 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12497 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbhBHJp1 (ORCPT ); Mon, 8 Feb 2021 04:45:27 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DZ1GJ2N4XzjL0D; Mon, 8 Feb 2021 17:40:08 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Mon, 8 Feb 2021 17:41:21 +0800 From: Meng Yu To: , , , , , CC: , , , , Subject: [PATCH v8 8/9] crypto: add curve25519 params and expose them Date: Mon, 8 Feb 2021 17:38:56 +0800 Message-ID: <1612777137-51067-9-git-send-email-yumeng18@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1612777137-51067-1-git-send-email-yumeng18@huawei.com> References: <1612777137-51067-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-crypto@vger.kernel.org 1. Add curve 25519 parameters; 2. Add curve25519 function 'ecc_get_curve25519_param', 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 | 18 ++++++++++++++++++ include/crypto/ecc_curve.h | 7 +++++++ 3 files changed, 31 insertions(+) diff --git a/crypto/ecc.c b/crypto/ecc.c index a631d3e..d8dbe7a 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 bcd7b58..f37eced 100644 --- a/crypto/ecc_curve_defs.h +++ b/crypto/ecc_curve_defs.h @@ -160,4 +160,22 @@ static struct ecc_curve nist_p521 = { .b = nist_p521_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