Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chacha20-Poly1305 encryption #14249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Chacha20-Poly1305 encryption #14249

wants to merge 1 commit into from

Commits on Sep 4, 2024

  1. Chacha20-Poly1305 encryption

    This commit implements the Chacha20-Poly1305 AEAD from RFC 8439 as a new
    algorithm option for encrypted datasets.
    
    AES (and particularly the default AES-GCM mode used in OpenZFS) is known
    to be very slow on systems without hardware assistance. There are many
    such machines out there could make good use of OpenZFS, especially
    low-cost machines and small boards that would otherwise make very nice
    storage machines. The Raspberry Pi series of machines are a good
    example.
    
    The best option for these systems is an encryption option that performs
    well in software. Chacha20-Poly1305 is the current "standard" option for
    this in many contexts, and is a good choice for OpenZFS.
    
    The core Chacha20 and Poly1305 implementations are taken from Loup
    Valliant's Monocypher. These were chosen because they are compact, easy
    to read, easy to use and the author has written extensively about its
    development, all of which give me confidence that there are unlikely to
    be any surprises.
    
    I've added a KCF-style module to the ICP to implement the AEAD. This
    implements just enough for OpenZFS, and is not suitable as a
    general-purpose KCF for Illumos (though it could be the starting point
    for one).
    
    For FreeBSD, which does not use the ICP, I've instead hooked it up to
    FreeBSD's builtin crypto stack.
    
    The rest is adding an enabling property value and a feature flag and and
    hooking it up to all the right touch points, and documentation updates.
    
    The existing tests that cycle through the possible encryption options
    have been extended to add one more.
    
    I've added a test to ensure that raw receives of chacha20-poly1305
    datasets do the right thing based on the state of the feature flag on
    the receiving side.
    
    There's also a test unit that runs the test vectors in RFC 8439 against
    Chacha20, Poly1305 and the AEAD in the ICP that combines them. This is
    most useful as a sanity check during future work to add alternate
    (accelerated) implementations.
    
    Finally, manual interop testing has been done to confirm that pools and
    streams can be moved between Linux and FreeBSD correctly.
    
    Light and uncontrolled performance testing on a Raspberry Pi 4B
    (Broadcom BCM2711, no hardware AES) writing to a chacha20-poly1305
    dataset was ~2.4x faster than aes-256-gcm on the same hardware. On a
    Fitlet2 (Celeron J3455, AES-NI but no AVX (openzfs#10846)) it was ~1.3x faster.
    
    Sponsored-by: https://despairlabs.com/sponsor/
    Signed-off-by: Rob Norris <robn@despairlabs.com>
    robn committed Sep 4, 2024
    Configuration menu
    Copy the full SHA
    d9d69c1 View commit details
    Browse the repository at this point in the history