2020-06-21 19:33:24

by Corentin LABBE

[permalink] [raw]
Subject: [PATCH v3 00/14] crypto: allwinner: add xRNG and hashes

Hello

The main goal of this serie is to add support for TRNG, PRNG and hashes
to the sun8i-ss/sun8i-ce.
The whole serie is tested with CRYPTO_EXTRA_TESTS enabled and loading
tcrypt.
The PRNG and TRNG are tested with rngtest.

Regards

Change since v1:
- removed _crypto_rng_cast patch

Change since v2:
- cleaned unused variables from sun8i-ce-prng
- added some missing memzero_explicit

Corentin Labbe (14):
crypto: sun8i-ss: Add SS_START define
crypto: sun8i-ss: Add support for the PRNG
crypto: sun8i-ss: support hash algorithms
crypto: sun8i-ss: fix a trivial typo
crypto: sun8i-ss: Add more comment on some structures
crypto: sun8i-ss: better debug printing
crypto: sun8i-ce: move iv data to request context
crypto: sun8i-ce: split into prepare/run/unprepare
crypto: sun8i-ce: handle different error registers
crypto: sun8i-ce: rename has_t_dlen_in_bytes to cipher_t_dlen_in_bytes
crypto: sun8i-ce: support hash algorithms
crypto: sun8i-ce: Add stat_bytes debugfs
crypto: sun8i-ce: Add support for the PRNG
crypto: sun8i-ce: Add support for the TRNG

drivers/crypto/allwinner/Kconfig | 43 ++
drivers/crypto/allwinner/sun8i-ce/Makefile | 3 +
.../allwinner/sun8i-ce/sun8i-ce-cipher.c | 99 +++-
.../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 369 ++++++++++++++-
.../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 415 ++++++++++++++++
.../crypto/allwinner/sun8i-ce/sun8i-ce-prng.c | 161 +++++++
.../crypto/allwinner/sun8i-ce/sun8i-ce-trng.c | 124 +++++
drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 135 +++++-
drivers/crypto/allwinner/sun8i-ss/Makefile | 2 +
.../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 198 +++++++-
.../crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 446 ++++++++++++++++++
.../crypto/allwinner/sun8i-ss/sun8i-ss-prng.c | 170 +++++++
drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h | 93 +++-
13 files changed, 2216 insertions(+), 42 deletions(-)
create mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
create mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c
create mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c
create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c

--
2.26.2


2020-06-21 19:33:26

by Corentin LABBE

[permalink] [raw]
Subject: [PATCH v3 01/14] crypto: sun8i-ss: Add SS_START define

Instead of using an hardcoded value, let's use a defined value for
SS_START.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 2 +-
drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
index 5d9d0fedcb06..81eff935fb5c 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
@@ -61,7 +61,7 @@ int sun8i_ss_run_task(struct sun8i_ss_dev *ss, struct sun8i_cipher_req_ctx *rctx
const char *name)
{
int flow = rctx->flow;
- u32 v = 1;
+ u32 v = SS_START;
int i;

#ifdef CONFIG_CRYPTO_DEV_SUN8I_SS_DEBUG
diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
index 29c44f279112..f7a64033fc03 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
@@ -13,6 +13,8 @@
#include <linux/debugfs.h>
#include <linux/crypto.h>

+#define SS_START 1
+
#define SS_ENCRYPTION 0
#define SS_DECRYPTION BIT(6)

--
2.26.2

2020-06-21 19:33:40

by Corentin LABBE

[permalink] [raw]
Subject: [PATCH v3 05/14] crypto: sun8i-ss: Add more comment on some structures

This patch adds some comment on structures used by sun8i-ss.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
index 056fcdd14201..b2668e5b612f 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
@@ -171,6 +171,8 @@ struct sun8i_ss_dev {
* @ivlen: size of biv
* @keylen: keylen for this request
* @biv: buffer which contain the IV
+ *
+ * t_src, t_dst, p_key, p_iv op_mode, op_dir and method must be in LE32
*/
struct sun8i_cipher_req_ctx {
struct sginfo t_src[MAX_SG];
@@ -193,6 +195,8 @@ struct sun8i_cipher_req_ctx {
* @keylen: len of the key
* @ss: pointer to the private data of driver handling this TFM
* @fallback_tfm: pointer to the fallback TFM
+ *
+ * enginectx must be the first element
*/
struct sun8i_cipher_tfm_ctx {
struct crypto_engine_ctx enginectx;
--
2.26.2