Enable the Mediatek EIP-93 crypto engine
Subsystems (3)
v2 cover Enable the Mediatek EIP-93 crypto engine
This series enable the Mediatek EIP-93 crypto engine as found in the MT7621
This engine is capable of AES/DES/3DES ciphers in ECB/CBC and CTR modes, hash and hmac(hash) using MD5, SHA1, SHA224 and SHA256. The engine can do full authenc(hmac(x), cipher(y)) using mentioned ciphers and hashes. The engine also has an ANSI X9.31 PRNG.
This driver is fully test and passes all the extra tests when selecting:CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
For now only simple cipher and authenc are added. In the future I will add patches for hash/hmac and the PRNG.
Richard van Schagen
Changes since V1:
- Fix errors found by kernel test robot.
--- .../bindings/crypto/mediatek,mtk-eip93.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml
drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/mtk-eip93/Kconfig | 49 ++ drivers/crypto/mtk-eip93/Makefile | 7 + drivers/crypto/mtk-eip93/eip93-aead.c | 767 +++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-aead.h | 43 ++ drivers/crypto/mtk-eip93/eip93-aes.h | 15 + drivers/crypto/mtk-eip93/eip93-cipher.c | 399 ++++++++++++ drivers/crypto/mtk-eip93/eip93-cipher.h | 62 ++ drivers/crypto/mtk-eip93/eip93-common.c | 784 ++++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-common.h | 34 + drivers/crypto/mtk-eip93/eip93-des.h | 15 + drivers/crypto/mtk-eip93/eip93-main.c | 458 ++++++++++++++ drivers/crypto/mtk-eip93/eip93-main.h | 146 +++++ drivers/crypto/mtk-eip93/eip93-regs.h | 382 ++++++++++++ 15 files changed, 3164 insertions(+) create mode 100644 drivers/crypto/mtk-eip93/Kconfig create mode 100644 drivers/crypto/mtk-eip93/Makefile create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.c create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.h create mode 100644 drivers/crypto/mtk-eip93/eip93-aes.h create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.c create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.h create mode 100644 drivers/crypto/mtk-eip93/eip93-common.c create mode 100644 drivers/crypto/mtk-eip93/eip93-common.h create mode 100644 drivers/crypto/mtk-eip93/eip93-des.h create mode 100644 drivers/crypto/mtk-eip93/eip93-main.c create mode 100644 drivers/crypto/mtk-eip93/eip93-main.h create mode 100644 drivers/crypto/mtk-eip93/eip93-regs.h
PATCH v2 1/2 dt-bindings: crypto: Add Mediatek EIP-93 crypto engine
Add bindings for the Mediatek EIP-93 crypto engine.
---
Changes since V1
- Add missing #include to examples
.../bindings/crypto/mediatek,mtk-eip93.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml new file +43 -0
@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/mediatek,mtk-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek EIP93 crypto engine + +maintainers: + - Richard van Schagen <[email protected]> + +properties: + compatible: + enum: + - mediatek, mtk-eip93 + + reg: + maxItems: 1 + + interrupts-parent: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupt-parent + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/mips-gic.h> + + crypto: crypto@1e004000 { + compatible = "mediatek,mtk-eip93"; + reg = <0x1e004000 0x1000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SHARED 19 IRQ_TYPE_LEVEL_HIGH>; + };
Signature · 1 line
2.30.2
PATCH v2 2/2 crypto: mtk-eip93 - Add Mediatek EIP-93 crypto engine
In reply to Richard van SchagenThis patch adds support for the Mediatek EIP-93 crypto engine.
This will add AES/DES/3DES ciphers in ECB/CBC and CTR modes as well as authenc(HMAC(x), cipher(y)) using HMAC MD5, SHA1, SHA224 and SHA256.
---
Changes since V1:
- Removed unused variables
- Add corrected header files
- Select dependencies in Kconfig
drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/mtk-eip93/Kconfig | 49 ++ drivers/crypto/mtk-eip93/Makefile | 7 + drivers/crypto/mtk-eip93/eip93-aead.c | 767 +++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-aead.h | 43 ++ drivers/crypto/mtk-eip93/eip93-aes.h | 15 + drivers/crypto/mtk-eip93/eip93-cipher.c | 399 ++++++++++++ drivers/crypto/mtk-eip93/eip93-cipher.h | 62 ++ drivers/crypto/mtk-eip93/eip93-common.c | 784 ++++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-common.h | 34 + drivers/crypto/mtk-eip93/eip93-des.h | 15 + drivers/crypto/mtk-eip93/eip93-main.c | 458 ++++++++++++++ drivers/crypto/mtk-eip93/eip93-main.h | 146 +++++ drivers/crypto/mtk-eip93/eip93-regs.h | 382 ++++++++++++ 15 files changed, 3164 insertions(+) create mode 100644 drivers/crypto/mtk-eip93/Kconfig create mode 100644 drivers/crypto/mtk-eip93/Makefile create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.c create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.h create mode 100644 drivers/crypto/mtk-eip93/eip93-aes.h create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.c create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.h create mode 100644 drivers/crypto/mtk-eip93/eip93-common.c create mode 100644 drivers/crypto/mtk-eip93/eip93-common.h create mode 100644 drivers/crypto/mtk-eip93/eip93-des.h create mode 100644 drivers/crypto/mtk-eip93/eip93-main.c create mode 100644 drivers/crypto/mtk-eip93/eip93-main.h create mode 100644 drivers/crypto/mtk-eip93/eip93-regs.h
drivers/crypto/Kconfig +2 -0
@@ -912,4 +912,6 @@ config CRYPTO_DEV_SA2UL source "drivers/crypto/keembay/Kconfig" +source "drivers/crypto/mtk-eip93/Kconfig" + endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -51,3 +51,4 @@ obj-$(CONFIG_CRYPTO_DEV_ZYNQMP_AES) += xilinx/ obj-y += hisilicon/ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/ obj-y += keembay/ +obj-$(CONFIG_CRYPTO_DEV_EIP93) += mtk-eip93/
drivers/crypto/mtk-eip93/Kconfig new file +49 -0
49 lines not on this page · raw message
drivers/crypto/mtk-eip93/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +obj-$(CONFIG_CRYPTO_DEV_EIP93) += crypto-hw-eip93.o + +crypto-hw-eip93-y += eip93-main.o eip93-common.o + +crypto-hw-eip93-$(CONFIG_CRYPTO_DEV_EIP93_SKCIPHER) += eip93-cipher.o +crypto-hw-eip93-$(CONFIG_CRYPTO_DEV_EIP93_AEAD) += eip93-aead.o +
drivers/crypto/mtk-eip93/eip93-aead.c new file +767 -0
767 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-aead.h new file +43 -0
43 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-aes.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +*/ +#ifndef _EIP93_AES_H_ +#define _EIP93_AES_H_ + +extern struct mtk_alg_template mtk_alg_ecb_aes; +extern struct mtk_alg_template mtk_alg_cbc_aes; +extern struct mtk_alg_template mtk_alg_ctr_aes; +extern struct mtk_alg_template mtk_alg_rfc3686_aes; + +#endif /* _EIP93_AES_H_ */
drivers/crypto/mtk-eip93/eip93-cipher.c new file +399 -0
399 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-cipher.h new file +62 -0
62 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-common.c new file +784 -0
784 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +*/ + +#ifndef _EIP93_COMMON_H_ +#define _EIP93_COMMON_H_ + +inline int mtk_put_descriptor (struct mtk_device *mtk, +struct eip93_descriptor_s *desc); + +inline void *mtk_get_descriptor (struct mtk_device *mtk); + +inline int mtk_get_free_saState (struct mtk_device *mtk); + +void mtk_set_saRecord (struct saRecord_s *saRecord,const unsigned int keylen, +const u32 flags); + +#if IS_ENABLED (CONFIG_CRYPTO_DEV_EIP93_SKCIPHER ) +int mtk_skcipher_send_req (struct crypto_async_request *async); + +void mtk_skcipher_handle_result (struct mtk_device *mtk, +struct crypto_async_request *async, +int err); +#endif + +#if IS_ENABLED (CONFIG_CRYPTO_DEV_EIP93_HMAC ) +int mtk_authenc_setkey (struct crypto_shash *cshash,struct saRecord_s *sa, +const u8 *authkey,unsigned int authkeylen); +#endif + +#endif /* _EIP93_COMMON_H_ */
drivers/crypto/mtk-eip93/eip93-des.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +*/ +#ifndef _EIP93_DES_H_ +#define _EIP93_DES_H_ + +extern struct mtk_alg_template mtk_alg_ecb_des; +extern struct mtk_alg_template mtk_alg_cbc_des; +extern struct mtk_alg_template mtk_alg_ecb_des3_ede; +extern struct mtk_alg_template mtk_alg_cbc_des3_ede; + +#endif /* _EIP93_DES_H_ */
drivers/crypto/mtk-eip93/eip93-main.c new file +458 -0
458 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-main.h new file +146 -0
146 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-regs.h new file +382 -0
211 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.30.2
Part of the diff is not shown here. View the raw message.