mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/7] digest: add verify callback
Date: Thu, 12 Mar 2015 18:41:49 +0100	[thread overview]
Message-ID: <20150312174149.GH24885@pengutronix.de> (raw)
In-Reply-To: <1426170146-31302-4-git-send-email-plagnioj@jcrosoft.com>

On Thu, Mar 12, 2015 at 03:22:23PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> this will allow to compare a md with the original one
> 
> When calling this do not call final
> 
> For RSA_SIGN verification final does not exist only verify
> as final will be for signing
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  crypto/digest.c   | 23 ++++++++++++++++++++++-
>  crypto/hmac.c     |  1 +
>  crypto/internal.h |  2 ++
>  crypto/md5.c      |  1 +
>  crypto/sha1.c     |  1 +
>  crypto/sha2.c     |  2 ++
>  crypto/sha4.c     |  2 ++
>  include/digest.h  |  6 ++++++
>  8 files changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/crypto/digest.c b/crypto/digest.c
> index c06089d..98c3607 100644
> --- a/crypto/digest.c
> +++ b/crypto/digest.c
> @@ -26,6 +26,8 @@
>  #include <module.h>
>  #include <linux/err.h>
>  
> +#include "internal.h"
> +
>  static LIST_HEAD(digests);
>  
>  static struct digest_algo *digest_algo_get_by_name(const char *name);
> @@ -37,9 +39,28 @@ static int dummy_init(struct digest *d)
>  
>  static void dummy_free(struct digest *d) {}
>  
> +int digest_generic_verity(struct digest *d, const unsigned char *md)

s/verity/verify/

> +{
> +	int ret;
> +	int len = digest_length(d);
> +	unsigned char *tmp;
> +
> +	tmp = xmalloc(sizeof(len));

sizeof(len) is not what you want.

> +
> +	ret = digest_final(d, tmp);
> +	if (ret)
> +		goto end;
> +
> +	ret = memcmp(md, tmp, len);

ret = ret ? -EINVAL : 0;

To consistently return an error code.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-03-12 17:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 14:19 [PATCH 0/7] prepare for rsa support Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:22 ` [PATCH 1/7] digest: fix and add missing copyright Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:22   ` [PATCH 2/7] digest: hmac: fix set_key prototype Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:22   ` [PATCH 3/7] crypto: add pbkdf2 hmac key generator Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:22   ` [PATCH 4/7] digest: add verify callback Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:55     ` Jan Lübbe
2015-03-12 17:41     ` Sascha Hauer [this message]
2015-03-12 18:56       ` Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:22   ` [PATCH 5/7] digest: allow algo to specify their length at runtime Jean-Christophe PLAGNIOL-VILLARD
2015-03-13  7:28     ` Sascha Hauer
2015-03-12 14:22   ` [PATCH 6/7] command: rename digest.c to hashsum.c Jean-Christophe PLAGNIOL-VILLARD
2015-03-12 14:22   ` [PATCH 7/7] command: add generic digest command Jean-Christophe PLAGNIOL-VILLARD
2015-03-13  7:26     ` Sascha Hauer
2015-03-13  8:32       ` Jean-Christophe PLAGNIOL-VILLARD
2015-03-13  8:42         ` [PATCH 1/1] command: allow runtime usage Jean-Christophe PLAGNIOL-VILLARD
2015-03-13 18:46           ` Robert Schwebel
2015-03-13  7:33   ` [PATCH 1/7] digest: fix and add missing copyright 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=20150312174149.GH24885@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox