From patchwork Thu Jan 25 03:10:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10183533 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FE8460388 for ; Thu, 25 Jan 2018 03:10:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C3228A03 for ; Thu, 25 Jan 2018 03:10:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28CC628A25; Thu, 25 Jan 2018 03:10:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2A1328A03 for ; Thu, 25 Jan 2018 03:10:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932998AbeAYDK0 (ORCPT ); Wed, 24 Jan 2018 22:10:26 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40974 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932925AbeAYDKZ (ORCPT ); Wed, 24 Jan 2018 22:10:25 -0500 Received: by mail-pg0-f67.google.com with SMTP id 136so4173890pgd.8 for ; Wed, 24 Jan 2018 19:10:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=n9jy8snUn1/w5EthzorB7oTvYl3CR+pGp0OKgPqcH+w=; b=D13l+Nhxi7YkAa11r1GRUf3TetVX3WpVgYY9apI/a0VryBN0qatiphe36mticLNjna tnZnlJXjeNaWEgQWRb3ENNArlKgOTTlOAYrfQS0VmI3jL+Ob1FOsYhHrciJRX54/+WfV neapD+g8pDlppBMd0DwX03cWf8NJhpy26PIYyc1Jf9BjvL7Ccl3mNqxznCKG5R6ehL5t 3PaEfKz/9Gpwm0Ub0M7Nn843z4BjmMdipttoIYd/yzdw59YtQTubhG+VmHGuSXYh8len bjPfayFp98kSQ0KAnTONGxpuFpiaWxaBDJyY20hZNQXC1EuKs2WiFMqEkKau2cTCdzb4 8vRg== 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; bh=n9jy8snUn1/w5EthzorB7oTvYl3CR+pGp0OKgPqcH+w=; b=X0nPX+GqwdkNQFZy78Z65NBUV7DRFs5Bpgvrvq2lC/6MyKAcdE++eYvrfbq6NTLCAx wAniC/xJVCTSSJQEL+uYJpeOqb9xFpUDE60PnsDdxbcWe2MASgjK43Llpt7egX5iqsVU T7XgXcXCSiV9j6jTecDyOHBaq4IXeB1I3LHdXTsyCM+ETBKonQpnvJ59HaG+AZIRMBwb tPZETtdwCSl14P7yWUnPAw/PzAOI9Qw3pNsv5HNaV2wQLX82QKWb/wpW1b6jg4I1ZNoZ V9X6xi5emnWU1bWMos6g5QQmeAAJPboKwgVmNq3m4h8fJdtTbFZ7FKV1G70o8dLIn7Je nejQ== X-Gm-Message-State: AKwxytcnb1EKIeoaWzyqQj+xGiEdUIx/URCa4Kh1Kr2h9ZZ1cPEEV1xQ pU2UgUxIMs5dgLYXOPihl9CkzQsw X-Google-Smtp-Source: AH8x226y40sFcKB+g8TS7+37Rn5kzUw2X36fDlajbaSQRF37LWXCF2dj9AK5ePem9JY4yWOCpKJ8YA== X-Received: by 2002:a17:902:714c:: with SMTP id u12-v6mr10326624plm.1.1516849824704; Wed, 24 Jan 2018 19:10:24 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id k10sm2022324pgq.89.2018.01.24.19.10.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 19:10:24 -0800 (PST) From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: "David S . Miller" , Tim Chen , Eric Biggers Subject: [PATCH] crypto: sha512-mb - remove HASH_FIRST flag Date: Wed, 24 Jan 2018 19:10:21 -0800 Message-Id: <20180125031021.888-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.16.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers The HASH_FIRST flag is never set. Remove it. Signed-off-by: Eric Biggers --- arch/x86/crypto/sha512-mb/sha512_mb.c | 30 +++--------------------------- arch/x86/crypto/sha512-mb/sha512_mb_ctx.h | 8 +++----- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/arch/x86/crypto/sha512-mb/sha512_mb.c b/arch/x86/crypto/sha512-mb/sha512_mb.c index 458409b7568d..39e2bbdc1836 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb.c +++ b/arch/x86/crypto/sha512-mb/sha512_mb.c @@ -107,15 +107,6 @@ static asmlinkage struct job_sha512* (*sha512_job_mgr_flush) static asmlinkage struct job_sha512* (*sha512_job_mgr_get_comp_job) (struct sha512_mb_mgr *state); -inline void sha512_init_digest(uint64_t *digest) -{ - static const uint64_t initial_digest[SHA512_DIGEST_LENGTH] = { - SHA512_H0, SHA512_H1, SHA512_H2, - SHA512_H3, SHA512_H4, SHA512_H5, - SHA512_H6, SHA512_H7 }; - memcpy(digest, initial_digest, sizeof(initial_digest)); -} - inline uint32_t sha512_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint64_t total_len) { @@ -263,11 +254,8 @@ static struct sha512_hash_ctx mgr = cstate->mgr; spin_lock_irqsave(&cstate->work_lock, irqflags); - if (flags & (~HASH_ENTIRE)) { - /* - * User should not pass anything other than FIRST, UPDATE, or - * LAST - */ + if (flags & ~(HASH_UPDATE | HASH_LAST)) { + /* User should not pass anything other than UPDATE or LAST */ ctx->error = HASH_CTX_ERROR_INVALID_FLAGS; goto unlock; } @@ -278,24 +266,12 @@ static struct sha512_hash_ctx goto unlock; } - if ((ctx->status & HASH_CTX_STS_COMPLETE) && !(flags & HASH_FIRST)) { + if (ctx->status & HASH_CTX_STS_COMPLETE) { /* Cannot update a finished job. */ ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED; goto unlock; } - - if (flags & HASH_FIRST) { - /* Init digest */ - sha512_init_digest(ctx->job.result_digest); - - /* Reset byte counter */ - ctx->total_length = 0; - - /* Clear extra blocks */ - ctx->partial_block_buffer_length = 0; - } - /* * If we made it here, there were no errors during this call to * submit diff --git a/arch/x86/crypto/sha512-mb/sha512_mb_ctx.h b/arch/x86/crypto/sha512-mb/sha512_mb_ctx.h index e4653f5eec3f..e5c465bd821e 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb_ctx.h +++ b/arch/x86/crypto/sha512-mb/sha512_mb_ctx.h @@ -57,11 +57,9 @@ #include "sha512_mb_mgr.h" #define HASH_UPDATE 0x00 -#define HASH_FIRST 0x01 -#define HASH_LAST 0x02 -#define HASH_ENTIRE 0x03 -#define HASH_DONE 0x04 -#define HASH_FINAL 0x08 +#define HASH_LAST 0x01 +#define HASH_DONE 0x02 +#define HASH_FINAL 0x04 #define HASH_CTX_STS_IDLE 0x00 #define HASH_CTX_STS_PROCESSING 0x01