mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-25 00:52:45 -04:00
crypto: ahash - Handle partial blocks in API
Provide an option to handle the partial blocks in the ahash API. Almost every hash algorithm has a block size and are only able to hash partial blocks on finalisation. As a first step disable virtual address support for algorithms with state sizes larger than HASH_MAX_STATESIZE. This is OK as virtual addresses are currently only used on synchronous fallbacks. This means ahash_do_req_chain only needs to handle synchronous fallbacks, removing the complexities of saving the request state. Also move the saved request state into the ahash_request object as nesting is no longer possible. Add a scatterlist to ahash_request to store the partial block. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
#ifndef _CRYPTO_HASH_H
|
||||
#define _CRYPTO_HASH_H
|
||||
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
@@ -65,6 +65,10 @@ struct ahash_request {
|
||||
};
|
||||
u8 *result;
|
||||
|
||||
struct scatterlist sg_head[2];
|
||||
crypto_completion_t saved_complete;
|
||||
void *saved_data;
|
||||
|
||||
void *__ctx[] CRYPTO_MINALIGN_ATTR;
|
||||
};
|
||||
|
||||
@@ -488,7 +492,11 @@ int crypto_ahash_finup(struct ahash_request *req);
|
||||
* -EBUSY if queue is full and request should be resubmitted later;
|
||||
* other < 0 if an error occurred
|
||||
*/
|
||||
int crypto_ahash_final(struct ahash_request *req);
|
||||
static inline int crypto_ahash_final(struct ahash_request *req)
|
||||
{
|
||||
req->nbytes = 0;
|
||||
return crypto_ahash_finup(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_ahash_digest() - calculate message digest for a buffer
|
||||
|
||||
Reference in New Issue
Block a user