Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157946
b: refs/heads/master
c: 97eedce
h: refs/heads/master
v: v3
  • Loading branch information
Herbert Xu committed Jul 8, 2009
1 parent af2ee42 commit a9729f5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2e4fddd8e420e8f531a34e7a97f9cdb851a6ad13
refs/heads/master: 97eedce1a64a57648ac5e39f03825528c47ba72e
55 changes: 52 additions & 3 deletions trunk/crypto/algapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,23 @@ int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
}
EXPORT_SYMBOL_GPL(crypto_init_spawn);

int crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg,
struct crypto_instance *inst,
const struct crypto_type *frontend)
{
int err = -EINVAL;

if (frontend && (alg->cra_flags ^ frontend->type) & frontend->maskset)
goto out;

spawn->frontend = frontend;
err = crypto_init_spawn(spawn, alg, inst, frontend->maskset);

out:
return err;
}
EXPORT_SYMBOL_GPL(crypto_init_spawn2);

void crypto_drop_spawn(struct crypto_spawn *spawn)
{
down_write(&crypto_alg_sem);
Expand All @@ -496,12 +513,10 @@ void crypto_drop_spawn(struct crypto_spawn *spawn)
}
EXPORT_SYMBOL_GPL(crypto_drop_spawn);

struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
u32 mask)
static struct crypto_alg *crypto_spawn_alg(struct crypto_spawn *spawn)
{
struct crypto_alg *alg;
struct crypto_alg *alg2;
struct crypto_tfm *tfm;

down_read(&crypto_alg_sem);
alg = spawn->alg;
Expand All @@ -516,6 +531,19 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
return ERR_PTR(-EAGAIN);
}

return alg;
}

struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
u32 mask)
{
struct crypto_alg *alg;
struct crypto_tfm *tfm;

alg = crypto_spawn_alg(spawn);
if (IS_ERR(alg))
return ERR_CAST(alg);

tfm = ERR_PTR(-EINVAL);
if (unlikely((alg->cra_flags ^ type) & mask))
goto out_put_alg;
Expand All @@ -532,6 +560,27 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
}
EXPORT_SYMBOL_GPL(crypto_spawn_tfm);

void *crypto_spawn_tfm2(struct crypto_spawn *spawn)
{
struct crypto_alg *alg;
struct crypto_tfm *tfm;

alg = crypto_spawn_alg(spawn);
if (IS_ERR(alg))
return ERR_CAST(alg);

tfm = crypto_create_tfm(alg, spawn->frontend);
if (IS_ERR(tfm))
goto out_put_alg;

return tfm;

out_put_alg:
crypto_mod_put(alg);
return tfm;
}
EXPORT_SYMBOL_GPL(crypto_spawn_tfm2);

int crypto_register_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&crypto_chain, nb);
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/crypto/algapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct crypto_spawn {
struct list_head list;
struct crypto_alg *alg;
struct crypto_instance *inst;
const struct crypto_type *frontend;
u32 mask;
};

Expand Down Expand Up @@ -117,9 +118,14 @@ struct crypto_template *crypto_lookup_template(const char *name);

int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
struct crypto_instance *inst, u32 mask);
int crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg,
struct crypto_instance *inst,
const struct crypto_type *frontend);

void crypto_drop_spawn(struct crypto_spawn *spawn);
struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
u32 mask);
void *crypto_spawn_tfm2(struct crypto_spawn *spawn);

static inline void crypto_set_spawn(struct crypto_spawn *spawn,
struct crypto_instance *inst)
Expand Down

0 comments on commit a9729f5

Please sign in to comment.