crypto: ahash - optimize performance when wrapping shash
[linux-2.6-microblaze.git] / include / crypto / hash.h
index b00a4a3..c7bdbec 100644 (file)
@@ -250,16 +250,7 @@ struct shash_alg {
 #undef HASH_ALG_COMMON_STAT
 
 struct crypto_ahash {
-       int (*init)(struct ahash_request *req);
-       int (*update)(struct ahash_request *req);
-       int (*final)(struct ahash_request *req);
-       int (*finup)(struct ahash_request *req);
-       int (*digest)(struct ahash_request *req);
-       int (*export)(struct ahash_request *req, void *out);
-       int (*import)(struct ahash_request *req, const void *in);
-       int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
-                     unsigned int keylen);
-
+       bool using_shash; /* Underlying algorithm is shash, not ahash */
        unsigned int statesize;
        unsigned int reqsize;
        struct crypto_tfm base;
@@ -513,10 +504,7 @@ int crypto_ahash_digest(struct ahash_request *req);
  *
  * Return: 0 if the export was successful; < 0 if an error occurred
  */
-static inline int crypto_ahash_export(struct ahash_request *req, void *out)
-{
-       return crypto_ahash_reqtfm(req)->export(req, out);
-}
+int crypto_ahash_export(struct ahash_request *req, void *out);
 
 /**
  * crypto_ahash_import() - import message digest state
@@ -529,15 +517,7 @@ static inline int crypto_ahash_export(struct ahash_request *req, void *out)
  *
  * Return: 0 if the import was successful; < 0 if an error occurred
  */
-static inline int crypto_ahash_import(struct ahash_request *req, const void *in)
-{
-       struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
-
-       if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
-               return -ENOKEY;
-
-       return tfm->import(req, in);
-}
+int crypto_ahash_import(struct ahash_request *req, const void *in);
 
 /**
  * crypto_ahash_init() - (re)initialize message digest handle
@@ -550,36 +530,7 @@ static inline int crypto_ahash_import(struct ahash_request *req, const void *in)
  *
  * Return: see crypto_ahash_final()
  */
-static inline int crypto_ahash_init(struct ahash_request *req)
-{
-       struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
-
-       if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
-               return -ENOKEY;
-
-       return tfm->init(req);
-}
-
-static inline struct crypto_istat_hash *hash_get_stat(
-       struct hash_alg_common *alg)
-{
-#ifdef CONFIG_CRYPTO_STATS
-       return &alg->stat;
-#else
-       return NULL;
-#endif
-}
-
-static inline int crypto_hash_errstat(struct hash_alg_common *alg, int err)
-{
-       if (!IS_ENABLED(CONFIG_CRYPTO_STATS))
-               return err;
-
-       if (err && err != -EINPROGRESS && err != -EBUSY)
-               atomic64_inc(&hash_get_stat(alg)->err_cnt);
-
-       return err;
-}
+int crypto_ahash_init(struct ahash_request *req);
 
 /**
  * crypto_ahash_update() - add data to message digest for processing
@@ -592,16 +543,7 @@ static inline int crypto_hash_errstat(struct hash_alg_common *alg, int err)
  *
  * Return: see crypto_ahash_final()
  */
-static inline int crypto_ahash_update(struct ahash_request *req)
-{
-       struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
-       struct hash_alg_common *alg = crypto_hash_alg_common(tfm);
-
-       if (IS_ENABLED(CONFIG_CRYPTO_STATS))
-               atomic64_add(req->nbytes, &hash_get_stat(alg)->hash_tlen);
-
-       return crypto_hash_errstat(alg, tfm->update(req));
-}
+int crypto_ahash_update(struct ahash_request *req);
 
 /**
  * DOC: Asynchronous Hash Request Handle