Skip to contentSkip to conversation

Pseudo-random number generator

RFC PATCH In review Jan Glauber 4 participants 11 messages Dec 1, 2006 – Jan 16, 2007

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

RFC PATCH 1/1 Pseudo-random number generator

New s390 machines have hardware support for the generation of pseudo-random numbers. This patch implements a simple char driver that exports this numbers to user-space. Other possible implementations would have been:

* using the new hwrandom number generator API
PRO: reuse of an existing interface
CON: this API is for "truly" random data, not for pseudo-random numbers

* merging the s390 PRNG with the random pool implementation
PRO: no new interface, random numbers can be read through /dev/urandom
CON: complex implementation, could only use traditional /dev/urandom algorithm
or hardware-accelerated implementation

I've chosen the char driver since it allows the user to decide which pseudo-random numbers he wants to use. That means there is a new interface for the s390 PRNG, called /dev/prandom.

I would like to know if there are any objections, especially with the chosen device name.

Jan

---
 arch/s390/crypto/Makefile           |    1 
 arch/s390/crypto/crypt_s390.h       |    3 
 arch/s390/crypto/crypt_s390_query.c |    2 
 arch/s390/crypto/prng.c             |  206 ++++++++++++++++++++++++++++++++++++
 arch/s390/defconfig                 |    1 
 drivers/s390/Kconfig                |    7 +
 include/asm-s390/timex.h            |   12 ++
 7 files changed, 231 insertions(+), 1 deletion(-)
arch/s390/crypto/Makefile +1 -0
diff -urNp linux-2.5/arch/s390/crypto/Makefile linux-2.5_prng/arch/s390/crypto/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s
 obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o
 obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o
 obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o
+obj-$(CONFIG_S390_PRNG) += prng.o
 
 obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o
arch/s390/crypto/crypt_s390.h +2 -1
diff -urNp linux-2.5/arch/s390/crypto/crypt_s390.h linux-2.5_prng/arch/s390/crypto/crypt_s390.h
@@ -68,6 +68,7 @@ enum crypt_s390_kmc_func {
 	KMC_AES_192_DECRYPT  = CRYPT_S390_KMC | 0x13 | 0x80,
 	KMC_AES_256_ENCRYPT  = CRYPT_S390_KMC | 0x14,
 	KMC_AES_256_DECRYPT  = CRYPT_S390_KMC | 0x14 | 0x80,
+	KMC_PRNG	     = CRYPT_S390_KMC | 0x43,
 };
 
 /* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
@@ -147,7 +148,7 @@ crypt_s390_km(long func, void* param, u8
  * @param src: address of source memory area
  * @param src_len: length of src operand in bytes
  * @returns < zero for failure, 0 for the query func, number of processed bytes
- * 	for encryption/decryption funcs
+ *	for encryption/decryption funcs
  */
 static inline int
 crypt_s390_kmc(long func, void* param, u8* dest, const u8* src, long src_len)
arch/s390/crypto/crypt_s390_query.c +2 -0
diff -urNp linux-2.5/arch/s390/crypto/crypt_s390_query.c linux-2.5_prng/arch/s390/crypto/crypt_s390_query.c
@@ -54,6 +54,8 @@ static void query_available_functions(vo
 		crypt_s390_func_available(KMC_AES_192_ENCRYPT));
 	printk(KERN_INFO "KMC_AES_256: %d\n",
 		crypt_s390_func_available(KMC_AES_256_ENCRYPT));
