Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3859111pxb; Mon, 8 Feb 2021 01:47:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxd29YxAFRpG1c/5emxR2i7WDz8j44+VexFM7fhHck6CRnAeQRblNsrRtqj4g+uSzsjx6jp X-Received: by 2002:a17:906:7c43:: with SMTP id g3mr16047258ejp.210.1612777661941; Mon, 08 Feb 2021 01:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612777661; cv=none; d=google.com; s=arc-20160816; b=LoJtS8vZIlEdHz5XQ32p14K+N9jhnl1JjmUiJcW+khjRxnoDzOXrCNL1nhQa1PrC1w +bq3OTwLocdRiJP/3pnJ3NDd2wJnnxBrq2UxAc34G3kvyArTHKGUYVq5ZLM5PS+bEgyx KFzoaJHXm2I4LlC9amAHxI1bzzATvFRJK2xw3dXE/TB//AovwlSB3xK330UYzrPVjjXS LHzAHry1Y8VuZir7difIasvWggMm2E1PtMwnCndF9SGPISnRrEvQQzmQlAz/+kHZnVjL qmfhyyP6JqFdJBBViX5v0jkkrLW/6HRhOZu42A1Mz0ZJ66Nqwrn2rI1ZnAl18Cgqh569 WYEg== 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=BIvV0e4LV6EsYRK+2lasaNHSjhXTcLdVyzZJvq99pQY=; b=EaQJinO8ElcA3p7MjtW7nlIjz1h2kdjtspBfp3sZ8EagO97IOuCQR49elHVz3KHogN KcVlHkcT5NQZmTF3CpnA5nPOqPLKLdVUy1KbxS7AdRw8UR2JHL4GbuFv91J3DkcRqykg T/eBdfz5FRqRj94dj9MzL7yp+jCaPztoghWfvQ/VMMjMjVsHZJ47mYIefkvzLk/DVRhz 5g+uM7cT3pRyZGFJZ1J9kGlGhexPl0OA2DrfyGgcUJq1v0SRKY08SkrKdWnbJH04Erh+ qNsFwJLj6YUlu8EBct2pKbfliUqHifp7ulbiTX4KYTMR5pGv/G3hcfVwsTzojNyqqKIw QZNA== 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 m1si10771657eja.95.2021.02.08.01.47.05; Mon, 08 Feb 2021 01:47:41 -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 S231255AbhBHJpv (ORCPT + 99 others); Mon, 8 Feb 2021 04:45:51 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12494 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbhBHJmi (ORCPT ); Mon, 8 Feb 2021 04:42:38 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DZ1GH6y94zjBW5; Mon, 8 Feb 2021 17:40:07 +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:20 +0800 From: Meng Yu To: , , , , , CC: , , , , Subject: [PATCH v8 3/9] crypto: atmel-ecc - move curve_id of ECDH from the key to algorithm name Date: Mon, 8 Feb 2021 17:38:51 +0800 Message-ID: <1612777137-51067-4-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 As curve id of ECDH will be moved from its key into algorithm name, we cannot use 'curve_id' in 'struct ecdh', so we should modify ECDH driver in atmel, and make ECDH algorithm name be the same as crypto (like 'ecdh-nist-pxxx'); Signed-off-by: Meng Yu Reviewed-by: Zaibo Xu --- drivers/crypto/atmel-ecc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c index 9bd8e51..9ade6ad 100644 --- a/drivers/crypto/atmel-ecc.c +++ b/drivers/crypto/atmel-ecc.c @@ -104,7 +104,7 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, return -EINVAL; } - ctx->n_sz = atmel_ecdh_supported_curve(params.curve_id); + ctx->n_sz = atmel_ecdh_supported_curve(ctx->curve_id); if (!ctx->n_sz || params.key_size) { /* fallback to ecdh software implementation */ ctx->do_fallback = true; @@ -125,7 +125,6 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, goto free_cmd; ctx->do_fallback = false; - ctx->curve_id = params.curve_id; atmel_i2c_init_genkey_cmd(cmd, DATA_SLOT_2); @@ -263,6 +262,7 @@ static int atmel_ecdh_init_tfm(struct crypto_kpp *tfm) struct crypto_kpp *fallback; struct atmel_ecdh_ctx *ctx = kpp_tfm_ctx(tfm); + ctx->curve_id = ECC_CURVE_NIST_P256; ctx->client = atmel_ecc_i2c_client_alloc(); if (IS_ERR(ctx->client)) { pr_err("tfm - i2c_client binding failed\n"); @@ -306,7 +306,7 @@ static unsigned int atmel_ecdh_max_size(struct crypto_kpp *tfm) return ATMEL_ECC_PUBKEY_SIZE; } -static struct kpp_alg atmel_ecdh = { +static struct kpp_alg atmel_ecdh_nist_p256 = { .set_secret = atmel_ecdh_set_secret, .generate_public_key = atmel_ecdh_generate_public_key, .compute_shared_secret = atmel_ecdh_compute_shared_secret, @@ -315,7 +315,7 @@ static struct kpp_alg atmel_ecdh = { .max_size = atmel_ecdh_max_size, .base = { .cra_flags = CRYPTO_ALG_NEED_FALLBACK, - .cra_name = "ecdh", + .cra_name = "ecdh-nist-p256", .cra_driver_name = "atmel-ecdh", .cra_priority = ATMEL_ECC_PRIORITY, .cra_module = THIS_MODULE, @@ -340,14 +340,14 @@ static int atmel_ecc_probe(struct i2c_client *client, &driver_data.i2c_client_list); spin_unlock(&driver_data.i2c_list_lock); - ret = crypto_register_kpp(&atmel_ecdh); + ret = crypto_register_kpp(&atmel_ecdh_nist_p256); if (ret) { spin_lock(&driver_data.i2c_list_lock); list_del(&i2c_priv->i2c_client_list_node); spin_unlock(&driver_data.i2c_list_lock); dev_err(&client->dev, "%s alg registration failed\n", - atmel_ecdh.base.cra_driver_name); + atmel_ecdh_nist_p256.base.cra_driver_name); } else { dev_info(&client->dev, "atmel ecc algorithms registered in /proc/crypto\n"); } @@ -365,7 +365,7 @@ static int atmel_ecc_remove(struct i2c_client *client) return -EBUSY; } - crypto_unregister_kpp(&atmel_ecdh); + crypto_unregister_kpp(&atmel_ecdh_nist_p256); spin_lock(&driver_data.i2c_list_lock); list_del(&i2c_priv->i2c_client_list_node); -- 2.8.1