* [PATCH v2] ASoC: cros_ec_codec: switch to library API for SHA-256
@ 2020-05-15 10:03 Ard Biesheuvel
2020-05-15 10:16 ` Tzung-Bi Shih
2020-05-15 11:10 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2020-05-15 10:03 UTC (permalink / raw)
To: alsa-devel
Cc: Herbert Xu, Arnd Bergmann, Tzung-Bi Shih, Liam Girdwood,
Eric Biggers, Guenter Roeck, Mark Brown, Enric Balletbo i Serra,
Benson Leung, Ard Biesheuvel, Cheng-Yi Chiang
The CrOS EC codec driver uses SHA-256 explicitly, and not in a
performance critical manner, so there is really no point in using
the SHASH crypto API here. Let's switch to the library API instead.
Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Benson Leung <bleung@chromium.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
v2:
- rebase onto sound/for-5.8
- drop pointless memzero_explicit()
- drop include of crypto/hash.h
sound/soc/codecs/Kconfig | 3 +--
sound/soc/codecs/cros_ec_codec.c | 23 ++++----------------
2 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 44b8c4cde4f3..2d4f1b4bc011 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -538,8 +538,7 @@ config SND_SOC_CQ0093VC
config SND_SOC_CROS_EC_CODEC
tristate "codec driver for ChromeOS EC"
depends on CROS_EC
- select CRYPTO
- select CRYPTO_SHA256
+ select CRYPTO_LIB_SHA256
help
If you say yes here you will get support for the
ChromeOS Embedded Controller's Audio Codec.
diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c
index 1948bc6971f6..8d45c628e988 100644
--- a/sound/soc/codecs/cros_ec_codec.c
+++ b/sound/soc/codecs/cros_ec_codec.c
@@ -8,7 +8,6 @@
* EC for audio function.
*/
-#include <crypto/hash.h>
#include <crypto/sha.h>
#include <linux/acpi.h>
#include <linux/delay.h>
@@ -107,25 +106,11 @@ static int send_ec_host_command(struct cros_ec_device *ec_dev, uint32_t cmd,
static int calculate_sha256(struct cros_ec_codec_priv *priv,
uint8_t *buf, uint32_t size, uint8_t *digest)
{
- struct crypto_shash *tfm;
- struct shash_desc *desc;
+ struct sha256_state sctx;
- tfm = crypto_alloc_shash("sha256", CRYPTO_ALG_TYPE_SHASH, 0);
- if (IS_ERR(tfm)) {
- dev_err(priv->dev, "can't alloc shash\n");
- return PTR_ERR(tfm);
- }
- desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_KERNEL);
- if (!desc) {
- crypto_free_shash(tfm);
- return -ENOMEM;
- }
- desc->tfm = tfm;
- crypto_shash_digest(desc, buf, size, digest);
- shash_desc_zero(desc);
-
- kfree(desc);
- crypto_free_shash(tfm);
+ sha256_init(&sctx);
+ sha256_update(&sctx, buf, size);
+ sha256_final(&sctx, digest);
#ifdef DEBUG
{
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] ASoC: cros_ec_codec: switch to library API for SHA-256
2020-05-15 10:03 [PATCH v2] ASoC: cros_ec_codec: switch to library API for SHA-256 Ard Biesheuvel
@ 2020-05-15 10:16 ` Tzung-Bi Shih
2020-05-15 11:10 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Tzung-Bi Shih @ 2020-05-15 10:16 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: ALSA development, Herbert Xu, Arnd Bergmann, Liam Girdwood,
Eric Biggers, Guenter Roeck, Mark Brown, Enric Balletbo i Serra,
Benson Leung, Cheng-Yi Chiang
On Fri, May 15, 2020 at 6:03 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> The CrOS EC codec driver uses SHA-256 explicitly, and not in a
> performance critical manner, so there is really no point in using
> the SHASH crypto API here. Let's switch to the library API instead.
>
> Cc: Cheng-Yi Chiang <cychiang@chromium.org>
> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Cc: Guenter Roeck <groeck@chromium.org>
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: Tzung-Bi Shih <tzungbi@google.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ASoC: cros_ec_codec: switch to library API for SHA-256
2020-05-15 10:03 [PATCH v2] ASoC: cros_ec_codec: switch to library API for SHA-256 Ard Biesheuvel
2020-05-15 10:16 ` Tzung-Bi Shih
@ 2020-05-15 11:10 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2020-05-15 11:10 UTC (permalink / raw)
To: alsa-devel, Ard Biesheuvel
Cc: Herbert Xu, Arnd Bergmann, Tzung-Bi Shih, Liam Girdwood,
Eric Biggers, Enric Balletbo i Serra, Guenter Roeck, Benson Leung,
Cheng-Yi Chiang
On Fri, 15 May 2020 12:03:09 +0200, Ard Biesheuvel wrote:
> The CrOS EC codec driver uses SHA-256 explicitly, and not in a
> performance critical manner, so there is really no point in using
> the SHASH crypto API here. Let's switch to the library API instead.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.8
Thanks!
[1/1] ASoC: cros_ec_codec: switch to library API for SHA-256
commit: 93fa0af4790abdabf80ca0c4fff3f1629c84a56f
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-15 11:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-15 10:03 [PATCH v2] ASoC: cros_ec_codec: switch to library API for SHA-256 Ard Biesheuvel
2020-05-15 10:16 ` Tzung-Bi Shih
2020-05-15 11:10 ` Mark Brown
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.