All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Subject: [RFC] [PATCH 2/3] crypto: ahash - add crypto_ahash_finup
Date: Tue, 7 Jul 2009 09:25:57 +0200	[thread overview]
Message-ID: <20090707072557.GE20288@secunet.com> (raw)
In-Reply-To: <20090707072343.GC20288@secunet.com>

This patch adds the finup method for ahash. This can be used to
do the last hash update and the hash final together.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 crypto/ahash.c         |    1 +
 crypto/shash.c         |   15 +++++++++++++++
 include/crypto/hash.h  |    6 ++++++
 include/linux/crypto.h |    2 ++
 4 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/crypto/ahash.c b/crypto/ahash.c
index f347637..c2fbc6d 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -200,6 +200,7 @@ static int crypto_init_ahash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 	crt->init = alg->init;
 	crt->update = alg->update;
 	crt->final  = alg->final;
+	crt->finup  = alg->finup; 
 	crt->digest = alg->digest;
 	crt->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
 	crt->digestsize = alg->digestsize;
diff --git a/crypto/shash.c b/crypto/shash.c
index 2ccc8b0..3f494fe 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -224,6 +224,20 @@ static int shash_async_final(struct ahash_request *req)
 	return crypto_shash_final(ahash_request_ctx(req), req->result);
 }
 
+static int shash_async_finup(struct ahash_request *req)
+{
+	int err;
+
+	err = shash_async_update(req);
+	if (err)
+		goto out;
+
+	err = shash_async_final(req);
+
+out:
+	return err;
+}
+
 static int shash_async_digest(struct ahash_request *req)
 {
 	struct scatterlist *sg = req->src;
@@ -292,6 +306,7 @@ static int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
 	crt->init = shash_async_init;
 	crt->update = shash_async_update;
 	crt->final  = shash_async_final;
+	crt->finup  = shash_async_finup;
 	crt->digest = shash_async_digest;
 	crt->setkey = shash_async_setkey;
 
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index bd473a0..7c36733 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -177,6 +177,12 @@ static inline int crypto_ahash_final(struct ahash_request *req)
 	return crt->final(req);
 }
 
+static inline int crypto_ahash_finup(struct ahash_request *req)
+{
+	struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req));
+	return crt->finup(req);
+}
+
 static inline void ahash_request_complete(struct ahash_request *req, int err)
 {
 	req->base.complete(&req->base, err);
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index ec29fa2..ab3e4b8 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -225,6 +225,7 @@ struct ahash_alg {
 	int (*reinit)(struct ahash_request *req);
 	int (*update)(struct ahash_request *req);
 	int (*final)(struct ahash_request *req);
+	int (*finup)(struct ahash_request *req);
 	int (*digest)(struct ahash_request *req);
 	int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
 			unsigned int keylen);
@@ -437,6 +438,7 @@ struct ahash_tfm {
 	int (*init)(struct ahash_request *req);
 	int (*update)(struct ahash_request *req);
 	int (*final)(struct ahash_request *req);
+	int (*finup)(struct ahash_request *req);
 	int (*digest)(struct ahash_request *req);
 	int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
 			unsigned int keylen);
-- 
1.5.4.2


  parent reply	other threads:[~2009-07-07  7:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  7:23 [RFC] [PATCH 0/3] convert hmac to ahash Steffen Klassert
2009-07-07  7:24 ` [RFC] [PATCH 1/3] crypto: ahash - Add some helper functions Steffen Klassert
2009-07-07  7:25 ` Steffen Klassert [this message]
2009-07-07  7:26 ` [RFC] [PATCH 3/3] crypto: hmac - convert to ahash Steffen Klassert
2009-07-09  4:48   ` Herbert Xu

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=20090707072557.GE20288@secunet.com \
    --to=steffen.klassert@secunet.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.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 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.