From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/9] crypto: digest: digest_file_window/digest_file/digest_file_by_name drop key params
Date: Tue, 17 Mar 2015 12:53:09 +0100 [thread overview]
Message-ID: <1426593196-12509-2-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1426593196-12509-1-git-send-email-plagnioj@jcrosoft.com>
expect the key to be set before calling
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
commands/digest.c | 10 ++++++++--
crypto/digest.c | 10 ++--------
include/digest.h | 3 ---
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/commands/digest.c b/commands/digest.c
index 701e6a1..fa692eb 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_sey_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);
diff --git a/crypto/digest.c b/crypto/digest.c
index 2228ec7..208a204 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -116,7 +116,6 @@ void digest_free(struct digest *d)
EXPORT_SYMBOL_GPL(digest_free);
int digest_file_window(struct digest *d, const char *filename,
- const unsigned char *key, size_t keylen,
unsigned char *hash,
ulong start, ulong size)
{
@@ -125,9 +124,6 @@ int digest_file_window(struct digest *d, const char *filename,
unsigned char *buf;
int flags = 0;
- if (key)
- digest_set_key(d, key, keylen);
-
ret = digest_init(d);
if (ret)
return ret;
@@ -194,7 +190,6 @@ out:
EXPORT_SYMBOL_GPL(digest_file_window);
int digest_file(struct digest *d, const char *filename,
- const unsigned char *key, size_t keylen,
unsigned char *hash)
{
struct stat st;
@@ -205,12 +200,11 @@ int digest_file(struct digest *d, const char *filename,
if (ret < 0)
return ret;
- return digest_file_window(d, filename, key, keylen, hash, 0, st.st_size);
+ return digest_file_window(d, filename, hash, 0, st.st_size);
}
EXPORT_SYMBOL_GPL(digest_file);
int digest_file_by_name(const char *algo, const char *filename,
- const unsigned char *key, size_t keylen,
unsigned char *hash)
{
struct digest *d;
@@ -220,7 +214,7 @@ int digest_file_by_name(const char *algo, const char *filename,
if (!d)
return -EIO;
- ret = digest_file(d, filename, key, keylen, hash);
+ ret = digest_file(d, filename, hash);
digest_free(d);
return ret;
}
diff --git a/include/digest.h b/include/digest.h
index b890a7a..1c742f6 100644
--- a/include/digest.h
+++ b/include/digest.h
@@ -54,14 +54,11 @@ struct digest *digest_alloc(const char *name);
void digest_free(struct digest *d);
int digest_file_window(struct digest *d, const char *filename,
- const unsigned char *key, size_t keylen,
unsigned char *hash,
ulong start, ulong size);
int digest_file(struct digest *d, const char *filename,
- const unsigned char *key, size_t keylen,
unsigned char *hash);
int digest_file_by_name(const char *algo, const char *filename,
- const unsigned char *key, size_t keylen,
unsigned char *hash);
static inline int digest_init(struct digest *d)
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-03-17 11:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 11:49 [PATCH 0/9 v4] prepare for rsa support Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 1/9] crypto: digest: digest_file_window: check every digest_xxx return Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2015-03-17 11:53 ` [PATCH 3/9] digest: add verify callback Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 4/9] digest: add digest callback Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 5/9] crypto: hmac: use digest_digest and check the return of every digest_xxx Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 6/9] crypto: add pbkdf2 hmac key generator Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 7/9] command: allow runtime usage Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 8/9] command: rename digest.c to hashsum.c Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 11:53 ` [PATCH 9/9] command: add generic digest command Jean-Christophe PLAGNIOL-VILLARD
2015-03-17 12:54 ` [PATCH 0/9 v4] prepare for rsa support Jan Lübbe
2015-03-18 7:44 ` Sascha Hauer
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=1426593196-12509-2-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox