]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: x86/nhpoly1305 - implement ->digest
authorEric Biggers <ebiggers@google.com>
Tue, 10 Oct 2023 05:59:46 +0000 (22:59 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Oct 2023 05:39:25 +0000 (13:39 +0800)
Implement the ->digest method to improve performance on single-page
messages by reducing the number of indirect calls.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/nhpoly1305-avx2-glue.c
arch/x86/crypto/nhpoly1305-sse2-glue.c

index 46b036204ed918dc047e51f5448941a546484418..c3a872f4d6a773305aca2d06d3e5b9f731d2bf84 100644 (file)
@@ -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),
 };
index 4a4970d751076826a5ae52293c00ce1c128de52d..a268a8439a5c98a1fa460ec1043cd55d68d02c6c 100644 (file)
@@ -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),
 };