From 299aab052ba37f58f1ec3c2bd142828199202559 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Mon, 20 Apr 2015 13:39:00 +0800 Subject: crypto: api - Add crypto_alg_extsize helper This patch adds a crypto_alg_extsize helper that can be used by algorithm types such as pcompress and shash. Signed-off-by: Herbert Xu --- crypto/algapi.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crypto/algapi.c') diff --git a/crypto/algapi.c b/crypto/algapi.c index d2627a3d..a60f6262 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -964,6 +964,12 @@ void crypto_xor(u8 *dst, const u8 *src, unsigned int size) } EXPORT_SYMBOL_GPL(crypto_xor); +unsigned int crypto_alg_extsize(struct crypto_alg *alg) +{ + return alg->cra_ctxsize; +} +EXPORT_SYMBOL_GPL(crypto_alg_extsize); + static int __init crypto_algapi_init(void) { crypto_init_proc(); -- cgit v1.2.3 From 74c02aa0ec083bdf55dc43b2a2e7da3f7dbfb7ad Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Wed, 22 Apr 2015 11:28:46 +0800 Subject: crypto: api - Move module sig ifdef into accessor function Currently we're hiding mod->sig_ok under an ifdef in open code. This patch adds a module_sig_ok accessor function and removes that ifdef. Signed-off-by: Herbert Xu Acked-by: Rusty Russell --- crypto/algapi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'crypto/algapi.c') diff --git a/crypto/algapi.c b/crypto/algapi.c index a60f6262..f835f439 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -43,12 +43,9 @@ static inline int crypto_set_driver_name(struct crypto_alg *alg) static inline void crypto_check_module_sig(struct module *mod) { -#ifdef CONFIG_CRYPTO_FIPS - if (fips_enabled && mod && !mod->sig_ok) + if (fips_enabled && mod && !module_sig_ok(mod)) panic("Module %s signature verification failed in FIPS mode\n", mod->name); -#endif - return; } static int crypto_check_alg(struct crypto_alg *alg) -- cgit v1.2.3 From b900dfff33bc0d7c637ba21f3de973f9f2eaa46c Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Wed, 22 Apr 2015 13:25:53 +0800 Subject: crypto: api - Include linux/fips.h All users of fips_enabled should include linux/fips.h directly instead of getting it through internal.h. Signed-off-by: Herbert Xu --- crypto/algapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'crypto/algapi.c') diff --git a/crypto/algapi.c b/crypto/algapi.c index f835f439..c63836f4 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include -- cgit v1.2.3 From bfd3ab4138d47f001e02641d1290c66def25daf4 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 23 Apr 2015 14:48:05 +0800 Subject: crypto: api - Fix build error when modules are disabled The commit 74c02aa0ec083bdf55dc43b2a2e7da3f7dbfb7ad ("crypto: api - Move module sig ifdef into accessor function") broke the build when modules are completely disabled because we directly dereference module->name. This patch fixes this by using the accessor function module_name. Reported-by: Fengguang Wu Signed-off-by: Herbert Xu --- crypto/algapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crypto/algapi.c') diff --git a/crypto/algapi.c b/crypto/algapi.c index c63836f4..3103e6a1 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -46,7 +46,7 @@ static inline void crypto_check_module_sig(struct module *mod) { if (fips_enabled && mod && !module_sig_ok(mod)) panic("Module %s signature verification failed in FIPS mode\n", - mod->name); + module_name(mod)); } static int crypto_check_alg(struct crypto_alg *alg) -- cgit v1.2.3 From af6bf41e2aefecffb7126b17b73f2c68ceba7d51 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Mon, 11 May 2015 17:47:39 +0800 Subject: crypto: api - Add crypto_grab_spawn primitive This patch adds a new primitive crypto_grab_spawn which is meant to replace crypto_init_spawn and crypto_init_spawn2. Under the new scheme the user no longer has to worry about reference counting the alg object before it is subsumed by the spawn. It is pretty much an exact copy of crypto_grab_aead. Prior to calling this function spawn->frontend and spawn->inst must have been set. Signed-off-by: Herbert Xu --- crypto/algapi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crypto/algapi.c') diff --git a/crypto/algapi.c b/crypto/algapi.c index 3103e6a1..abf100c0 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -612,6 +612,22 @@ out: } EXPORT_SYMBOL_GPL(crypto_init_spawn2); +int crypto_grab_spawn(struct crypto_spawn *spawn, const char *name, + u32 type, u32 mask) +{ + struct crypto_alg *alg; + int err; + + alg = crypto_find_alg(name, spawn->frontend, type, mask); + if (IS_ERR(alg)) + return PTR_ERR(alg); + + err = crypto_init_spawn(spawn, alg, spawn->inst, mask); + crypto_mod_put(alg); + return err; +} +EXPORT_SYMBOL_GPL(crypto_grab_spawn); + void crypto_drop_spawn(struct crypto_spawn *spawn) { if (!spawn->alg) -- cgit v1.2.3 From 6e2599bb2914d6feae845ff99f14032c4b0f7abf Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 28 May 2015 22:07:56 +0800 Subject: crypto: api - Include alignment in crypto_alg_extsize This patch ensures that the tfm context always has enough extra memory to ensure that it is aligned according to cra_alignment. Signed-off-by: Herbert Xu --- crypto/algapi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crypto/algapi.c') diff --git a/crypto/algapi.c b/crypto/algapi.c index abf100c0..3c079b7f 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -980,7 +980,8 @@ EXPORT_SYMBOL_GPL(crypto_xor); unsigned int crypto_alg_extsize(struct crypto_alg *alg) { - return alg->cra_ctxsize; + return alg->cra_ctxsize + + (alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1)); } EXPORT_SYMBOL_GPL(crypto_alg_extsize); -- cgit v1.2.3