Support for s390 Pseudo Random Number Generator
Subsystems (3)
From: Jan Glauber <[email protected]>
[S390] Support for s390 Pseudo Random Number Generator
Starting with the z9 the CPU Cryptographic Assist Facility comes with an integrated Pseudo Random Number Generator. The generator creates random numbers by an algorithm similar to the ANSI X9.17 standard. The pseudo-random numbers can be accessed via a character device driver node called /dev/prandom. Similar to /dev/urandom any amount of bytes can be read from the device without blocking.
Signed-off-by Jan Glauber <[email protected]>
Signed-off-by Martin Schwidefsky <[email protected]>
---
arch/s390/crypto/Makefile | 1 arch/s390/crypto/crypt_s390.h | 1 arch/s390/crypto/crypt_s390_query.c | 2 arch/s390/crypto/prng.c | 213 ++++++++++++++++++++++++++++++++++++ arch/s390/defconfig | 1 drivers/crypto/Kconfig | 2 include/asm-s390/timex.h | 12 ++ 7 files changed, 232 insertions(+)
arch/s390/crypto/crypt_s390.h +1 -0
@@ -71,6 +71,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, };/*
arch/s390/crypto/crypt_s390_query.c +2 -0
@@ -55,6 +55,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/Makefile +1 -0
@@ -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/prng.c +213 -0
213 lines not on this page · raw message
arch/s390/defconfig +1 -0
@@ -756,6 +756,7 @@ CONFIG_CRYPTO_CBC=y # CONFIG_CRYPTO_SHA256_S390 is not set # CONFIG_CRYPTO_DES_S390 is not set # CONFIG_CRYPTO_AES_S390 is not set +CONFIG_S390_PRNG=m # # Library routines
drivers/crypto/Kconfig +2 -0
@@ -51,6 +51,8 @@ config CRYPTO_DEV_PADLOCK_SHA If unsure say M. The compiled module will be called padlock-sha.ko +source "arch/s390/crypto/Kconfig" + config CRYPTO_DEV_GEODE tristate "Support for the Geode LX AES engine" depends on CRYPTO && X86_32 && PCI
include/asm-s390/timex.h +12 -0
@@ -62,6 +62,18 @@ static inline unsigned long long get_cloreturn 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 ) + asmvolatile ("stcke %0" :"=Q" (*((__clock_t *)dest)) : :"cc" ); +#else /* __GNUC__ */ + asmvolatile ("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 ;