Skip to contentSkip to conversation

crypto: hisilicon - Add HiSilicon ADVCA Subsystem

PATCH In review David Yang 2 participants 4 messages Jun 6, 2023 – Jun 16, 2023

Subsystems (2)
lore
Share & tools
lore

David Yang

author
#0 lore raw

v4 cover crypto: hisilicon - Add HiSilicon ADVCA Subsystem

HiSilicon ADVCA Subsystem contains various cryptographic devices, including symmetric key ciphers, hash functions, RSA algorithms, as well as key ladder and OTP memory.

This series adds symmetric key cipher and SHA algorithm family driver.

This series is based on Hi3798Mv100.

v2: sorry, I accidentally skipped v1.
v3:
* use devm_reset_control_get_optional_exclusive
* disable clocks if init failed
* put device reset when removal
* implement import function for sha device
* fix typo reported by test bot
v4: fix sparse warnings

David Yang (2):
crypto: hisilicon - Add HiSilicon ADVCA Subsystem
crypto: hisilicon/advca - Add SHA support

 drivers/crypto/hisilicon/Kconfig              |   11 +
 drivers/crypto/hisilicon/Makefile             |    1 +
 drivers/crypto/hisilicon/advca/Makefile       |    2 +
 .../crypto/hisilicon/advca/hisi-advca-muc.c   | 1530 +++++++++++++++++
 .../crypto/hisilicon/advca/hisi-advca-sha.c   |  659 +++++++
 5 files changed, 2203 insertions(+)
 create mode 100644 drivers/crypto/hisilicon/advca/Makefile
 create mode 100644 drivers/crypto/hisilicon/advca/hisi-advca-muc.c
 create mode 100644 drivers/crypto/hisilicon/advca/hisi-advca-sha.c

base-commit: f8dba31b0a826e691949cd4fdfa5c30defaac8c5

Signature · 1 line
2.39.2
author
#1 lore raw

PATCH v4 1/2 crypto: hisilicon - Add HiSilicon ADVCA Subsystem

HiSilicon ADVCA Subsystem contains various cryptographic devices, including symmetric key ciphers, hash functions, RSA algorithms, as well as key ladder and OTP memory.

This patch adds symmetric key cipher driver.

---
 drivers/crypto/hisilicon/Kconfig              |    8 +
 drivers/crypto/hisilicon/Makefile             |    1 +
 drivers/crypto/hisilicon/advca/Makefile       |    1 +
 .../crypto/hisilicon/advca/hisi-advca-muc.c   | 1530 +++++++++++++++++
 4 files changed, 1540 insertions(+)
 create mode 100644 drivers/crypto/hisilicon/advca/Makefile
 create mode 100644 drivers/crypto/hisilicon/advca/hisi-advca-muc.c
drivers/crypto/hisilicon/Kconfig +8 -0
index e8690c223584..99279a9ec6b1 100644
@@ -1,5 +1,13 @@
 # SPDX-License-Identifier: GPL-2.0
 
+config CRYPTO_DEV_HISI_ADVCA
+	tristate "Support for Hisilicon ADVCA Subsystem"
+	depends on ARCH_HISI || COMPILE_TEST
+	select CRYPTO_SKCIPHER
+	help
+	  Support for Hisilicon ADVCA (Advanced Conditional Access) Subsystem,
+	  which can be found on HiSilicon STB SoCs, such as Hi37xx.
+
 config CRYPTO_DEV_HISI_SEC
 	tristate "Support for Hisilicon SEC crypto block cipher accelerator"
 	select CRYPTO_SKCIPHER
drivers/crypto/hisilicon/Makefile +1 -0
index fc51e0edec69..37600b94e1d9 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_CRYPTO_DEV_HISI_ADVCA) += advca/
 obj-$(CONFIG_CRYPTO_DEV_HISI_HPRE) += hpre/
 obj-$(CONFIG_CRYPTO_DEV_HISI_SEC) += sec/
 obj-$(CONFIG_CRYPTO_DEV_HISI_SEC2) += sec2/
drivers/crypto/hisilicon/advca/Makefile new file +1 -0
new file mode 100644
index 000000000000..3f64b4a24e9e
@@ -0,0 +1 @@
+obj-$(CONFIG_CRYPTO_DEV_HISI_ADVCA) += hisi-advca-muc.o
drivers/crypto/hisilicon/advca/hisi-advca-muc.c new file +1530 -0

1,530 lines not on this page · raw message

Signature · 1 line
2.39.2
author
#2 lore raw

PATCH v4 2/2 crypto: hisilicon/advca - Add SHA support

In reply to David Yang

Add driver for SHA algorithm family.

Support for state injection was not tested due to lack of such device.

---
 drivers/crypto/hisilicon/Kconfig              |   3 +
 drivers/crypto/hisilicon/advca/Makefile       |   1 +
 .../crypto/hisilicon/advca/hisi-advca-sha.c   | 659 ++++++++++++++++++
 3 files changed, 663 insertions(+)
 create mode 100644 drivers/crypto/hisilicon/advca/hisi-advca-sha.c
drivers/crypto/hisilicon/Kconfig +3 -0
index 99279a9ec6b1..6e94f56e9a2c 100644
@@ -4,6 +4,9 @@ config CRYPTO_DEV_HISI_ADVCA
 	tristate "Support for Hisilicon ADVCA Subsystem"
 	depends on ARCH_HISI || COMPILE_TEST
 	select CRYPTO_SKCIPHER
+	select CRYPTO_HASH
+	select CRYPTO_SHA1
+	select CRYPTO_SHA256
 	help
 	  Support for Hisilicon ADVCA (Advanced Conditional Access) Subsystem,
 	  which can be found on HiSilicon STB SoCs, such as Hi37xx.
drivers/crypto/hisilicon/advca/Makefile +1 -0
index 3f64b4a24e9e..e556d3f81729 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_CRYPTO_DEV_HISI_ADVCA) += hisi-advca-muc.o
+obj-$(CONFIG_CRYPTO_DEV_HISI_ADVCA) += hisi-advca-sha.o
drivers/crypto/hisilicon/advca/hisi-advca-sha.c new file +659 -0

659 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer
#3 lore raw

Re: [PATCH v4 2/2] crypto: hisilicon/advca - Add SHA support

On Tue, Jun 06, 2023 at 03:11:12PM +0800, David Yang wrote:
.

drivers/crypto/hisilicon/advca/hisi-advca-sha.c line 160

Quoted 8 lines
drivers/crypto/hisilicon/advca/hisi-advca-sha.c new file +8 -0
+/*
+ * must be called before setting SHA_START
+ * does nothing if import is not supported (SHA_TYPE_HASH)
+ */
+static void hica_sha_import(const struct hica_sha_priv *priv, const void *state)
+{
+	if (priv->type != SHA_TYPE_MHASH)
+		return;

As you may have noticed from the void return type, an import is not allowed to fail. If you have to fail then you're doing something wrong.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt