All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Cc: alsa-devel@alsa-project.org, linux-efi@vger.kernel.org,
	Hans de Goede <hdegoede@redhat.com>,
	Mat Martineau <mathew.j.martineau@linux.intel.com>,
	Guenter Roeck <groeck@chromium.org>,
	Tzung-Bi Shih <tzungbi@google.com>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Matthieu Baerts <matthieu.baerts@tessares.net>,
	mptcp@lists.01.org, Ard Biesheuvel <ardb@kernel.org>,
	Cheng-Yi Chiang <cychiang@chromium.org>
Subject: [PATCH 1/4] crypto: lib/sha256 - add sha256() function
Date: Tue,  7 Jul 2020 11:58:15 -0700	[thread overview]
Message-ID: <20200707185818.80177-2-ebiggers@kernel.org> (raw)
In-Reply-To: <20200707185818.80177-1-ebiggers@kernel.org>

From: Eric Biggers <ebiggers@google.com>

Add a function sha256() which computes a SHA-256 digest in one step,
combining sha256_init() + sha256_update() + sha256_final().

This is similar to how we also have blake2s().

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 include/crypto/sha.h |  1 +
 lib/crypto/sha256.c  | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index 10753ff71d46..4ff3da816630 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -147,6 +147,7 @@ static inline void sha256_init(struct sha256_state *sctx)
 }
 void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len);
 void sha256_final(struct sha256_state *sctx, u8 *out);
+void sha256(const u8 *data, unsigned int len, u8 *out);
 
 static inline void sha224_init(struct sha256_state *sctx)
 {
diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c
index 2e621697c5c3..2321f6cb322f 100644
--- a/lib/crypto/sha256.c
+++ b/lib/crypto/sha256.c
@@ -280,4 +280,14 @@ void sha224_final(struct sha256_state *sctx, u8 *out)
 }
 EXPORT_SYMBOL(sha224_final);
 
+void sha256(const u8 *data, unsigned int len, u8 *out)
+{
+	struct sha256_state sctx;
+
+	sha256_init(&sctx);
+	sha256_update(&sctx, data, len);
+	sha256_final(&sctx, out);
+}
+EXPORT_SYMBOL(sha256);
+
 MODULE_LICENSE("GPL");
-- 
2.27.0


WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Cc: alsa-devel@alsa-project.org, Ard Biesheuvel <ardb@kernel.org>,
	Cheng-Yi Chiang <cychiang@chromium.org>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Guenter Roeck <groeck@chromium.org>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-efi@vger.kernel.org,
	Mat Martineau <mathew.j.martineau@linux.intel.com>,
	Matthieu Baerts <matthieu.baerts@tessares.net>,
	mptcp@lists.01.org, Tzung-Bi Shih <tzungbi@google.com>
Subject: [PATCH 1/4] crypto: lib/sha256 - add sha256() function
Date: Tue,  7 Jul 2020 11:58:15 -0700	[thread overview]
Message-ID: <20200707185818.80177-2-ebiggers@kernel.org> (raw)
In-Reply-To: <20200707185818.80177-1-ebiggers@kernel.org>

From: Eric Biggers <ebiggers@google.com>

Add a function sha256() which computes a SHA-256 digest in one step,
combining sha256_init() + sha256_update() + sha256_final().

This is similar to how we also have blake2s().

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 include/crypto/sha.h |  1 +
 lib/crypto/sha256.c  | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index 10753ff71d46..4ff3da816630 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -147,6 +147,7 @@ static inline void sha256_init(struct sha256_state *sctx)
 }
 void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len);
 void sha256_final(struct sha256_state *sctx, u8 *out);
+void sha256(const u8 *data, unsigned int len, u8 *out);
 
 static inline void sha224_init(struct sha256_state *sctx)
 {
diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c
index 2e621697c5c3..2321f6cb322f 100644
--- a/lib/crypto/sha256.c
+++ b/lib/crypto/sha256.c
@@ -280,4 +280,14 @@ void sha224_final(struct sha256_state *sctx, u8 *out)
 }
 EXPORT_SYMBOL(sha224_final);
 
