Skip to content

Commit

Permalink
crypto: ahash - Remove old_ahash_alg
Browse files Browse the repository at this point in the history
Now that all ahash implementations have been converted to the new
ahash type, we can remove old_ahash_alg and its associated support.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
herbertx committed Jul 14, 2009
1 parent 4dc10c0 commit 500b3e3
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 53 deletions.
27 changes: 0 additions & 27 deletions crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,46 +175,19 @@ static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
return -ENOSYS;
}

static int crypto_init_ahash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
{
struct old_ahash_alg *alg = &tfm->__crt_alg->cra_ahash;
struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
struct ahash_alg *nalg = crypto_ahash_alg(crt);

if (alg->digestsize > PAGE_SIZE / 8)
return -EINVAL;

crt->init = alg->init;
crt->update = alg->update;
crt->final = alg->final;
crt->digest = alg->digest;
crt->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
crt->digestsize = alg->digestsize;

nalg->setkey = alg->setkey;
nalg->halg.digestsize = alg->digestsize;

return 0;
}

static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
struct ahash_alg *alg = crypto_ahash_alg(hash);
struct old_ahash_alg *oalg = crypto_old_ahash_alg(hash);

if (tfm->__crt_alg->cra_type != &crypto_ahash_type)
return crypto_init_shash_ops_async(tfm);

if (oalg->init)
return crypto_init_ahash_ops(tfm, 0, 0);

hash->init = alg->init;
hash->update = alg->update;
hash->final = alg->final;
hash->digest = alg->digest;
hash->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
hash->digestsize = alg->halg.digestsize;

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions crypto/shash.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
{
struct crypto_alg *calg = tfm->__crt_alg;
struct shash_alg *alg = __crypto_shash_alg(calg);
struct crypto_ahash *crt = __crypto_ahash_cast(tfm);
struct crypto_shash **ctx = crypto_tfm_ctx(tfm);
struct crypto_shash *shash;
Expand All @@ -293,7 +292,6 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
crt->digest = shash_async_digest;
crt->setkey = shash_async_setkey;

crt->digestsize = alg->digestsize;
crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);

return 0;
Expand Down
3 changes: 1 addition & 2 deletions include/crypto/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ struct crypto_ahash {
int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
unsigned int keylen);

unsigned int digestsize;
unsigned int reqsize;
struct crypto_tfm base;
};
Expand Down Expand Up @@ -137,7 +136,7 @@ static inline struct hash_alg_common *crypto_hash_alg_common(

static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm)
{
return tfm->digestsize;
return crypto_hash_alg_common(tfm)->digestsize;
}

static inline unsigned int crypto_ahash_statesize(struct crypto_ahash *tfm)
Expand Down
6 changes: 0 additions & 6 deletions include/crypto/internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ static inline struct ahash_alg *__crypto_ahash_alg(struct crypto_alg *alg)
halg);
}

static inline struct old_ahash_alg *crypto_old_ahash_alg(
struct crypto_ahash *tfm)
{
return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash;
}

static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm,
unsigned int reqsize)
{
Expand Down
16 changes: 0 additions & 16 deletions include/linux/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,10 @@ struct crypto_async_request;
struct crypto_aead;
struct crypto_blkcipher;
struct crypto_hash;
struct crypto_ahash;
struct crypto_rng;
struct crypto_tfm;
struct crypto_type;
struct aead_givcrypt_request;
struct ahash_request;
struct skcipher_givcrypt_request;

typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);
Expand Down Expand Up @@ -211,18 +209,6 @@ struct ablkcipher_alg {
unsigned int ivsize;
};

struct old_ahash_alg {
int (*init)(struct ahash_request *req);
int (*reinit)(struct ahash_request *req);
int (*update)(struct ahash_request *req);
int (*final)(struct ahash_request *req);
int (*digest)(struct ahash_request *req);
int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
unsigned int keylen);

unsigned int digestsize;
};

struct aead_alg {
int (*setkey)(struct crypto_aead *tfm, const u8 *key,
unsigned int keylen);
Expand Down Expand Up @@ -309,7 +295,6 @@ struct rng_alg {
#define cra_cipher cra_u.cipher
#define cra_digest cra_u.digest
#define cra_hash cra_u.hash
#define cra_ahash cra_u.ahash
#define cra_compress cra_u.compress
#define cra_rng cra_u.rng

Expand Down Expand Up @@ -337,7 +322,6 @@ struct crypto_alg {
struct cipher_alg cipher;
struct digest_alg digest;
struct hash_alg hash;
struct old_ahash_alg ahash;
struct compress_alg compress;
struct rng_alg rng;
} cra_u;
Expand Down

0 comments on commit 500b3e3

Please sign in to comment.