+	printk(KERN_INFO "KMC_PRNG: %d\n",
+		crypt_s390_func_available(KMC_PRNG));
 
 	/* query available KIMD functions */
 	printk(KERN_INFO "KIMD_QUERY: %d\n",
arch/s390/crypto/prng.c +206 -0

206 lines not on this page · raw message

arch/s390/defconfig +1 -0
diff -urNp linux-2.5/arch/s390/defconfig linux-2.5_prng/arch/s390/defconfig
@@ -437,6 +437,7 @@ CONFIG_MONWRITER=m
 #
 CONFIG_ZCRYPT=m
 # CONFIG_ZCRYPT_MONOLITHIC is not set
+CONFIG_S390_PRNG=m
 
 #
 # Network device support
drivers/s390/Kconfig +7 -0
diff -urNp linux-2.5/drivers/s390/Kconfig linux-2.5_prng/drivers/s390/Kconfig
@@ -244,4 +244,11 @@ config ZCRYPT_MONOLITHIC
 	  that contains all parts of the crypto device driver (ap bus,
 	  request router and all the card drivers).
 
+config S390_PRNG
+	tristate "Support for pseudo random number generator device driver"
+	help
+	  Select this option if you want to use the s390 pseudo random number generator.
+	  The PRNG is part of the cryptograhic processor functions and produces
+	  ANSI X9.17 conform numbers. The PRNG is usable via the char device /dev/prandom.
+
 endmenu
include/asm-s390/timex.h +12 -0
diff -urNp linux-2.5/include/asm-s390/timex.h linux-2.5_prng/include/asm-s390/timex.h
@@ -62,6 +62,18 @@ static inline unsigned long long get_clo
 	return clk;
 }
 
+static inline void get_clock_extended(void *dest)
+{
+	typedef struct { unsigned long long clk[2]; } clock_t;
+
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
+	asm volatile("stcke %0" : "=Q" (*((clock_t *)dest)) : : "cc");
+#else /* __GNUC__ */
+	asm volatile("stcke 0(%1)" : "=m" (*((clock_t *)dest))
+				   : "a" ((clock_t *)dest) : "cc");
+#endif /* __GNUC__ */
+}
+
 static inline cycles_t get_cycles(void)
 {
 	return (cycles_t) get_clock() >> 2;
#1 lore raw
Quoted 4 lines

* merging the s390 PRNG with the random pool implementation
PRO: no new interface, random numbers can be read through /dev/urandom
CON: complex implementation, could only use traditional /dev/urandom algorithm
or hardware-accelerated implementation

Also PRO: Can be verified by non-IBM people, high resistance if there is a flaw (accidental or US government 8)) in the 390 hardware.

Quoted 3 lines

I've chosen the char driver since it allows the user to decide which pseudo-random numbers he wants to use. That means there is a new interface for the s390 PRNG, called /dev/prandom.

And people can pipe this into the urandom layer if they wish.

arch/s390/crypto/prng.c line 47

Quoted 6 lines
arch/s390/crypto/prng.c +6 -0
+/* copied from libica, use a non-zero initial parameter block */
+unsigned char parm_block[32] = {
+0x0F,0x2B,0x8E,0x63,0x8C,0x8E,0xD2,0x52,0x64,0xB7,0xA0,0x7B,0x75,0x28,0xB8,0xF4,
+0x75,0x5F,0xD2,0xA6,0x8D,0x97,0x11,0xFF,0x49,0xD8,0x23,0xF3,0x7E,0x21,0xEC,0xA0,
+};
+

Global variables called "p" and "parm_block". Plus parm_block appears to be const

Also your register the misc device before allocating the buffer so it can be opened in theory before the alloc is done and crash.

#2 lore raw
Quoted 7 lines · Alan
Quoted 4 lines

* merging the s390 PRNG with the random pool implementation
PRO: no new interface, random numbers can be read through /dev/urandom
CON: complex implementation, could only use traditional /dev/urandom algorithm
or hardware-accelerated implementation

Also PRO: Can be verified by non-IBM people, high resistance if there is a flaw (accidental or US government 8)) in the 390 hardware.

No, the interesting stuff is done internally in the hardware, we cannot see it with both implementations.

Quoted 5 lines
Quoted 3 lines

I've chosen the char driver since it allows the user to decide which pseudo-random numbers he wants to use. That means there is a new interface for the s390 PRNG, called /dev/prandom.

And people can pipe this into the urandom layer if they wish.

Yes, a user can just symlink urandom to prandom and will have a faster generator.

Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+/* copied from libica, use a non-zero initial parameter block */
+unsigned char parm_block[32] = {
+0x0F,0x2B,0x8E,0x63,0x8C,0x8E,0xD2,0x52,0x64,0xB7,0xA0,0x7B,0x75,0x28,0xB8,0xF4,
+0x75,0x5F,0xD2,0xA6,0x8D,0x97,0x11,0xFF,0x49,0xD8,0x23,0xF3,0x7E,0x21,0xEC,0xA0,
+};
+

