diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2015-03-17 12:53:09 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-19 07:46:15 +0100 |
commit | 92138a77544da7ad7d880082e905c1ca8cd0c527 (patch) | |
tree | 4c839672611c982994d1bfd400b718739feb8540 /commands | |
parent | bf2cdf4084721de533ad0957f2ca3002cfa89cf1 (diff) | |
download | barebox-92138a77544da7ad7d880082e905c1ca8cd0c527.tar.gz barebox-92138a77544da7ad7d880082e905c1ca8cd0c527.tar.xz |
crypto: digest: digest_file_window/digest_file/digest_file_by_name drop key params
expect the key to be set before calling
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/digest.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/commands/digest.c b/commands/digest.c index 701e6a16fa..59c94ea2bf 100644 --- a/commands/digest.c +++ b/commands/digest.c @@ -52,11 +52,17 @@ static int do_digest(char *algorithm, int argc, char *argv[]) if (key) { char *tmp = asprintf("hmac(%s)", algorithm); d = digest_alloc(tmp); + BUG_ON(!d); + ret = digest_set_key(d, key, keylen); free(tmp); + if (ret) { + perror("set_key"); + goto err; + } } else { d = digest_alloc(algorithm); + BUG_ON(!d); } - BUG_ON(!d); if (argc < 1) return COMMAND_ERROR_USAGE; @@ -79,7 +85,6 @@ static int do_digest(char *algorithm, int argc, char *argv[]) } ret = digest_file_window(d, filename, - key, keylen, hash, start, size); if (ret < 0) { ret = 1; @@ -94,6 +99,7 @@ static int do_digest(char *algorithm, int argc, char *argv[]) argv++; } +err: free(hash); digest_free(d); |