Commit 796b06f5 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu
Browse files

crypto: x86/nhpoly1305 - implement ->digest



Implement the ->digest method to improve performance on single-page
messages by reducing the number of indirect calls.

Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent ddefde7b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -34,6 +34,14 @@ static int nhpoly1305_avx2_update(struct shash_desc *desc,
	return 0;
}

static int nhpoly1305_avx2_digest(struct shash_desc *desc,
				  const u8 *src, unsigned int srclen, u8 *out)
{
	return crypto_nhpoly1305_init(desc) ?:
	       nhpoly1305_avx2_update(desc, src, srclen) ?:
	       crypto_nhpoly1305_final(desc, out);
}

static struct shash_alg nhpoly1305_alg = {
	.base.cra_name		= "nhpoly1305",
	.base.cra_driver_name	= "nhpoly1305-avx2",
@@ -44,6 +52,7 @@ static struct shash_alg nhpoly1305_alg = {
	.init			= crypto_nhpoly1305_init,
	.update			= nhpoly1305_avx2_update,
	.final			= crypto_nhpoly1305_final,
	.digest			= nhpoly1305_avx2_digest,
	.setkey			= crypto_nhpoly1305_setkey,
	.descsize		= sizeof(struct nhpoly1305_state),
};
+9 −0
Original line number Diff line number Diff line
@@ -34,6 +34,14 @@ static int nhpoly1305_sse2_update(struct shash_desc *desc,
	return 0;
}

static int nhpoly1305_sse2_digest(struct shash_desc *desc,
				  const u8 *src, unsigned int srclen, u8 *out)
{
	return crypto_nhpoly1305_init(desc) ?:
	       nhpoly1305_sse2_update(desc, src, srclen) ?:
	       crypto_nhpoly1305_final(desc, out);
}

static struct shash_alg nhpoly1305_alg = {
	.base.cra_name		= "nhpoly1305",
	.base.cra_driver_name	= "nhpoly1305-sse2",
@@ -44,6 +52,7 @@ static struct shash_alg nhpoly1305_alg = {
	.init			= crypto_nhpoly1305_init,
	.update			= nhpoly1305_sse2_update,
	.final			= crypto_nhpoly1305_final,
	.digest			= nhpoly1305_sse2_digest,
	.setkey			= crypto_nhpoly1305_setkey,
	.descsize		= sizeof(struct nhpoly1305_state),
};