Skip to contentSkip to conversation

Data Co-processor RNG Driver

PATCH In review Kshitiz Varshney 4 participants 9 messages Dec 22, 2022 – Jan 13, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Data Co-processor RNG Driver

Implemented Data Co-Processor random number generation driver.

usage command:
rng <number of bytes>

Kshitiz Varshney (3):
Uboot RNG Driver using Data Co-processor
Added dcp_rng driver initialization code
Added configs required for dcp_rng driver

 arch/arm/mach-imx/mx6/soc.c               |  10 ++
 configs/mx6ull_14x14_evk_defconfig        |   4 +
 configs/mx6ull_14x14_evk_plugin_defconfig |   4 +
 drivers/crypto/fsl/Kconfig                |  10 ++
 drivers/crypto/fsl/Makefile               |   1 +
 drivers/crypto/fsl/dcp_rng.c              | 182 ++++++++++++++++++++++
 6 files changed, 211 insertions(+)
 create mode 100644 drivers/crypto/fsl/dcp_rng.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 Uboot RNG Driver using Data Co-processor

This commit introduces Random number generator to uboot. It uses DCP driver for number generation.
RNG driver can be invoked by using below command on uboot prompt:-
rng <number of bytes>

---
 drivers/crypto/fsl/Kconfig   |  10 ++
 drivers/crypto/fsl/Makefile  |   1 +
 drivers/crypto/fsl/dcp_rng.c | 182 +++++++++++++++++++++++++++++++++++
 3 files changed, 193 insertions(+)
 create mode 100644 drivers/crypto/fsl/dcp_rng.c
drivers/crypto/fsl/Kconfig +10 -0
index b04c70183d..91a51cc5fe 100644
@@ -73,3 +73,13 @@ config FSL_CAAM_RNG
 	  reseeded from the TRNG every time random data is generated.
 
 endif
+
+config FSL_DCP_RNG
+	bool "Enable Random Number Generator support"
+	depends on DM_RNG
+	default n
+	help
+	  Enable support for the hardware based random number generator
+	  module of the DCP. It uses the True Random Number Generator (TRNG)
+	  and a Pseudo-Random Number Generator (PRNG) to achieve a true
+	  randomness and cryptographic strength.
drivers/crypto/fsl/Makefile +1 -0
index f9c3ccecfc..7a2543e16c 100644
@@ -7,4 +7,5 @@ obj-$(CONFIG_FSL_CAAM) += jr.o fsl_hash.o jobdesc.o error.o
 obj-$(CONFIG_CMD_BLOB)$(CONFIG_IMX_CAAM_DEK_ENCAP) += fsl_blob.o
 obj-$(CONFIG_RSA_FREESCALE_EXP) += fsl_rsa.o
 obj-$(CONFIG_FSL_CAAM_RNG) += rng.o
+obj-$(CONFIG_FSL_DCP_RNG) += dcp_rng.o
 obj-$(CONFIG_FSL_MFGPROT) += fsl_mfgprot.o
drivers/crypto/fsl/dcp_rng.c new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v2 1/3] Uboot RNG Driver using Data Co-processor

Quoted 8 lines · Kshitiz Varshney

This commit introduces Random number generator to uboot. It uses DCP driver for number generation.
RNG driver can be invoked by using below command on uboot prompt:-
rng <number of bytes>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH v2 2/3 Added dcp_rng driver initialization code

In reply to Kshitiz Varshney

This commit initializes dcp_rng device driver inside arch_misc_init() function.

---
 arch/arm/mach-imx/mx6/soc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/mach-imx/mx6/soc.c +10 -0
index 08f47cf03d..c2875e727c 100644
@@ -746,6 +746,16 @@ int arch_misc_init(void)
 		if (ret)
 			printf("Failed to initialize caam_jr: %d\n", ret);
 	}
+
+	if (IS_ENABLED(CONFIG_FSL_DCP_RNG)) {
+		struct udevice *dev;
+		int ret;
+
+		ret = uclass_get_device_by_driver(UCLASS_RNG, DM_DRIVER_GET(dcp_rng), &dev);
+		if (ret)
+			printf("Failed to initialize dcp rng: %d\n", ret);
+	}
+
 	setup_serial_number();
 	return 0;
 }
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 3/3 Added configs required for dcp_rng driver

In reply to Kshitiz Varshney

This commit adds configs required for using dcp_rng driver in imx6ull defconfig files.

---
 configs/mx6ull_14x14_evk_defconfig        | 4 ++++
 configs/mx6ull_14x14_evk_plugin_defconfig | 4 ++++
 2 files changed, 8 insertions(+)
configs/mx6ull_14x14_evk_defconfig +4 -0
index 65db621f15..881bc27a69 100644
@@ -65,3 +65,7 @@ CONFIG_DM_SPI=y
 CONFIG_FSL_QSPI=y
 CONFIG_SOFT_SPI=y
 CONFIG_IMX_THERMAL=y
+CONFIG_ARCH_MISC_INIT=y
+CONFIG_DM_RNG=y
+CONFIG_CMD_RNG=y
+CONFIG_FSL_DCP_RNG=y
configs/mx6ull_14x14_evk_plugin_defconfig +4 -0
index 55ddd7eabb..5e6766282e 100644
@@ -64,3 +64,7 @@ CONFIG_DM_SPI=y
 CONFIG_FSL_QSPI=y
 CONFIG_SOFT_SPI=y
 CONFIG_IMX_THERMAL=y
+CONFIG_ARCH_MISC_INIT=y
+CONFIG_DM_RNG=y
+CONFIG_CMD_RNG=y
+CONFIG_FSL_DCP_RNG=y
Signature · 1 line
2.25.1
#7 lore raw
In reply to Kshitiz Varshney
Quoted 5 lines · Kshitiz Varshney

Implemented Data Co-Processor random number generation driver.

usage command:
rng <number of bytes>

Quoted 8 lines

Kshitiz Varshney (3):
Uboot RNG Driver using Data Co-processor
Added dcp_rng driver initialization code
Added configs required for dcp_rng driver

  arch/arm/mach-imx/mx6/soc.c               |  10 ++
  configs/mx6ull_14x14_evk_defconfig        |   4 +
  configs/mx6ull_14x14_evk_plugin_defconfig |   4 +

Do these boards lack the CAAM RNG supported by drivers/crypto/fsl/rng.c?

Best regards

Heinrich

Quoted 6 lines
  drivers/crypto/fsl/Kconfig                |  10 ++
  drivers/crypto/fsl/Makefile               |   1 +
  drivers/crypto/fsl/dcp_rng.c              | 182 ++++++++++++++++++++++
  6 files changed, 211 insertions(+)

create mode 100644 drivers/crypto/fsl/dcp_rng.c

reviewer
#8 lore raw

Hi Heinrich,

Quoted 4 lines · Heinrich Schuchardt
Quoted 2 lines
  configs/mx6ull_14x14_evk_defconfig        |   4 +
  configs/mx6ull_14x14_evk_plugin_defconfig |   4 +

Do these boards lack the CAAM RNG supported by drivers/crypto/fsl/rng.c?

imx6ull does not have CAAM.