Global variables called "p" and "parm_block". Plus parm_block appears to be const

Argh. I'll make them static.

Quoted 2 lines

Also your register the misc device before allocating the buffer so it can be opened in theory before the alloc is done and crash.

Fixed. The misc_register is now done at the very end.

thanks,
Jan

---
 arch/s390/crypto/Makefile           |    1 
 arch/s390/crypto/crypt_s390.h       |    3 
 arch/s390/crypto/crypt_s390_query.c |    2 
 arch/s390/crypto/prng.c             |  203 ++++++++++++++++++++++++++++++++++++
 arch/s390/defconfig                 |    1 
 drivers/s390/Kconfig                |    7 +
 include/asm-s390/timex.h            |   12 ++
 7 files changed, 228 insertions(+), 1 deletion(-)
arch/s390/crypto/Makefile +1 -0
diff -urNp linux-2.5/arch/s390/crypto/Makefile linux-2.5_prng/arch/s390/crypto/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s
 obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o
 obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o
 obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o
+obj-$(CONFIG_S390_PRNG) += prng.o
 
 obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o
arch/s390/crypto/crypt_s390.h +2 -1
diff -urNp linux-2.5/arch/s390/crypto/crypt_s390.h linux-2.5_prng/arch/s390/crypto/crypt_s390.h
@@ -68,6 +68,7 @@ enum crypt_s390_kmc_func {
 	KMC_AES_192_DECRYPT  = CRYPT_S390_KMC | 0x13 | 0x80,
 	KMC_AES_256_ENCRYPT  = CRYPT_S390_KMC | 0x14,
 	KMC_AES_256_DECRYPT  = CRYPT_S390_KMC | 0x14 | 0x80,
+	KMC_PRNG	     = CRYPT_S390_KMC | 0x43,
 };
 
 /* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
@@ -147,7 +148,7 @@ crypt_s390_km(long func, void* param, u8
  * @param src: address of source memory area
  * @param src_len: length of src operand in bytes
  * @returns < zero for failure, 0 for the query func, number of processed bytes
- * 	for encryption/decryption funcs
+ *	for encryption/decryption funcs
  */
 static inline int
 crypt_s390_kmc(long func, void* param, u8* dest, const u8* src, long src_len)
arch/s390/crypto/crypt_s390_query.c +2 -0
diff -urNp linux-2.5/arch/s390/crypto/crypt_s390_query.c linux-2.5_prng/arch/s390/crypto/crypt_s390_query.c
@@ -54,6 +54,8 @@ static void query_available_functions(vo
 		crypt_s390_func_available(KMC_AES_192_ENCRYPT));
 	printk(KERN_INFO "KMC_AES_256: %d\n",
 		crypt_s390_func_available(KMC_AES_256_ENCRYPT));
+	printk(KERN_INFO "KMC_PRNG: %d\n",
+		crypt_s390_func_available(KMC_PRNG));
 
 	/* query available KIMD functions */
 	printk(KERN_INFO "KIMD_QUERY: %d\n",
arch/s390/crypto/prng.c +203 -0

203 lines not on this page · raw message

arch/s390/defconfig +1 -0
diff -urNp linux-2.5/arch/s390/defconfig linux-2.5_prng/arch/s390/defconfig
@@ -437,6 +437,7 @@ CONFIG_MONWRITER=m
 #
 CONFIG_ZCRYPT=m
 # CONFIG_ZCRYPT_MONOLITHIC is not set
+CONFIG_S390_PRNG=m
 
 #
 # Network device support
drivers/s390/Kconfig +7 -0
diff -urNp linux-2.5/drivers/s390/Kconfig linux-2.5_prng/drivers/s390/Kconfig
@@ -244,4 +244,11 @@ config ZCRYPT_MONOLITHIC
 	  that contains all parts of the crypto device driver (ap bus,
 	  request router and all the card drivers).
 
+config S390_PRNG
+	tristate "Support for pseudo random number generator device driver"
+	help
+	  Select this option if you want to use the s390 pseudo random number generator.
+	  The PRNG is part of the cryptograhic processor functions and produces
+	  ANSI X9.17 conform numbers. The PRNG is usable via the char device /dev/prandom.
+
 endmenu
include/asm-s390/timex.h +12 -0
diff -urNp linux-2.5/include/asm-s390/timex.h linux-2.5_prng/include/asm-s390/timex.h
@@ -62,6 +62,18 @@ static inline unsigned long long get_clo
 	return clk;
 }
 
