mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
crypto: sha512-generic - Use API partial block handling
Use the Crypto API partial block handling. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
561aab1104
commit
216623af53
|
|
@ -6,16 +6,10 @@
|
|||
* Copyright (c) 2003 Kyle McMartin <kyle@debian.org>
|
||||
*/
|
||||
#include <crypto/internal/hash.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/types.h>
|
||||
#include <crypto/sha2.h>
|
||||
#include <crypto/sha512_base.h>
|
||||
#include <linux/percpu.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/unaligned.h>
|
||||
|
||||
const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE] = {
|
||||
|
|
@ -148,45 +142,39 @@ sha512_transform(u64 *state, const u8 *input)
|
|||
void sha512_generic_block_fn(struct sha512_state *sst, u8 const *src,
|
||||
int blocks)
|
||||
{
|
||||
while (blocks--) {
|
||||
do {
|
||||
sha512_transform(sst->state, src);
|
||||
src += SHA512_BLOCK_SIZE;
|
||||
}
|
||||
} while (--blocks);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sha512_generic_block_fn);
|
||||
|
||||
int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len)
|
||||
static int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len)
|
||||
{
|
||||
return sha512_base_do_update(desc, data, len, sha512_generic_block_fn);
|
||||
return sha512_base_do_update_blocks(desc, data, len,
|
||||
sha512_generic_block_fn);
|
||||
}
|
||||
EXPORT_SYMBOL(crypto_sha512_update);
|
||||
|
||||
static int sha512_final(struct shash_desc *desc, u8 *hash)
|
||||
static int crypto_sha512_finup(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len, u8 *hash)
|
||||
{
|
||||
sha512_base_do_finalize(desc, sha512_generic_block_fn);
|
||||
sha512_base_do_finup(desc, data, len, sha512_generic_block_fn);
|
||||
return sha512_base_finish(desc, hash);
|
||||
}
|
||||
|
||||
int crypto_sha512_finup(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len, u8 *hash)
|
||||
{
|
||||
sha512_base_do_update(desc, data, len, sha512_generic_block_fn);
|
||||
return sha512_final(desc, hash);
|
||||
}
|
||||
EXPORT_SYMBOL(crypto_sha512_finup);
|
||||
|
||||
static struct shash_alg sha512_algs[2] = { {
|
||||
.digestsize = SHA512_DIGEST_SIZE,
|
||||
.init = sha512_base_init,
|
||||
.update = crypto_sha512_update,
|
||||
.final = sha512_final,
|
||||
.finup = crypto_sha512_finup,
|
||||
.descsize = sizeof(struct sha512_state),
|
||||
.descsize = SHA512_STATE_SIZE,
|
||||
.base = {
|
||||
.cra_name = "sha512",
|
||||
.cra_driver_name = "sha512-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_AHASH_ALG_BLOCK_ONLY |
|
||||
CRYPTO_AHASH_ALG_FINUP_MAX,
|
||||
.cra_blocksize = SHA512_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
|
|
@ -194,13 +182,14 @@ static struct shash_alg sha512_algs[2] = { {
|
|||
.digestsize = SHA384_DIGEST_SIZE,
|
||||
.init = sha384_base_init,
|
||||
.update = crypto_sha512_update,
|
||||
.final = sha512_final,
|
||||
.finup = crypto_sha512_finup,
|
||||
.descsize = sizeof(struct sha512_state),
|
||||
.descsize = SHA512_STATE_SIZE,
|
||||
.base = {
|
||||
.cra_name = "sha384",
|
||||
.cra_driver_name = "sha384-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_AHASH_ALG_BLOCK_ONLY |
|
||||
CRYPTO_AHASH_ALG_FINUP_MAX,
|
||||
.cra_blocksize = SHA384_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,14 +82,6 @@ struct sha512_state {
|
|||
u8 buf[SHA512_BLOCK_SIZE];
|
||||
};
|
||||
|
||||
struct shash_desc;
|
||||
|
||||
extern int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len);
|
||||
|
||||
extern int crypto_sha512_finup(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len, u8 *hash);
|
||||
|
||||
/*
|
||||
* Stand-alone implementation of the SHA256 algorithm. It is designed to
|
||||
* have as little dependencies as possible so it can be used in the
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user