Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1053865pxf; Thu, 25 Mar 2021 23:17:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnS17TxyUmpvHLC/DPwczG55btsUNE0tBjqYI7tUpk2l/vbHs66cQmrih/6jvM7J6zNLqJ X-Received: by 2002:a17:906:8043:: with SMTP id x3mr13300612ejw.149.1616739456735; Thu, 25 Mar 2021 23:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616739456; cv=none; d=google.com; s=arc-20160816; b=HvDRWrUeIxkGk5TUphfqG0f7ZwguTHvqTxPfruQ8xXggHRFSN35hBmi304ceBwJUXW CsjbUkILL1MqVA3ye/01+rcoSuDnSjXF538NWolIK1201wfOGfWrXoyajSvy+Y4ww4dh cPHGKglPwgQYwCr+hkUlDCLKo1ASwZITgtTR/1ah19m2vSxgs1dcGX9/ot0/Hjzx/Cji 3R8GXuhHc+F7Ito/nLZnb0cR1gDNqKclLBb93fZHkk1QyUwVishjgH8J47YJHB+J8iwD Z16QoK5lto98i49o6Gyn4CF71mK+eze8M63wJNhA5N4Xg74Lq04h4IWMit7aEJl7a0SW FPZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=I3/C3SnTiyh5RpX2BkuU+DA0fQe2gcOkCeVDVujzSss=; b=iNcw8t0Ap3dDR60MY/XspWCYJ2fwWp5V8rNJi4NaP1FRfmTnIiVB6RE3cYrJd/ELIQ cWfjis9TmYFSh36/ES6H5uZqfWjIAB2fJOsGRRVgfz9nRdz0RTmERciu99Pi0eJnTOOG 2WL28o0QMhB2LapQsiKGHa9TsPuvFfq6DFr3Rs915YTs7hIADMQE4mGsaWsInazagDOE IG+1VPqdC9Kdhe9nvnMfzXnygdN4aeerSw9vjsXkvI0Ks1SgJh2/MwrZWR7ww20tAf2n oizITNyoxvFa0+xdXOapl0JL7YBv6SZoB96idnATlpKCFhmiMMSBhn9mDL4WBzJecYSn TSHg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si6281689eje.45.2021.03.25.23.17.05; Thu, 25 Mar 2021 23:17:36 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbhCZGQ2 (ORCPT + 99 others); Fri, 26 Mar 2021 02:16:28 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14483 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbhCZGQN (ORCPT ); Fri, 26 Mar 2021 02:16:13 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F6BWP5H8SzyNk2; Fri, 26 Mar 2021 14:14:09 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Fri, 26 Mar 2021 14:16:03 +0800 From: Meng Yu To: , CC: , , , , , Subject: [PATCH] crypto: hisilicon/hpre - rsa key should not be empty Date: Fri, 26 Mar 2021 14:13:32 +0800 Message-ID: <1616739212-7751-1-git-send-email-yumeng18@huawei.com> X-Mailer: git-send-email 2.8.1 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 We should ensure key is not empty before we set key. Signed-off-by: Meng Yu --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index 53068d2..7cf7d80 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1093,6 +1093,9 @@ static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key, struct hpre_ctx *ctx = akcipher_tfm_ctx(tfm); int ret; + if (!key || !keylen) + return -EINVAL; + ret = crypto_akcipher_set_pub_key(ctx->rsa.soft_tfm, key, keylen); if (ret) return ret; @@ -1106,6 +1109,9 @@ static int hpre_rsa_setprivkey(struct crypto_akcipher *tfm, const void *key, struct hpre_ctx *ctx = akcipher_tfm_ctx(tfm); int ret; + if (!key || !keylen) + return -EINVAL; + ret = crypto_akcipher_set_priv_key(ctx->rsa.soft_tfm, key, keylen); if (ret) return ret; -- 2.8.1