+static inline void get_clock_extended(void *dest)
+{
+	typedef struct { unsigned long long clk[2]; } clock_t;
+
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
+	asm volatile("stcke %0" : "=Q" (*((clock_t *)dest)) : : "cc");
+#else /* __GNUC__ */
+	asm volatile("stcke 0(%1)" : "=m" (*((clock_t *)dest))
+				   : "a" ((clock_t *)dest) : "cc");
+#endif /* __GNUC__ */
+}
+
 static inline cycles_t get_cycles(void)
 {
 	return (cycles_t) get_clock() >> 2;
#3 lore raw
Quoted 2 lines · On Fri, 01 Dec 2006 16:20:46 +0100 Jan Glauber <[email protected]> wrote:

Yes, a user can just symlink urandom to prandom and will have a faster generator.

More usefully they can use it as an entropy source with an entropy daemon to feed it into the standard urandom/random.

#4 lore raw
In reply to Jan Glauber

arch/s390/crypto/prng.c line 63

Quoted 9 lines · Jan Glauber

New s390 machines have hardware support for the generation of pseudo-random numbers. This patch implements a simple char driver that exports this numbers to user-space. Other possible implementations would have been:

arch/s390/crypto/prng.c +5 -0
+	for (i = 0; i < 16; i++) {
+		entropy[0] = get_clock();
+		entropy[1] = get_clock();
+		entropy[2] = get_clock();
+		entropy[3] = get_clock();

By the time this loop completes, we'll have done 64 get_clock() - and if an attacker has a good estimate of what the system clock has in it, they'll be able to guess all 64 values, since each pass through the loop will have fairly predictable timing. So as a result, the pseudo-random stream will be a *lot* less random than one would hope for...

arch/s390/crypto/prng.c line 106

Quoted 4 lines
arch/s390/crypto/prng.c +4 -0
+		/*
+		 * It shouldn't weaken the quality of the random numbers
+		 * passing the full 16 bytes from STCKE to the generator.
+		 */

As long as you realize that probably 12 or 13 or even more of those 16 bytes are likely predictable (depending exactly how fast the hardware clock ticks), and as a result the output stream will also be predictable.

I think this needs to either find a way to stir in entropy from sources other than the clock, or make it clear that the returned data is pseudo-random but likely predictable by a determined attacker. As such, it's probably a bad choice for many things that /dev/urandom is usable for, such as session keys and the like.

#5 lore raw
Quoted 5 lines · On Mon, 2006-12-04 at 11:15 -0500, [email protected] wrote:
Quoted 3 lines · Jan Glauber

New s390 machines have hardware support for the generation of pseudo-random numbers. This patch implements a simple char driver that exports this numbers to user-space. Other possible implementations would have been:

Quoted 11 lines

arch/s390/crypto/prng.c line 63

Quoted 5 lines
arch/s390/crypto/prng.c +5 -0
+	for (i = 0; i < 16; i++) {
+		entropy[0] = get_clock();
+		entropy[1] = get_clock();
+		entropy[2] = get_clock();
+		entropy[3] = get_clock();

By the time this loop completes, we'll have done 64 get_clock() - and if an attacker has a good estimate of what the system clock has in it, they'll be able to guess all 64 values, since each pass through the loop will have fairly predictable timing. So as a result, the pseudo-random stream will be a *lot* less random than one would hope for...

I completely agree. Filling the input buffer with timestamps looks quite uncomfortable but was exactly what the hardware specification suggested.

At least for the initialisation of the PRNG I preferred get_random_bytes() over get_clock to get a good initial seed. But get_random_bytes cannot be used during normal operation since the PRNG read should not block.

Quoted 8 lines

arch/s390/crypto/prng.c line 106

Quoted 4 lines
arch/s390/crypto/prng.c +4 -0
+		/*
+		 * It shouldn't weaken the quality of the random numbers
+		 * passing the full 16 bytes from STCKE to the generator.
+		 */

As long as you realize that probably 12 or 13 or even more of those 16 bytes are likely predictable (depending exactly how fast the hardware clock ticks), and as a result the output stream will also be predictable.

Yes, if an attacker knows the initial clock value a brute-force attack would be feasible to predict the output. But I don't know if the hardware completely relies on the clock values or if there is any internal state which is not visible by an attacker. I will try to find out more details...

Jan

#6 lore raw
Quoted 5 lines · Jan Glauber

Yes, if an attacker knows the initial clock value a brute-force attack would be feasible to predict the output. But I don't know if the hardware completely relies on the clock values or if there is any internal state which is not visible by an attacker. I will try to find out more details...

OK, after some research I got a new proposal. What the hardware does internally is just a Triple-DES operation with 3 different keys.

That means with my old implementation the input for a TDES operation is the buffer full of timestamps. If an attacker can guess the first timestamp he knows the entire input, since the timestamp loop indeed produces timestamps with a constant offset. Therefore I'd like to replace the timestamp loop with only a single timestamp, which has the following advantages:

- it is as safe as the loop (since the additional timestamps contain very low entropy)
- its faster, since we don't have to overwrite the entire buffer
- the one timestamp still guarantees unique, non-repeating output values

Even if an attacker knows the input buffer for the next operation (known-plaintext attack) it turns out that currently this attack is not feasible against TDES. Therefore, as long as the key is not compromised there is no way to guess the next output from the generator.

Jan

--

 arch/s390/crypto/Makefile           |    1 
 arch/s390/crypto/crypt_s390.h       |    3 
 arch/s390/crypto/crypt_s390_query.c |    2 
 arch/s390/crypto/prng.c             |  209 ++++++++++++++++++++++++++++++++++++
 arch/s390/defconfig                 |    1 
 drivers/s390/Kconfig                |    7 +
 6 files changed, 222 insertions(+), 1 deletion(-)
arch/s390/crypto/Makefile +1 -0
diff -urNp linux-2.6.orig/arch/s390/crypto/Makefile linux-2.6/arch/s390/crypto/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s
 obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o
 obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o
 obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o
+obj-$(CONFIG_S390_PRNG) += prng.o
 
 obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o
arch/s390/crypto/crypt_s390.h +2 -1
diff -urNp linux-2.6.orig/arch/s390/crypto/crypt_s390.h linux-2.6/arch/s390/crypto/crypt_s390.h
@@ -68,6 +68,7 @@ enum crypt_s390_kmc_func {
 	KMC_AES_192_DECRYPT  = CRYPT_S390_KMC | 0x13 | 0x80,
 	KMC_AES_256_ENCRYPT  = CRYPT_S390_KMC | 0x14,
 	KMC_AES_256_DECRYPT  = CRYPT_S390_KMC | 0x14 | 0x80,
+	KMC_PRNG	     = CRYPT_S390_KMC | 0x43,
 };
 
 /* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
@@ -147,7 +148,7 @@ crypt_s390_km(long func, void* param, u8
  * @param src: address of source memory area
  * @param src_len: length of src operand in bytes
  * @returns < zero for failure, 0 for the query func, number of processed bytes
- * 	for encryption/decryption funcs
+ *	for encryption/decryption funcs
  */
 static inline int
 crypt_s390_kmc(long func, void* param, u8* dest, const u8* src, long src_len)
arch/s390/crypto/crypt_s390_query.c +2 -0
diff -urNp linux-2.6.orig/arch/s390/crypto/crypt_s390_query.c linux-2.6/arch/s390/crypto/crypt_s390_query.c
@@ -54,6 +54,8 @@ static void query_available_functions(vo
 		crypt_s390_func_available(KMC_AES_192_ENCRYPT));
 	printk(KERN_INFO "KMC_AES_256: %d\n",
 		crypt_s390_func_available(KMC_AES_256_ENCRYPT));
+	printk(KERN_INFO "KMC_PRNG: %d\n",
+		crypt_s390_func_available(KMC_PRNG));
 
 	/* query available KIMD functions */
 	printk(KERN_INFO "KIMD_QUERY: %d\n",
arch/s390/crypto/prng.c +209 -0

209 lines not on this page · raw message

arch/s390/defconfig +1 -0
diff -urNp linux-2.6.orig/arch/s390/defconfig linux-2.6/arch/s390/defconfig
@@ -459,6 +459,7 @@ CONFIG_MONWRITER=m
 #
 CONFIG_ZCRYPT=m
 # CONFIG_ZCRYPT_MONOLITHIC is not set
+CONFIG_S390_PRNG=m
 
 #
 # Network device support
drivers/s390/Kconfig +7 -0
diff -urNp linux-2.6.orig/drivers/s390/Kconfig linux-2.6/drivers/s390/Kconfig
@@ -244,4 +244,11 @@ config ZCRYPT_MONOLITHIC
 	  that contains all parts of the crypto device driver (ap bus,
 	  request router and all the card drivers).
 
+config S390_PRNG
+	tristate "Support for pseudo random number generator device driver"
+	help
+	  Select this option if you want to use the s390 pseudo random number generator.
+	  The PRNG is part of the cryptograhic processor functions and produces
+	  ANSI X9.17 conform numbers. The PRNG is usable via the char device /dev/prandom.
+
 endmenu
#7 lore raw
In reply to Jan Glauber
Quoted 6 lines · Jan Glauber

I've chosen the char driver since it allows the user to decide which pseudo-random numbers he wants to use. That means there is a new interface for the s390 PRNG, called /dev/prandom.

I would like to know if there are any objections, especially with the chosen device name.

This may be a stupid question, but what is it _good_ for? My understanding is that the crypt_s390_kmc() opcodes work in user mode as well as kernel mode, so you should not need a character device at all, but maybe just a small tool that spits prandom data to stdout.

	Arnd <><
#8 lore raw
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Jan Glauber

I've chosen the char driver since it allows the user to decide which pseudo-random numbers he wants to use. That means there is a new interface for the s390 PRNG, called /dev/prandom.

Quoted 7 lines
Quoted 2 lines

I would like to know if there are any objections, especially with the chosen device name.

This may be a stupid question, but what is it _good_ for? My understanding is that the crypt_s390_kmc() opcodes work in user mode as well as kernel mode, so you should not need a character device at all, but maybe just a small tool that spits prandom data to stdout.

Hm, why is /dev/urandom implemented in the kernel?

It could be done completely in user-space (like libica already does) but I think having a device node where you can read from is the simplest implementation. Also, if we can solve the security flaw we could use it as replacement for /dev/urandom.

Jan

#9 lore raw
Quoted 6 lines · Jan Glauber

Hm, why is /dev/urandom implemented in the kernel?

It could be done completely in user-space (like libica already does) but I think having a device node where you can read from is the simplest implementation. Also, if we can solve the security flaw we could use it as replacement for /dev/urandom.

urandom is more useful, because can't be implemented in user space at all. /dev/urandom will use the real randomness from the kernel as a seed without depleting the entropy pool. How does your /dev/prandom device compare to /dev/urandom performance-wise? If it can be made to use the same input data and it turns out to be significantly faster, I can see some use for it.

	Arnd <><
#10 lore raw
Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · Jan Glauber

Hm, why is /dev/urandom implemented in the kernel?

It could be done completely in user-space (like libica already does) but I think having a device node where you can read from is the simplest implementation. Also, if we can solve the security flaw we could use it as replacement for /dev/urandom.

Quoted 6 lines

urandom is more useful, because can't be implemented in user space at all. /dev/urandom will use the real randomness from the kernel as a seed without depleting the entropy pool. How does your /dev/prandom device compare to /dev/urandom performance-wise? If it can be made to use the same input data and it turns out to be significantly faster, I can see some use for it.

The performance of the PRNG without constantly adding entropy is up tp factor 40 faster than /dev/urandom ;- , depending on the block size of the read.

With the current patch it performs not so well because of the STCKE loop before every KMC. I think about removing them and changing the periodically seed to use get_random_bytes instead.

Jan