summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-crypt.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andy.shevchenko@gmail.com>2017-04-27 16:52:04 +0300
committerMike Snitzer <snitzer@redhat.com>2017-04-27 12:08:31 -0400
commite944e03e336f7ffa02aabc71291933d93dcd077c (patch)
tree1a57bf056e14efbaf698d246d18cc6ffcc146cc4 /drivers/md/dm-crypt.c
parent86f917adea2dc0ef440a248601e48154dc48e6d0 (diff)
downloadblackbird-op-linux-e944e03e336f7ffa02aabc71291933d93dcd077c.tar.gz
blackbird-op-linux-e944e03e336f7ffa02aabc71291933d93dcd077c.zip
dm crypt: replace custom implementation of hex2bin()
There is no need to have a duplication of the generic library, i.e. hex2bin(). Replace the open coded variant. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Tested-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-crypt.c')
-rw-r--r--drivers/md/dm-crypt.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index e2de5715d528..24f3b9fdeeb6 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1814,30 +1814,6 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io)
queue_work(cc->crypt_queue, &io->work);
}
-/*
- * Decode key from its hex representation
- */
-static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
-{
- char buffer[3];
- unsigned int i;
-
- buffer[2] = '\0';
-
- for (i = 0; i < size; i++) {
- buffer[0] = *hex++;
- buffer[1] = *hex++;
-
- if (kstrtou8(buffer, 16, &key[i]))
- return -EINVAL;
- }
-
- if (*hex != '\0')
- return -EINVAL;
-
- return 0;
-}
-
static void crypt_free_tfms_aead(struct crypt_config *cc)
{
if (!cc->cipher_tfm.tfms_aead)
@@ -2136,7 +2112,8 @@ static int crypt_set_key(struct crypt_config *cc, char *key)
kzfree(cc->key_string);
cc->key_string = NULL;
- if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
+ /* Decode key from its hex representation. */
+ if (cc->key_size && hex2bin(cc->key, key, cc->key_size) < 0)
goto out;
r = crypt_setkey(cc);
OpenPOWER on IntegriCloud