diff mbox

[3/4] crypto: akcipher: add crypto_akcipher_type methods needed by templates.

Message ID 1447412495-4370-3-git-send-email-andrew.zaborowski@intel.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show

Commit Message

Andrew Zaborowski Nov. 13, 2015, 11:01 a.m. UTC
Add two dummy methods that are required by the crypto API internals:
.ctxsize and .init
(just because the framework calls them without checking if they were
provided).  They're only required by the complicated code path needed to
instantiate a template algorithm.  Also expose crypto_akcipher_type like
other crypto types are exposed to be used from outside modules.

Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>
---
 crypto/akcipher.c       | 16 +++++++++++++++-
 include/crypto/algapi.h |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Herbert Xu Nov. 17, 2015, 1:42 p.m. UTC | #1
Andrew Zaborowski <andrew.zaborowski@intel.com> wrote:
> Add two dummy methods that are required by the crypto API internals:
> .ctxsize and .init
> (just because the framework calls them without checking if they were
> provided).  They're only required by the complicated code path needed to
> instantiate a template algorithm.  Also expose crypto_akcipher_type like
> other crypto types are exposed to be used from outside modules.
> 
> Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>

Nack.  They are only required if you use obsolete methods of creating
a tfm.
Andrew Zaborowski Nov. 17, 2015, 9:47 p.m. UTC | #2
Hi Herbert,

On 17 November 2015 at 14:42, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> Andrew Zaborowski <andrew.zaborowski@intel.com> wrote:
>> Add two dummy methods that are required by the crypto API internals:
>> .ctxsize and .init
>> (just because the framework calls them without checking if they were
>> provided).  They're only required by the complicated code path needed to
>> instantiate a template algorithm.  Also expose crypto_akcipher_type like
>> other crypto types are exposed to be used from outside modules.
>>
>> Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>
>
> Nack.  They are only required if you use obsolete methods of creating
> a tfm.

Will you then accept a patch to add a cra_u.akcipher to struct
crypto_alg?  I see shash/ahash use one method to create instances and
blkcipher use another.  I have no way to know which of them is
"obsolete" (possibly both) and that was the reason for sending an RFC
first.

Best regards
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Herbert Xu Nov. 18, 2015, 12:05 a.m. UTC | #3
On Tue, Nov 17, 2015 at 10:47:11PM +0100, Andrzej Zaborowski wrote:
>
> Will you then accept a patch to add a cra_u.akcipher to struct
> crypto_alg?  I see shash/ahash use one method to create instances and

No as struct crypto_alg is obsolete.

> blkcipher use another.  I have no way to know which of them is
> "obsolete" (possibly both) and that was the reason for sending an RFC
> first.

AEAD is the best example to use for templates.  It was recently
converted.

Cheers,
diff mbox

Patch

diff --git a/crypto/akcipher.c b/crypto/akcipher.c
index 120ec04..6ef7f99 100644
--- a/crypto/akcipher.c
+++ b/crypto/akcipher.c
@@ -53,6 +53,11 @@  static void crypto_akcipher_show(struct seq_file *m, struct crypto_alg *alg)
 	seq_puts(m, "type         : akcipher\n");
 }
 
+static int crypto_akcipher_init(struct crypto_tfm *tfm, u32 type, u32 mask)
+{
+	return 0;
+}
+
 static void crypto_akcipher_exit_tfm(struct crypto_tfm *tfm)
 {
 	struct crypto_akcipher *akcipher = __crypto_akcipher_tfm(tfm);
@@ -75,8 +80,16 @@  static int crypto_akcipher_init_tfm(struct crypto_tfm *tfm)
 	return 0;
 }
 
-static const struct crypto_type crypto_akcipher_type = {
+static unsigned int crypto_akcipher_ctxsize(struct crypto_alg *alg, u32 type,
+					    u32 mask)
+{
+	return alg->cra_ctxsize;
+}
+
+const struct crypto_type crypto_akcipher_type = {
+	.ctxsize = crypto_akcipher_ctxsize,
 	.extsize = crypto_alg_extsize,
+	.init = crypto_akcipher_init,
 	.init_tfm = crypto_akcipher_init_tfm,
 #ifdef CONFIG_PROC_FS
 	.show = crypto_akcipher_show,
@@ -87,6 +100,7 @@  static const struct crypto_type crypto_akcipher_type = {
 	.type = CRYPTO_ALG_TYPE_AKCIPHER,
 	.tfmsize = offsetof(struct crypto_akcipher, base),
 };
+EXPORT_SYMBOL_GPL(crypto_akcipher_type);
 
 struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
 					      u32 mask)
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index c9fe145..1089f20 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -130,6 +130,7 @@  struct ablkcipher_walk {
 
 extern const struct crypto_type crypto_ablkcipher_type;
 extern const struct crypto_type crypto_blkcipher_type;
+extern const struct crypto_type crypto_akcipher_type;
 
 void crypto_mod_put(struct crypto_alg *alg);