linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Cope <alexcope@google.com>
To: linux-crypto@vger.kernel.org
Cc: mhalcrow@google.com, edknapp@google.com,
	Alex Cope <alexcope@google.com>,
	Eric Biggers <ebiggers@google.com>
Subject: [RFC][PATCH 4/7] crypto: shash - Add crypto_grab_shash() and crypto_spawn_shash_alg()
Date: Mon, 14 Nov 2016 13:01:15 -0800	[thread overview]
Message-ID: <1479157277-10251-5-git-send-email-alexcope@google.com> (raw)
In-Reply-To: <1479157277-10251-1-git-send-email-alexcope@google.com>

Analogous to crypto_grab_skcipher() and crypto_spawn_skcipher_alg(),
these are useful for algorithms that need to use a shash sub-algorithm,
possibly in addition to other sub-algorithms.

Signed-off-by: Alex Cope <alexcope@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 crypto/shash.c                 | 8 ++++++++
 include/crypto/internal/hash.h | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/crypto/shash.c b/crypto/shash.c
index a051541..55a5535 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -536,6 +536,14 @@ void shash_free_instance(struct crypto_instance *inst)
 }
 EXPORT_SYMBOL_GPL(shash_free_instance);
 
+int crypto_grab_shash(struct crypto_shash_spawn *spawn,
+		      const char *name, u32 type, u32 mask)
+{
+	spawn->base.frontend = &crypto_shash_type;
+	return crypto_grab_spawn(&spawn->base, name, type, mask);
+}
+EXPORT_SYMBOL_GPL(crypto_grab_shash);
+
 int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
 			    struct shash_alg *alg,
 			    struct crypto_instance *inst)
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index 1d4f365..54e4425 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -99,6 +99,8 @@ int shash_register_instance(struct crypto_template *tmpl,
 			    struct shash_instance *inst);
 void shash_free_instance(struct crypto_instance *inst);
 
+int crypto_grab_shash(struct crypto_shash_spawn *spawn,
+		      const char *name, u32 type, u32 mask);
 int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
 			    struct shash_alg *alg,
 			    struct crypto_instance *inst);
@@ -108,6 +110,12 @@ static inline void crypto_drop_shash(struct crypto_shash_spawn *spawn)
 	crypto_drop_spawn(&spawn->base);
 }
 
+static inline struct shash_alg *crypto_spawn_shash_alg(
+	struct crypto_shash_spawn *spawn)
+{
+	return container_of(spawn->base.alg, struct shash_alg, base);
+}
+
 struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
 
 int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
-- 
2.8.0.rc3.226.g39d4020

  parent reply	other threads:[~2016-11-14 21:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 21:01 [RFC][PATCH 0/7] crypto: Adding Hash-Encrypt-Hash(HEH) Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 1/7] crypto: skcipher adding skciper_walk_virt_init Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 2/7] crypto: gf128mul - Refactor gf128 overflow macros Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 3/7] crypto: gf128mul - Add ble multiplication functions Alex Cope
2016-11-14 21:01 ` Alex Cope [this message]
2016-11-14 21:01 ` [RFC][PATCH 5/7] crypto: heh - Add Hash Encrypt Hash(HEH) algorithm Alex Cope
2016-11-14 21:01 ` [RFC][PATCH 6/7] crypto: testmgr - Add test vectors for HEH Alex Cope

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=1479157277-10251-5-git-send-email-alexcope@google.com \
    --to=alexcope@google.com \
    --cc=ebiggers@google.com \
    --cc=edknapp@google.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mhalcrow@google.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;
as well as URLs for NNTP newsgroup(s).