Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3086175ybd; Fri, 28 Jun 2019 02:36:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpIOrCR4z49UOgBw25jGpOpsVKXnLBpin8fPntL9V25fhJkKiVZWLpyeUuLtyZ/1ChgBDP X-Received: by 2002:a17:90a:9bc5:: with SMTP id b5mr12038635pjw.109.1561714582112; Fri, 28 Jun 2019 02:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561714582; cv=none; d=google.com; s=arc-20160816; b=0luaeZBHCB25sEaNbsuNrdmXufdmtUSMsau8UZVkngOPhMapxXF258EwTfG5y/QLGI fnoATzoyZQ+PQyiFQDl8UmJBD5KSGjY21wj+yi3zB8XRieV86EEU05b3uUmBiaQYyLES h3aHWKKU4p7mbA2L+42n7Pd4fmQtR508bb8uegYItSvbomnIOAOwpcg9+Tfj1WkJzrQa NJKQsENY0n6mEuwqpl+nAhhD1Yxe+98b4c6Aq90JF4fCJvPQFfCsZNimi1XFdzzRscOy MvAwyqk2aKJn3m5WI/13y7IsHT2voJxLjdQyHZVu2xiX8c+Wb+ebmCibqEzl9RPmB2HT 0uoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q5518Fu0qbEYULyTPyyJZ5MNF13pn8CvciS2tOCCXSU=; b=0YX9PKe81RRAxdnbLpY7y1z1UvsdyyyMebsZwwMEar6wrCzcfGaRhJH61p+P0aHRnz WzjYYnCoT7yjVFm0bdNurwyibtwBXVior0rWd/MPxUZXkCuPWV44PWmh1lgEB0xWSE4D 9TQZQCE/9iOr/j/aBjxHbiGwcEIrALdWjoRWKm1ogVoJd9peeI+CKzJqIabONIGnV3JN A9eaKavNb9vKz6Db7pebiYxKJFYWOYrLZrcU6RwwVDXBajCmliRu+pLGgbFLS4PVQ1P7 r/WpKGvGehtB63GPXlWrWwV7+6EVPq+nlkFmsnSopBhngFYRfPCQOjMkVR7PaiMRVe8y Jz1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BtHuZ18E; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d132si1958536pfd.102.2019.06.28.02.36.08; Fri, 28 Jun 2019 02:36:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BtHuZ18E; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726678AbfF1Jfw (ORCPT + 99 others); Fri, 28 Jun 2019 05:35:52 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35013 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbfF1Jfw (ORCPT ); Fri, 28 Jun 2019 05:35:52 -0400 Received: by mail-wr1-f67.google.com with SMTP id f15so5564750wrp.2 for ; Fri, 28 Jun 2019 02:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q5518Fu0qbEYULyTPyyJZ5MNF13pn8CvciS2tOCCXSU=; b=BtHuZ18EzYN3SILXl9LvM0f7VRwtGKe4rW+9i4aVHuFqG4pcyzhfOVDIS8CVHbMMOq kfvOPlmSVMUgCnFXIOTWFutPGlOLE3gaaWYItJvAL9u34HzuqbCTE+DBG0TvzW4FfYJW tjOxaXVgL7AoDQwZI8RxVe/cav2o4TTQWn2kqV092roTeLrtCQuY0LWyAYs9x1W+wWCX O0qqkY/ISJh2K5p+AI9ZEr6um0oF6oRiOxSqEoIp6Vous/dyBGVIP/dPZjVRTzl5F5su zQNwgGFhR5bSjfQdFlqVprBJ6g35zAB0IgmWKEEn6tuDNd5nDkBOdwdUQxCapQyWmhE0 QHug== 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:mime-version:content-transfer-encoding; bh=Q5518Fu0qbEYULyTPyyJZ5MNF13pn8CvciS2tOCCXSU=; b=baGSQPkn/GTuhigl24nuWiPQgmS4Cr/scdBbz+dI20qJ3nccYgu9oXnMuoZyXXlzkT sIFp4kz6gXVyIDnM8BRbf2iPHmv1nt6irwCBIplDpQvn2c3beoQ+OYMFm0Sgoc6LMa0W BcLMbgK/dbLtobfHwL4zftsQMA9LPIlp7/OFR+nqkRGCd76zRl9grJPrGyBkQjG67Wva 8vQAUmnQ+crmKUF8vOHqFsj+rwJa2h/sJY3ivh+0UkAhIQFXo6dVghSsi+CBqr0bT06Y hfPzrtmJKVKAxJoq1ykvjtXXwxPThAnG1BT8MnQbUtZazCYRoZVkH2g8es2xrTLJrksj yosA== X-Gm-Message-State: APjAAAWICZ/KmUA8zwr+cY6X7Lggn8Smcc17vE/QZocBXkXUzboK8tyH tIUzwf/rYMolnawgUIqEpurhhVXjf8mZcg== X-Received: by 2002:adf:a305:: with SMTP id c5mr6915355wrb.29.1561714550294; Fri, 28 Jun 2019 02:35:50 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id m24sm1709910wmi.39.2019.06.28.02.35.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 02:35:49 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@kernel.org, horia.geanta@nxp.com, Ard Biesheuvel Subject: [PATCH v3 11/30] crypto: hifn/des - switch to new verification routines Date: Fri, 28 Jun 2019 11:35:10 +0200 Message-Id: <20190628093529.12281-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190628093529.12281-1-ard.biesheuvel@linaro.org> References: <20190628093529.12281-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Signed-off-by: Ard Biesheuvel --- drivers/crypto/hifn_795x.c | 29 +++++--------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c index d656be0a142b..5a86d0cf9070 100644 --- a/drivers/crypto/hifn_795x.c +++ b/drivers/crypto/hifn_795x.c @@ -30,7 +30,7 @@ #include #include -#include +#include static char hifn_pll_ref[sizeof("extNNN")] = "ext"; module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444); @@ -1951,22 +1951,11 @@ static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key, struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct hifn_context *ctx = crypto_tfm_ctx(tfm); struct hifn_device *dev = ctx->dev; + int err; - if (len > HIFN_MAX_CRYPT_KEY_LENGTH) { - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -1; - } - - if (len == HIFN_DES_KEY_LENGTH) { - u32 tmp[DES_EXPKEY_WORDS]; - int ret = des_ekey(tmp, key); - - if (unlikely(ret == 0) && - (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } - } + err = crypto_des_verify_key(tfm, key); + if (err) + return err; dev->flags &= ~HIFN_FLAG_OLD_KEY; @@ -1981,15 +1970,11 @@ static int hifn_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, { struct hifn_context *ctx = crypto_ablkcipher_ctx(cipher); struct hifn_device *dev = ctx->dev; - u32 flags; int err; - flags = crypto_ablkcipher_get_flags(cipher); - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(cipher, flags); + err = crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(cipher), key); + if (err) return err; - } dev->flags &= ~HIFN_FLAG_OLD_KEY; -- 2.20.1