git: csprng: Update to use crypto/chacha20 (a better version)

Aaron LI aly at crater.dragonflybsd.org
Sat Nov 11 00:02:18 PST 2023


commit 4104d69157ee38ff93919a108aa1819707050150
Author: Aaron LI <aly at aaronly.me>
Date:   Wed Nov 8 14:08:52 2023 +0800

    csprng: Update to use crypto/chacha20 (a better version)
    
    The CSPRNG code was already using Chacha20 (from crypto/chacha) to
    generate the random stream.  However, the 'crypto/chacha20' version
    has been tweaked for and better suited to random stream generation.
    The enhancements include:
    
    - Provide the KEYSTREAM_ONLY mode to help ease the invocation and
      improve performance.
    - Allow to use a 128-bit counter to avoid worrying about overflow
      (i.e., nonce reuse).  This also remove the burden on the caller
      to check for counter overflow and rotate nonce.
    - Can be embedded for better compiler optimization.
    
    The 'crypto/chacha20' was imported on 2023-02-25 from FreeBSD to
    implement the libc arc4random(3) API.  After the CSPRNG migration,
    the old 'crypto/chacha' version become unused and will be removed
    in a later commit.
    
    Referred to FreeBSD and OpenBSD.

Summary of changes:
 sys/conf/files               |  1 -
 sys/crypto/chacha20/chacha.c |  2 ++
 sys/crypto/chacha20/chacha.h |  3 ++-
 sys/kern/subr_csprng.c       | 56 +++++++++++++-------------------------------
 sys/sys/csprng.h             |  6 ++---
 5 files changed, 22 insertions(+), 46 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4104d69157ee38ff93919a108aa1819707050150


-- 
DragonFly BSD source repository


More information about the Commits mailing list