All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: dm-crypt@saout.de
Cc: gmazyland@gmail.com, Richard Weinberger <richard@nod.at>
Subject: [dm-crypt] [PATCH] crypt_plain_hash: Remove dead code
Date: Fri, 18 Jan 2019 15:14:51 +0100	[thread overview]
Message-ID: <20190118141451.12000-1-richard@nod.at> (raw)

Since commit 31a4d552a2d9 ("Support keyfile offset and keyfile size option even for plain volumes.")
params.hash is set to NULL when the requested hash function is
"plain". Therfore the code to handle the "plain" hasher in
crypt_plain_hash() is no longer reachable and can be removed.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 lib/crypt_plain.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lib/crypt_plain.c b/lib/crypt_plain.c
index f89c7747649d..66339bdbf2c9 100644
--- a/lib/crypt_plain.c
+++ b/lib/crypt_plain.c
@@ -99,17 +99,7 @@ int crypt_plain_hash(struct crypt_device *cd,
 		pad_size = 0;
 	}
 
-	/* No hash, copy passphrase directly */
-	if (!strcmp(hash_name_buf, "plain")) {
-		if (passphrase_size < hash_size) {
-			log_dbg(cd, "Too short plain passphrase.");
-			return -EINVAL;
-		}
-		memcpy(key, passphrase, hash_size);
-		r = 0;
-	} else
-		r = hash(hash_name_buf, hash_size, key, passphrase_size, passphrase);
-
+	r = hash(hash_name_buf, hash_size, key, passphrase_size, passphrase);
 	if (r == 0 && pad_size)
 		memset(key + hash_size, 0, pad_size);
 
-- 
2.20.1

             reply	other threads:[~2019-01-18 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 14:14 Richard Weinberger [this message]
2019-01-20  9:33 ` [dm-crypt] [PATCH] crypt_plain_hash: Remove dead code Milan Broz
2019-01-20  9:53   ` Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190118141451.12000-1-richard@nod.at \
    --to=richard@nod.at \
    --cc=dm-crypt@saout.de \
    --cc=gmazyland@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.