From patchwork Thu Jun 27 12:02:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167934 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2249341ilk; Thu, 27 Jun 2019 05:03:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKjija0sOMxeC6qKS7TE21+I5Yz1vmkEpGqGsPasBUuhwdgwoKhvPPWpo/351EYIXDknsq X-Received: by 2002:a17:902:4201:: with SMTP id g1mr4277441pld.300.1561637012793; Thu, 27 Jun 2019 05:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561637012; cv=none; d=google.com; s=arc-20160816; b=gmucMiUmpO9ly6BUBfyNZBHquj6yQKFzQMjFCZhFnUAp9I2EoOqDWap5H9hLud5OlF RvU+5TITkwTlB4slmiwoB6lVhT6cwj/g1MZZXDh2xmTkQOvCcNsu7iJnpaLZ7n2CPvGr /5P5ROFQQTkzg4pm3J/7/EMnbXcTlUdVjLwivf99gIYqrnAdz0xFtJgU7bSdOwYunElN oeuEvZhgSIFAZJivFxkHcm7BJlUwq20hwWr2oH32z2xzFYQUVlI8n83GR3n8ALx0M2qB Ni+DovSqRrJ3FnS0Uqu0DESpPempihuxnpZ1zzHaRFlCOwyrt4ZmVL9ou6XcA/SDDbrB n2Tw== 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=QKKvnKfAoojqb9qpbzog+67ExgqfuGGUR2Pd0cRpEHk=; b=NpPkEtWFb5mmC9MvVII2BQYSd4l4iZ0Kyi8shp5biLEJpMveb8GhcMBnW2td2EdLIA vtP50utmXzJSdXDCBoh1jY+CFhQf0EVZULVvmTPv5qc433krhIVdomr9NXqLHkim/xTE ek9oEzg18jvXyuL3vntyQzLtqo+bNqhudZCJFU8ZjulnN809xC2X4t8SPyF2gXI9nC9L 88ZIq1Js8Z4FFYPyazvDtcquHtsr3LrymLSK5tfGoeyXotVJS/E7xm47VE3AgwxsqE0A j5D35xgzCWhBlwQgKO1UdfS4I+ldmfcpxkn4Ywkv1HIjRbcGLLDt7Fo9M2hlA+HKWkHE ZtVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YO63AJYr; 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 m39si2229121plg.155.2019.06.27.05.03.32; Thu, 27 Jun 2019 05:03:32 -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=YO63AJYr; 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 S1726462AbfF0MDb (ORCPT + 3 others); Thu, 27 Jun 2019 08:03:31 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44742 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfF0MDa (ORCPT ); Thu, 27 Jun 2019 08:03:30 -0400 Received: by mail-wr1-f67.google.com with SMTP id r16so382533wrl.11 for ; Thu, 27 Jun 2019 05:03:29 -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=QKKvnKfAoojqb9qpbzog+67ExgqfuGGUR2Pd0cRpEHk=; b=YO63AJYr8M/E6foKiZqJWaQhhv0dOKiQrz+/PxMLvOsFBuFGX6x8rKPkTmKRXYq3TD Tr7t+JKNzZbXcUK6Lboj1K9SiiNr5DF5sqZx5qANPmnzk389Pg5FDgzgBYA5vhOkcaBs 4cCuxVWZN+q4+IuNIGp52FFKTYkAV8GbgBxaC8rAhCKtlQDclin2Ku/jR6hJficiPlzM ZNnk88Bevawh2liPLq+dJfWB56VdjyY0yD9xCceqXa7k1MmXcPk3NX50IdAqEJ67qc7z XLM34Hrg/D+4Mxn+86ingG9Jvmpefl78H7uT+NIh0hys1ab+v5DVRW8qsNukwiXCSEU3 HNaQ== 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=QKKvnKfAoojqb9qpbzog+67ExgqfuGGUR2Pd0cRpEHk=; b=OQ9DbP+ycbXlQMSD9fLugi196qT5yDLWpbaRiMt+UX0wVXkOJd4kuDYizH+0vwL9no ahhlmBRKj3bFa4oCtWqbGaB18u3bZxTR8qwd4Te51TDypbI3Bngw6fO3/C2Fgh3Hcqjz dlyO4+zFTnaDSeKZ3G5RNYah83E9P4e7AWv6giD+X0iiKh9v9d0vJSX328vZgKHUGP0S 0nbn+9VUCVDx5ApAc8IehlEdcea8fnKE0fLxSlw2+TrlGat16W+k4Bv76adFD06cWAHm RvepXcqopUq1apn5086o9Ymt9hLVa/G+PrPftOKhVDcFRUszvlZCMq/V903vnL/N0dbV 76JA== X-Gm-Message-State: APjAAAV9ms6hZigPONB0EBX58adYNHPhLf+4EaQzaOtdPpjU51R2pA/M Ac8bwG9WmIBhFGM2B+9cESgZ0j6mOPpW+g== X-Received: by 2002:a5d:4909:: with SMTP id x9mr2820836wrq.226.1561637008133; Thu, 27 Jun 2019 05:03:28 -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 z126sm7732431wmb.32.2019.06.27.05.03.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:03:27 -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 , Harald Freudenberger Subject: [PATCH v2 02/30] crypto: s390/des - switch to new verification routines Date: Thu, 27 Jun 2019 14:02:46 +0200 Message-Id: <20190627120314.7197-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627120314.7197-1-ard.biesheuvel@linaro.org> References: <20190627120314.7197-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 Acked-by: Harald Freudenberger Signed-off-by: Ard Biesheuvel --- arch/s390/crypto/des_s390.c | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c index 1f9ab24dc048..99edfb4907b5 100644 --- a/arch/s390/crypto/des_s390.c +++ b/arch/s390/crypto/des_s390.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #define DES3_KEY_SIZE (3 * DES_KEY_SIZE) @@ -34,27 +34,24 @@ static int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len) { struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm); - u32 tmp[DES_EXPKEY_WORDS]; + int err; - /* check for weak keys */ - if (!des_ekey(tmp, key) && - (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 (unlikely(err)) + return err; memcpy(ctx->key, key, key_len); return 0; } -static void des_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) +static void crypto_des_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) { struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm); cpacf_km(CPACF_KM_DEA, ctx->key, out, in, DES_BLOCK_SIZE); } -static void des_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) +static void crypto_des_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) { struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm); @@ -75,8 +72,8 @@ static struct crypto_alg des_alg = { .cia_min_keysize = DES_KEY_SIZE, .cia_max_keysize = DES_KEY_SIZE, .cia_setkey = des_setkey, - .cia_encrypt = des_encrypt, - .cia_decrypt = des_decrypt, + .cia_encrypt = crypto_des_encrypt, + .cia_decrypt = crypto_des_decrypt, } } }; @@ -226,7 +223,7 @@ static int des3_setkey(struct crypto_tfm *tfm, const u8 *key, struct s390_des_ctx *ctx = crypto_tfm_ctx(tfm); int err; - err = __des3_verify_key(&tfm->crt_flags, key); + err = crypto_des3_ede_verify_key(tfm, key); if (unlikely(err)) return err;