From patchwork Thu Aug 15 09:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171417 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1918321ily; Thu, 15 Aug 2019 02:01:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyACxB+UOpCntLOci8ZxxRjeynEGEYVzxI81zXmea3tl4771sSbcXwsOocCUahWnQ8CvpCA X-Received: by 2002:a63:a35c:: with SMTP id v28mr2754260pgn.144.1565859717681; Thu, 15 Aug 2019 02:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565859717; cv=none; d=google.com; s=arc-20160816; b=lURwsfJXe5RyLlNeY4ZNu6AkbzaknFYMJhJK1PgySlluYfD0OFoOUsbLKk+5pu52EN kGz0iJFRwcoeCDdJMJY0IpIyzq/tqJAY0w8VHjhFHqtUnR6Sypsxo/puFWdYt86Uy7Mk iC+aMKYiqHfA3MMqYwbxK04MEzuJIx1dYtsSF/atkZ/C+RJrsCqK8IL9t3IJL0k04vTd aAJXJAeHKPWB6K9CS5jWoOivMAyn92R3CJ5Dxm1RPT9e4SWzOLGcDfY74fvAznEh2H/s 3AUt2cfv6ZNY41vr/3WuRH+LzDYwUmxzOmND/uZP1QECfP5k4yWYVChEkBBOeIZUTCHV WOEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=+kgpUivqCm6iG3E/0kf20tMpbngNNZjTQte9WULnO08=; b=dGcCrvS6JmMkbX5+y8fq7oWlDvuSX0fBUkfRb/ipsQgiMdx4Vo+CEjec14BioQ/DF5 yoON3zsAc1qzXN5D+Ua/LJAnVAiI21sWVm6odvuweyMDJzdPjukjHnF2HgETbWko8QSH PHs98LH8EK9IpIXmezXQ+/+db9YJugEWEOGqvjXYg4SBL3m2ziZetzXkvf4DLIKUk22m IE5T8H+i43oivlYQrDR3YhpQK/PcZfpECDQbr22hq3gg7e6abxVkNGnbBO2dxC0RGJlX 7zj59gXHRl7reUJNYtVYYfmbjTKWfyJ7Hv2/ZZSf+fawqKO8epS3SWzBWtONGNpG+wVX HbOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e96FvNtn; 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 g5si1559088plt.271.2019.08.15.02.01.57; Thu, 15 Aug 2019 02:01:57 -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=e96FvNtn; 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 S1730767AbfHOJB5 (ORCPT + 3 others); Thu, 15 Aug 2019 05:01:57 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34574 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfHOJB4 (ORCPT ); Thu, 15 Aug 2019 05:01:56 -0400 Received: by mail-wm1-f66.google.com with SMTP id e8so589724wme.1 for ; Thu, 15 Aug 2019 02:01:55 -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; bh=+kgpUivqCm6iG3E/0kf20tMpbngNNZjTQte9WULnO08=; b=e96FvNtns/NJo1MXRUb+181SdySwSU6p807OfAMxX+rlEgkbWWyuYRTER06B+6i+B+ vwOlY53Z2GZBOGBmDSRFKuZSEBNkCKiFVweR6/QoxCt31AQlNLlpu8yQ2DqnQhENNcff BMWZTnQjUpgX4wDDcXm5GPLvM4k3IZogxlUltvFIjqolA3SIS//yySXU7AltFFF5Fm8M 3emdZNyOiTZCV3Zw/6Joz36itzKyy769jPDd7cCGvsH7OIC/aCEp9yLJI5vGg+tH3VpJ zR3p0KCy3c+P9Ktv7P9Ij2b/4/pPBrWeCHw8QIczj7e6vuGf+fHv9OYKvI1jwky1/vZq ec2w== 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=+kgpUivqCm6iG3E/0kf20tMpbngNNZjTQte9WULnO08=; b=lzlc3u7GkSVk48LpZBRz0JpZBeQ/GOboJdTJyRA834CK13M5wiBTJaMrtl17qrBsWa I+bi17Jp3Cmli4AcqXqzmqx+yrgRKQm/UCrlC27S/uSsFQrD0WSpGIa7nJqLQSQVbTlS qjAH0+CGy/6x8WUFlKCtNh13jygaXL+OtcNcftLw9f/3jn1J60JIcxeB7qWF/Ynm2GBU TmmqD4K7Iw0X3xfmUCI7oENpvLnXaAKnA6wJ4yPj99V0CQMaC7T5RC9ox/KClQ9o6DsO Pw6GPZN/TIrU5ZozFtom+s6i6dQ/x6hef+P/bY6wIH5b95h4KgoVj73USAwhuKUgGh8/ +uWQ== X-Gm-Message-State: APjAAAWypV3lM7qiE8AQYOYviRNjNLzlNtrTXpAK1NFzRDarJjjNGFv0 DQu0fDnNBPfCbc4pEZYfMJxPxZb9sAhKcnnJ X-Received: by 2002:a05:600c:114e:: with SMTP id z14mr1594557wmz.161.1565859714739; Thu, 15 Aug 2019 02:01:54 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:a407:da00:f1b5:e68c:5f7f:79e7]) by smtp.gmail.com with ESMTPSA id x20sm3857533wrg.10.2019.08.15.02.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Aug 2019 02:01:54 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, Ard Biesheuvel Subject: [PATCH v5 17/30] crypto: omap/des - switch to new verification routines Date: Thu, 15 Aug 2019 12:00:59 +0300 Message-Id: <20190815090112.9377-18-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190815090112.9377-1-ard.biesheuvel@linaro.org> References: <20190815090112.9377-1-ard.biesheuvel@linaro.org> 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/omap-des.c | 27 ++++++-------------- 1 file changed, 8 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 484a693122af..b19d7e5d55ec 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -650,20 +650,13 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); + int err; pr_debug("enter, keylen: %d\n", keylen); - /* Do we need to test against weak key? */ - if (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) { - u32 tmp[DES_EXPKEY_WORDS]; - int ret = des_ekey(tmp, key); - - if (!ret) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } - } + err = verify_ablkcipher_des_key(cipher, key); + if (err) + return err; memcpy(ctx->key, key, keylen); ctx->keylen = keylen; @@ -672,20 +665,16 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, } static int omap_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, - unsigned int keylen) + unsigned int keylen) { struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); - u32 flags; int err; pr_debug("enter, keylen: %d\n", keylen); - flags = crypto_ablkcipher_get_flags(cipher); - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(cipher, flags); + err = verify_ablkcipher_des3_key(cipher, key); + if (err) return err; - } memcpy(ctx->key, key, keylen); ctx->keylen = keylen;