From patchwork Fri Feb 24 23:46:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9591357 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB4FF601AE for ; Fri, 24 Feb 2017 23:48:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9BF428741 for ; Fri, 24 Feb 2017 23:48:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE41D2871E; Fri, 24 Feb 2017 23:48:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F9B2874A for ; Fri, 24 Feb 2017 23:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751377AbdBXXri (ORCPT ); Fri, 24 Feb 2017 18:47:38 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33003 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212AbdBXXre (ORCPT ); Fri, 24 Feb 2017 18:47:34 -0500 Received: by mail-pg0-f66.google.com with SMTP id 5so4727415pgj.0; Fri, 24 Feb 2017 15:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f3x+2GtXPpUIvM/P2O4rpB0ZS48g5SypKLGrIzPYXY0=; b=APVJ9Hq2ljQ6jdGNrIt8ZKowfWWFj287tv/e+wXkf5OzrKrNxthfDOC/4rTSYRWcwH YUEMHPGpPSW6MBA+kxIZbAp+yjN6Zit369Q9aIoA1xbEJQliYpxkKVljI/Js75Sbbr9i ZFjsbLzuIhF0WVtIOe6oya5W5t/1vqfYS/WOQHkjKILvztChjhaAlCBWENy/Bbu2s69s 7/FT+l93tbm5Wgxgc8RYiclakve/D+K6iVplIo4iVcYhRjQRu2seVzKXQNAQdANp444p PSoy/SPJdoxbgIDSMDaCBJWabE51IwZOd2WVW7i0GdzLy5SxtiS726yXvLeuerLpNCtJ rCaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f3x+2GtXPpUIvM/P2O4rpB0ZS48g5SypKLGrIzPYXY0=; b=ofOZwKa8j3Gq3tNTQHnV/VIccWsc+o5rUeXGZCGLrnbBQclotz0hZIOh6no/Wz/jmc OrNduON0LdXOQpbM293E42j3qCzDOACzfXHqcusi8EMfYogAlFt6fTRm6wj9Lcmtc6xs W9yCpu9+8BtXZkyT6Fo60qrWIlIHnoWu/4awXI3qSu1JidFL+aY3Udj84cB8scqfVkv5 S5pNHVlUtAF3lAfxiVJRBSiDIpBbZCK7GB/jvlu2Wj1VpawPQhHbi8V87cvs37HVOYOL fOF5UxH/mWkVm8SSRakFZNXkyQ8jN5s44diGx0G6yyY06EhQVYNdVg0i3M3/wWgMBX7I eQrg== X-Gm-Message-State: AMke39k3e0jaB+mMpdJbE1bsM95cOK01AxlJUrPcUBB/RrJ6DD+EWC58t5vc+SEc5ww4GQ== X-Received: by 10.98.74.84 with SMTP id x81mr6726568pfa.172.1487980053782; Fri, 24 Feb 2017 15:47:33 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.119.30.131]) by smtp.gmail.com with ESMTPSA id m136sm17060150pga.22.2017.02.24.15.47.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Feb 2017 15:47:33 -0800 (PST) From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Herbert Xu , "David S . Miller" , linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH 1/2] crypto: kpp - constify buffer passed to crypto_kpp_set_secret() Date: Fri, 24 Feb 2017 15:46:58 -0800 Message-Id: <20170224234659.89423-2-ebiggers3@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170224234659.89423-1-ebiggers3@gmail.com> References: <20170224234659.89423-1-ebiggers3@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers Constify the buffer passed to crypto_kpp_set_secret() and kpp_alg.set_secret, since it is never modified. Signed-off-by: Eric Biggers --- crypto/dh.c | 3 ++- crypto/ecdh.c | 3 ++- drivers/crypto/qat/qat_common/qat_asym_algs.c | 2 +- include/crypto/kpp.h | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crypto/dh.c b/crypto/dh.c index ddcb528ab2cc..87e3542cf1b8 100644 --- a/crypto/dh.c +++ b/crypto/dh.c @@ -79,7 +79,8 @@ static int dh_set_params(struct dh_ctx *ctx, struct dh *params) return 0; } -static int dh_set_secret(struct crypto_kpp *tfm, void *buf, unsigned int len) +static int dh_set_secret(struct crypto_kpp *tfm, const void *buf, + unsigned int len) { struct dh_ctx *ctx = dh_get_ctx(tfm); struct dh params; diff --git a/crypto/ecdh.c b/crypto/ecdh.c index 3de289806d67..63ca33771e4e 100644 --- a/crypto/ecdh.c +++ b/crypto/ecdh.c @@ -38,7 +38,8 @@ static unsigned int ecdh_supported_curve(unsigned int curve_id) } } -static int ecdh_set_secret(struct crypto_kpp *tfm, void *buf, unsigned int len) +static int ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, + unsigned int len) { struct ecdh_ctx *ctx = ecdh_get_ctx(tfm); struct ecdh params; diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c index 0d35dca2e925..2aab80bc241f 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -491,7 +491,7 @@ static void qat_dh_clear_ctx(struct device *dev, struct qat_dh_ctx *ctx) ctx->g2 = false; } -static int qat_dh_set_secret(struct crypto_kpp *tfm, void *buf, +static int qat_dh_set_secret(struct crypto_kpp *tfm, const void *buf, unsigned int len) { struct qat_dh_ctx *ctx = kpp_tfm_ctx(tfm); diff --git a/include/crypto/kpp.h b/include/crypto/kpp.h index 4307a2f2365f..ce8e1f79374b 100644 --- a/include/crypto/kpp.h +++ b/include/crypto/kpp.h @@ -74,7 +74,7 @@ struct crypto_kpp { * @base: Common crypto API algorithm data structure */ struct kpp_alg { - int (*set_secret)(struct crypto_kpp *tfm, void *buffer, + int (*set_secret)(struct crypto_kpp *tfm, const void *buffer, unsigned int len); int (*generate_public_key)(struct kpp_request *req); int (*compute_shared_secret)(struct kpp_request *req); @@ -273,8 +273,8 @@ struct kpp_secret { * * Return: zero on success; error code in case of error */ -static inline int crypto_kpp_set_secret(struct crypto_kpp *tfm, void *buffer, - unsigned int len) +static inline int crypto_kpp_set_secret(struct crypto_kpp *tfm, + const void *buffer, unsigned int len) { struct kpp_alg *alg = crypto_kpp_alg(tfm);