mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: [RFC 3/7] crypto: Add crypto_spawn_shash
Date: Thu, 11 Jun 2009 15:10:30 +0800	[thread overview]
Message-ID: <1244704230.5320.126.camel@yhuang-dev.sh.intel.com> (raw)

Needed to use shash in cryptd hash.

Signed-off-by: Huang Ying <ying.huang@intel.com>

---
 crypto/shash.c          |    6 ++++++
 include/crypto/algapi.h |    8 ++++++++
 2 files changed, 14 insertions(+)

--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -240,6 +240,14 @@ static inline struct cipher_alg *crypto_
 	return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
 }
 
+static inline struct crypto_shash *crypto_spawn_shash(struct crypto_spawn *spawn)
+{
+	u32 type = CRYPTO_ALG_TYPE_SHASH;
+	u32 mask = CRYPTO_ALG_TYPE_MASK;
+
+	return (struct crypto_shash *)(crypto_spawn_tfm(spawn, type, mask));
+}
+
 static inline struct crypto_hash *crypto_spawn_hash(struct crypto_spawn *spawn)
 {
 	u32 type = CRYPTO_ALG_TYPE_HASH;
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -408,6 +408,9 @@ static int crypto_init_shash_ops_compat(
 	return 0;
 }
 
+static int crypto_shash_init_tfm(struct crypto_tfm *tfm,
+				 const struct crypto_type *frontend);
+
 static int crypto_init_shash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 {
 	switch (mask & CRYPTO_ALG_TYPE_MASK) {
@@ -415,6 +418,9 @@ static int crypto_init_shash_ops(struct 
 		return crypto_init_shash_ops_compat(tfm);
 	case CRYPTO_ALG_TYPE_AHASH_MASK:
 		return crypto_init_shash_ops_async(tfm);
+	case CRYPTO_ALG_TYPE_MASK:
+		if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_SHASH)
+			return crypto_shash_init_tfm(tfm, &crypto_shash_type);
 	}
 
 	return -EINVAL;



                 reply	other threads:[~2009-06-11  7:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1244704230.5320.126.camel@yhuang-dev.sh.intel.com \
    --to=ying.huang@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®