From patchwork Sat Jun 22 00:30:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167438 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1376696ilk; Fri, 21 Jun 2019 17:32:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPAC5WXSe1Ng67H4Cvcdomr7CzpwI2Isdqct1qALawqrT8+H70KoHs+/ZJCVnxFyIdxJ4K X-Received: by 2002:a63:6156:: with SMTP id v83mr15097317pgb.358.1561163522630; Fri, 21 Jun 2019 17:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561163522; cv=none; d=google.com; s=arc-20160816; b=lvH1buSk3sfsFxZ/9Dw5jUMEn6u1D9YrNpdAnw8qhpEfmhWitf8fp9r2hANIRxu5M7 fXLipqiZfSRwhFw4BCuHR5zPenJO3XHRe5saYPUOj3eozdRRVusA9b2ALAkhQ0d5+Kh5 k8JiHIL91ThdRtVof/Cm6qGzIV8HkRH73Mw2JhlI7CvFXC4DM3FsFzj85IR+cjtw7h+Y 2bBsni/5JRcBfWzmx62zQ6ORq/NA9Hr5b8ajUwwVRGpLSNY5xwGWVfIdpVxCxiqicTW8 S67ON3K/i12bf7IPJc1/jCs/VUThJMSRTLl2Ndm7ePg1hZ76yj0B2N551o4jPWQpqqxM 89AA== 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=vApWO3NPTtkZ39m30CStMxAxSIOK9CFxw47NF6Cp5iU=; b=0qRj+bFYEcNdNWzi0j2717RJ8lU5l/2+eSjwOsJKruycftFP/GCAlMDNcWisUpP3Ll LWoIWY9AJ8sVyx39Ipovem1K4l/6WljEZeS4uvV6ahRQXHsjSLpXy9/ayd6XUsByq756 +iOaRYrvsou3VgFIVRhUhgQkNWQXEPxiGiHzMc2VFVLcUx7ZrqkklXUlarwb3nPapEGT K8R6cYVi+QIxFy4l+LSJbgQmeM8xKJ99GZaK0eZNsuUChbtM09dMBBgYy8zJrMrXv55G f9HRDmfghGqRWYVdGgXMqFLJahp//QhKVad9ZB8+Se5plqAuQ6uVO8krdFV3JOeVfRec eNww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XSaTX3dh; 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 v10si4096271plg.320.2019.06.21.17.32.02; Fri, 21 Jun 2019 17:32:02 -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=XSaTX3dh; 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 S1726203AbfFVAcC (ORCPT + 3 others); Fri, 21 Jun 2019 20:32:02 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42654 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbfFVAcA (ORCPT ); Fri, 21 Jun 2019 20:32:00 -0400 Received: by mail-wr1-f66.google.com with SMTP id x17so8087954wrl.9 for ; Fri, 21 Jun 2019 17:31:58 -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=vApWO3NPTtkZ39m30CStMxAxSIOK9CFxw47NF6Cp5iU=; b=XSaTX3dhYLHnsAwzlSHynStn3Vli6o558owwN/zYBthggLpHrs9rvVKdcf0cCJlz/i 5eLRTZOLv0/QiByvi8tIlPc6pcdMelYtHSbLKJXqI/bj4xFBHxs6XPjzDQut+peTZdxl wva+M/bKbkikgNKv5ioPu15S/25i7nz1GNsq2xnOcW6zNhN+7RKcVKI1kc+aRmpkmrW/ TuPOGFNyMU/377dJyuKLqGXWl+hyvVu8UMoQX50aHiZkR+uU+8vJm6zhhsGyFPlov9KO Znk7HYr0XmdEylL1PPVE7a6VVQSpgXON0cw8AIkqnHawy39ppxyDxlm3KbQAbQweWgcE hIww== 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=vApWO3NPTtkZ39m30CStMxAxSIOK9CFxw47NF6Cp5iU=; b=pIyr5Dcdsk9mrNvGB/lzPlqVgTna12jpcAnQ2+xCfupVfONRpS4GnSsrx6BLOPJ9vx keFWzEfGgStWh7RvRA7PZ/oh3F7FrsVfJhWjCb+Rn3UvI8oAPfuRoLjEnRf6gYFxh+xM BYVpg/6KAJQr2DKx2/dO11UoljCaVuP/AKK+bl+86pZNw5oHlya7mrDDTlpnTUY1LePM F67QLM9QjnQ6FTvni4IRmNbyh7CXhT7q40hNWFZ2PtM57QG/ihSUkv8vBINaJCoKtqQw Sihc1vXGDKGcIY85huTXs1CVz0DfkBFPGAOrI2Y5RYZxGclPniVU7hIbifi/2WMcI5EB buDA== X-Gm-Message-State: APjAAAXlj+hQ6zHgebHK2wjRzxAwAtEYfOz5E5+r1rAQPlXJstFrXmI8 dZk/Fpvv/RD1/N/gPq5zsfu582ywnqofmoSM X-Received: by 2002:a5d:5510:: with SMTP id b16mr63602486wrv.267.1561163518061; Fri, 21 Jun 2019 17:31:58 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:99d4:1ff0:ed6:dfbb]) by smtp.gmail.com with ESMTPSA id v18sm4792019wrd.51.2019.06.21.17.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jun 2019 17:31:57 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@google.com, Ard Biesheuvel Subject: [RFC PATCH 13/30] crypto: safexcel/des - switch to new verification routines Date: Sat, 22 Jun 2019 02:30:55 +0200 Message-Id: <20190622003112.31033-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190622003112.31033-1-ard.biesheuvel@linaro.org> References: <20190622003112.31033-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 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/inside-secure/safexcel_cipher.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c index 8cdbdbe35681..82cc6f003bc9 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -963,19 +963,11 @@ static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key, { struct crypto_tfm *tfm = crypto_skcipher_tfm(ctfm); struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); - u32 tmp[DES_EXPKEY_WORDS]; int ret; - if (len != DES_KEY_SIZE) { - crypto_skcipher_set_flags(ctfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } - - ret = des_ekey(tmp, key); - if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + ret = crypto_des_verify_key(tfm, key, len); + if (unlikely(ret)) + return ret; /* if context exits and key changed, need to invalidate it */ if (ctx->base.ctxr_dma) @@ -1074,7 +1066,7 @@ static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm, struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm); int err; - err = des3_verify_key(ctfm, key); + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(ctfm), key, len); if (unlikely(err)) return err;