From patchwork Sat Jun 22 00:30:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167428 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1376530ilk; Fri, 21 Jun 2019 17:31:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAldf5QojFnl6JuM1cg4bOqSeavbpbC2eSY3VMznqR2vHNelPxFMHJwCGKrZqdExmnNRsa X-Received: by 2002:a63:88c1:: with SMTP id l184mr9361057pgd.376.1561163510680; Fri, 21 Jun 2019 17:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561163510; cv=none; d=google.com; s=arc-20160816; b=sJRgfSuBs/DuLhZ+/SqANUqOsHQOCr4J/QID6Uvj+Y4BCyPmPIGU8JCm9PqwnbOhM7 k3npnND0wP7hjrVsPv7B4qWpDgbPNS3LvLKGtHBk+26LJhE8MwCpPyqCRq/kGc8DuWn3 5WuY8JA35Bfffi2ncuZQDP+nSCeg5P1Jxyw4r1IVNM8dOpZS7ofQjNakrNkWXaIjwZK8 HjcIfVNMsTtr5s+RXjsIW10H9g9NZNS+I6OdsIoSFtWem9+tiWZg5876TcLzNUbh2QJk OpG2T9MBWQ//1IrJwcXhNrFZvvdNMPqgOkJI3EJfxoQFGs4C1OCD0IHSuMGnQl+h9jTO +PQA== 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=y03artuFEw1EqgZMcNtCu7Lvsp6XqRl3BVBaQjdCwrw=; b=PtgsQIF4ss5lu185gKNxsfNFK6KO8BrC9wA1IQpVvLIwQL1LosbVY7UBoPbgwzsZr5 4gKtCqGSfyQ4hhcm3adgjIwjGs237230q61Ki2EAEcGHYZMp/DnvIGjuVWVBUucGAr4O AUDTy1xjWaBpbKgoaOBDn82TazbSdJt/qxlVweCtUbu+KCB2oWUtQooaU/ML15Vtl+7s PwYfQC82CnJnTzCxwR+oqLyf65L1XrciyBqF5K0hnZJE3Hd8IiJ4tuyRPkRucf3f+GO+ wNaH7fCDZTKHAPrtxVO6IIW/el9glWdsDJxaYX85iDZ5zvpAWoWdkhHxjGoGQnSSU4VI j2Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E9VJbkQ6; 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.31.50; Fri, 21 Jun 2019 17:31:50 -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=E9VJbkQ6; 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 S1726118AbfFVAbt (ORCPT + 3 others); Fri, 21 Jun 2019 20:31:49 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54731 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfFVAbt (ORCPT ); Fri, 21 Jun 2019 20:31:49 -0400 Received: by mail-wm1-f68.google.com with SMTP id g135so7702855wme.4 for ; Fri, 21 Jun 2019 17:31:48 -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=y03artuFEw1EqgZMcNtCu7Lvsp6XqRl3BVBaQjdCwrw=; b=E9VJbkQ6xAG/NjVVA1nLQOt315Kl4uapklC6sIQZrozQdCDaLTDbHy3nNWLNPuJJuk 1dX2vTEiGICvC1aITRkRuuFVvy8pmx3fvuX9+1oRRwO9smRJhewPY1oT3+MAY7a4DQP2 MLPfb+nC+CsBXJDDchHVru6eRZyZor6pqGHUGf20Uih4eoHVRkwnJjIAnOCE8iU7KwVq rvWA4eviazv6TzykNSpsGS0GzITEPG5bYIe53jssdJNZIRn6bf5t7vEZS8MsxSYO8TNJ srw4O+zfmxKpc6bnGYz0qQBu6BPpluizw4EFcM5Tpf8kuNuRnU+eJEdxdSlKfGnJoHEr FwLg== 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=y03artuFEw1EqgZMcNtCu7Lvsp6XqRl3BVBaQjdCwrw=; b=V2+b1YhCUTaDaRmQE837TcSoPmp9Lfo9OmkG3prutGW0wCngoJyR9+uF3q2TD17Y0j NXamJNDFb4y8yBVKeINJAvNMyRpj5S5HCu4uUh+bf/5XvImVkLT3LXmQeRmniDYaYF5K LYawHFLcolyFDwvDOZua3zT5qVEyAay62DebgGuw+T9srd9N1LxKepR4jHe/DL41j2r7 qTMGLCWYzqarZ4o9B4tNyt0TXTyznjyCjUM17rzQx9hsSelCZvO29puki46TAu1R8TKc kkWTNOzgTKOg74kuloYDGJbYl+33mTAV7ZaJ83yxodfviakLoO3vReEuzNj0N4t+6ZlR rwFg== X-Gm-Message-State: APjAAAVUnCJHxFRwOG60zFWA/GEX6pVuuneECsVILmFxNRnvFDppYMgO SN6sGsLxwVys/lRp/4ZJAVhnCenJpNl/LsB0 X-Received: by 2002:a7b:c766:: with SMTP id x6mr5827061wmk.40.1561163507378; Fri, 21 Jun 2019 17:31:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jun 2019 17:31:46 -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 03/30] crypto: sparc/des - switch to new verification routines Date: Sat, 22 Jun 2019 02:30:45 +0200 Message-Id: <20190622003112.31033-4-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 --- arch/sparc/crypto/des_glue.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/arch/sparc/crypto/des_glue.c b/arch/sparc/crypto/des_glue.c index 453a4cf5492a..d0e3929359a1 100644 --- a/arch/sparc/crypto/des_glue.c +++ b/arch/sparc/crypto/des_glue.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -44,19 +44,15 @@ static int des_set_key(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { struct des_sparc64_ctx *dctx = crypto_tfm_ctx(tfm); - u32 *flags = &tfm->crt_flags; - u32 tmp[DES_EXPKEY_WORDS]; - int ret; + int err; /* Even though we have special instructions for key expansion, - * we call des_ekey() so that we don't have to write our own + * we call des_verify_key() so that we don't have to write our own * weak key detection code. */ - ret = des_ekey(tmp, key); - if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - *flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + err = des_verify_key(tfm, key, keylen); + if (unlikely(err)) + return err; des_sparc64_key_expand((const u32 *) key, &dctx->encrypt_expkey[0]); encrypt_to_decrypt(&dctx->decrypt_expkey[0], &dctx->encrypt_expkey[0]); @@ -207,7 +203,7 @@ static int des3_ede_set_key(struct crypto_tfm *tfm, const u8 *key, u64 k3[DES_EXPKEY_WORDS / 2]; int err; - err = __des3_verify_key(flags, key); + err = crypto_des3_ede_verify_key(tfm, key, keylen); if (unlikely(err)) return err;