+void sha256(const u8 *data, unsigned int len, u8 *out)
+{
+	struct sha256_state sctx;
+
+	sha256_init(&sctx);
+	sha256_update(&sctx, data, len);
+	sha256_final(&sctx, out);
+}
+EXPORT_SYMBOL(sha256);
+
 MODULE_LICENSE("GPL");
-- 
2.27.0


WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers at kernel.org>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH 1/4] crypto: lib/sha256 - add sha256() function
Date: Tue, 07 Jul 2020 11:58:15 -0700	[thread overview]
Message-ID: <20200707185818.80177-2-ebiggers@kernel.org> (raw)
In-Reply-To: 20200707185818.80177-1-ebiggers@kernel.org

[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]

From: Eric Biggers <ebiggers(a)google.com>

Add a function sha256() which computes a SHA-256 digest in one step,
combining sha256_init() + sha256_update() + sha256_final().

This is similar to how we also have blake2s().

Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
 include/crypto/sha.h |  1 +
 lib/crypto/sha256.c  | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index 10753ff71d46..4ff3da816630 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -147,6 +147,7 @@ static inline void sha256_init(struct sha256_state *sctx)
 }
 void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len);
 void sha256_final(struct sha256_state *sctx, u8 *out);
+void sha256(const u8 *data, unsigned int len, u8 *out);
 
 static inline void sha224_init(struct sha256_state *sctx)
 {
diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c
index 2e621697c5c3..2321f6cb322f 100644
--- a/lib/crypto/sha256.c
+++ b/lib/crypto/sha256.c
@@ -280,4 +280,14 @@ void sha224_final(struct sha256_state *sctx, u8 *out)
 }
 EXPORT_SYMBOL(sha224_final);
 
+void sha256(const u8 *data, unsigned int len, u8 *out)
+{
+	struct sha256_state sctx;
+
+	sha256_init(&sctx);
+	sha256_update(&sctx, data, len);
+	sha256_final(&sctx, out);
+}
+EXPORT_SYMBOL(sha256);
+
 MODULE_LICENSE("GPL");
-- 
2.27.0

  reply	other threads:[~2020-07-07 19:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 18:58 [PATCH 0/4] crypto: add sha256() function Eric Biggers
2020-07-07 18:58 ` [MPTCP] " Eric Biggers
2020-07-07 18:58 ` Eric Biggers
2020-07-07 18:58 ` Eric Biggers [this message]
2020-07-07 18:58   ` [MPTCP] [PATCH 1/4] crypto: lib/sha256 - " Eric Biggers
2020-07-07 18:58   ` Eric Biggers
2020-07-07 22:34   ` kernel test robot
2020-07-07 18:58 ` [PATCH 2/4] efi: use sha256() instead of open coding Eric Biggers
2020-07-07 18:58 ` [PATCH 3/4] mptcp: " Eric Biggers
2020-07-07 18:58   ` [MPTCP] " Eric Biggers
2020-07-08 11:22   ` Matthieu Baerts
2020-07-08 11:22     ` [MPTCP] " Matthieu Baerts
2020-07-07 18:58 ` [PATCH 4/4] ASoC: cros_ec_codec: " Eric Biggers
2020-07-07 18:58   ` Eric Biggers
2020-07-08  2:29   ` Tzung-Bi Shih
2020-07-08  2:29     ` Tzung-Bi Shih
2020-07-08  5:47 ` [PATCH 0/4] crypto: add sha256() function Ard Biesheuvel
2020-07-08  5:47   ` [MPTCP] " Ard Biesheuvel
2020-07-08  5:47   ` Ard Biesheuvel
2020-07-08 11:01 ` Hans de Goede
2020-07-08 11:01   ` [MPTCP] " Hans de Goede
2020-07-08 11:01   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707185818.80177-2-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=ardb@kernel.org \
    --cc=cychiang@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=hdegoede@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=matthieu.baerts@tessares.net \
    --cc=mptcp@lists.01.org \
    --cc=tzungbi@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.