Jump to content

Hardware PRNG/TRNG/SHA on sun8i-ce platform boards


Recommended Posts

Hi,

 

Linux 5.10 has supported hardware PRNG, SHA, MD% for all sun8i-ce (H3/R40/A64/H5/H6) boards, and supported hardware TRNG on H6.

 

Please consider enable CONFIG_CRYPTO_DEV_SUN8I_CE_HASH, CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG, CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG for hardware offload support.

 

Thanks.

 

 

 

Link to comment
Share on other sites

Thanks for your help :)

 

These items are bool,  so there is a typo on your changes, it should use "y" instead of "m".

I've compiled the kernel with enable these configuration items for testing.

 

With new kernel, hardware acceleration of hash and PRNG are working.

About TRNG, I don't have H6 board so I can't test it, but it should work.

 

====

Tested with Allwinner H5 @ 1.3GHz (NanoPi NEO Plus2)
Custom compiled OpenSSL 1.1.1f (enable afalg & devcrypto)

 

Hardware acceleration using devcrypto engine:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
md5                125.41k      492.89k     1973.08k     7892.65k    34665.81k    69555.54k
sha1               130.07k      514.35k     2055.51k     8212.48k    66057.56k   130498.56k
sha224             117.82k      493.03k     1927.34k     7808.00k    62761.64k   123442.52k
sha256             113.03k      464.36k     1863.77k     7758.51k    61401.77k   128270.34k

Hardware acceleration using af-alg engine:
md5                122.03k      487.08k     1945.43k     7781.72k    34679.47k    71068.33k
sha1               128.31k      523.97k     2096.81k     8388.95k    66704.73k   117396.82k
sha224             122.69k      490.47k     1933.57k     7881.05k    61666.65k   122350.25k
sha256             124.84k      502.57k     2017.62k     8225.45k    63477.08k   112044.71k

 

Hardware PRNG:
# kcapi-rng -b 100000000000  | rngtest -c 1000

rngtest 5
Copyright (c) 2004 by Henrique de Moraes Holschuh
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

rngtest: starting FIPS tests...
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 999
rngtest: FIPS 140-2 failures: 1
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 1
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=10.850; avg=120.314; max=9536.743)Mibits/s
rngtest: FIPS tests speed: (min=18.131; avg=46.903; max=61.726)Mibits/s
rngtest: Program run time: 568755 microseconds


sun8i-ce stats:
# cat /sys/kernel/debug/sun8i-ce/stats 
Channel 0: nreq 550144
Channel 1: nreq 550145
Channel 2: nreq 550145
Channel 3: nreq 276099
cbc-aes-sun8i-ce cbc(aes) 1496438 191409
ecb-aes-sun8i-ce ecb(aes) 133344 0
cbc-des3-sun8i-ce cbc(des3_ede) 20652 0
ecb-des3-sun8i-ce ecb(des3_ede) 0 0
md5-sun8i-ce md5 0 607984
sha1-sun8i-ce sha1 0 840794
sha224-sun8i-ce sha224 0 447130
sha256-sun8i-ce sha256 0 716347
sun8i-ce-prng stdrng 276099 55219720
HWRNG 0 0
 

 

 

 

Link to comment
Share on other sites

1 hour ago, akw said:

These items are bool,  so there is a typo on your changes, it should use "y" instead of "m".

I've compiled the kernel with enable these configuration items for testing.

 

With new kernel, hardware acceleration of hash and PRNG are working.

About TRNG, I don't have H6 board so I can't test it, but it should work.


PR updated and I guess we are ready to merge?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines