aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/api.c15
-rw-r--r--crypto/internal.h6
-rw-r--r--crypto/shash.c18
3 files changed, 16 insertions, 23 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 56b6e0e66311..22385cac90bb 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -453,8 +453,8 @@ err:
453} 453}
454EXPORT_SYMBOL_GPL(crypto_alloc_base); 454EXPORT_SYMBOL_GPL(crypto_alloc_base);
455 455
456struct crypto_tfm *crypto_create_tfm(struct crypto_alg *alg, 456void *crypto_create_tfm(struct crypto_alg *alg,
457 const struct crypto_type *frontend) 457 const struct crypto_type *frontend)
458{ 458{
459 char *mem; 459 char *mem;
460 struct crypto_tfm *tfm = NULL; 460 struct crypto_tfm *tfm = NULL;
@@ -488,9 +488,9 @@ out_free_tfm:
488 crypto_shoot_alg(alg); 488 crypto_shoot_alg(alg);
489 kfree(mem); 489 kfree(mem);
490out_err: 490out_err:
491 tfm = ERR_PTR(err); 491 mem = ERR_PTR(err);
492out: 492out:
493 return tfm; 493 return mem;
494} 494}
495EXPORT_SYMBOL_GPL(crypto_create_tfm); 495EXPORT_SYMBOL_GPL(crypto_create_tfm);
496 496
@@ -514,12 +514,11 @@ EXPORT_SYMBOL_GPL(crypto_create_tfm);
514 * 514 *
515 * In case of error the return value is an error pointer. 515 * In case of error the return value is an error pointer.
516 */ 516 */
517struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, 517void *crypto_alloc_tfm(const char *alg_name,
518 const struct crypto_type *frontend, 518 const struct crypto_type *frontend, u32 type, u32 mask)
519 u32 type, u32 mask)
520{ 519{
521 struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); 520 struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask);
522 struct crypto_tfm *tfm; 521 void *tfm;
523 int err; 522 int err;
524 523
525 type &= frontend->maskclear; 524 type &= frontend->maskclear;
diff --git a/crypto/internal.h b/crypto/internal.h
index 3c19a27a7563..fc76e1f37fc3 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -109,8 +109,10 @@ void crypto_alg_tested(const char *name, int err);
109void crypto_shoot_alg(struct crypto_alg *alg); 109void crypto_shoot_alg(struct crypto_alg *alg);
110struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, 110struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
111 u32 mask); 111 u32 mask);
112struct crypto_tfm *crypto_create_tfm(struct crypto_alg *alg, 112void *crypto_create_tfm(struct crypto_alg *alg,
113 const struct crypto_type *frontend); 113 const struct crypto_type *frontend);
114void *crypto_alloc_tfm(const char *alg_name,
115 const struct crypto_type *frontend, u32 type, u32 mask);
114 116
115int crypto_register_instance(struct crypto_template *tmpl, 117int crypto_register_instance(struct crypto_template *tmpl,
116 struct crypto_instance *inst); 118 struct crypto_instance *inst);
diff --git a/crypto/shash.c b/crypto/shash.c
index 13a0dc150a4d..7a659733f94a 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -18,15 +18,10 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20 20
21static const struct crypto_type crypto_shash_type;
22
23static inline struct crypto_shash *__crypto_shash_cast(struct crypto_tfm *tfm)
24{
25 return container_of(tfm, struct crypto_shash, base);
26}
27
28#include "internal.h" 21#include "internal.h"
29 22
23static const struct crypto_type crypto_shash_type;
24
30static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key, 25static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
31 unsigned int keylen) 26 unsigned int keylen)
32{ 27{
@@ -282,8 +277,7 @@ static int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
282 if (!crypto_mod_get(calg)) 277 if (!crypto_mod_get(calg))
283 return -EAGAIN; 278 return -EAGAIN;
284 279
285 shash = __crypto_shash_cast(crypto_create_tfm( 280 shash = crypto_create_tfm(calg, &crypto_shash_type);
286 calg, &crypto_shash_type));
287 if (IS_ERR(shash)) { 281 if (IS_ERR(shash)) {
288 crypto_mod_put(calg); 282 crypto_mod_put(calg);
289 return PTR_ERR(shash); 283 return PTR_ERR(shash);
@@ -391,8 +385,7 @@ static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm)
391 if (!crypto_mod_get(calg)) 385 if (!crypto_mod_get(calg))
392 return -EAGAIN; 386 return -EAGAIN;
393 387
394 shash = __crypto_shash_cast(crypto_create_tfm( 388 shash = crypto_create_tfm(calg, &crypto_shash_type);
395 calg, &crypto_shash_type));
396 if (IS_ERR(shash)) { 389 if (IS_ERR(shash)) {
397 crypto_mod_put(calg); 390 crypto_mod_put(calg);
398 return PTR_ERR(shash); 391 return PTR_ERR(shash);
@@ -480,8 +473,7 @@ static const struct crypto_type crypto_shash_type = {
480struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type, 473struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
481 u32 mask) 474 u32 mask)
482{ 475{
483 return __crypto_shash_cast( 476 return crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask);
484 crypto_alloc_tfm(alg_name, &crypto_shash_type, type, mask));
485} 477}
486EXPORT_SYMBOL_GPL(crypto_alloc_shash); 478EXPORT_SYMBOL_GPL(crypto_alloc_shash);
487 479