Skip to content

Add ChaCha20-Poly1305 crypto cipher support and introduce runtime availability checks for crypto ciphers #375

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ManManson
Copy link

@ManManson ManManson commented Apr 27, 2025

This changeset implements the following three major things:

  1. Introduces the support for ChaCha20-Poly1305 crypto cipher for all supported crypto backend libraries (OpenSSL and Libsodium). Libsodium uses the IETF variant of the algorithm, which should be compatible with other conforming implementations (e.g., it should be no problem if one client runs OpenSSL, while another runs libsodium).
  2. Add runtime availability checks for both AES-GCM and ChaCha20-Poly1305 ciphers (IsAvailable() method for the corresponding CipherContext classes).
  3. Libsodium use is not restricted to x86/x86_64 anymore, as ChaCha20-Poly1305 should always be available.

This PR is based on the prior work from @past-due, that was done in the scope of #197

Fixes: #196

ManManson and others added 7 commits April 27, 2025 13:06
Some backends may not support AES-GCM on all systems (example: libsodium). Add a new static AES_GCM_CipherContext::IsAvailable() function.

Co-Authored-By: past-due <[email protected]>

Signed-off-by: Pavel Solodovnikov <[email protected]>
Some backends may not support AES-GCM on all systems. Be more precise in what algorithms are advertised / initialized.

Co-Authored-By: past-due <[email protected]>

Signed-off-by: Pavel Solodovnikov <[email protected]>
This change contains an implementation of the
ChaCha20-Poly1305 crypto cipher for all supported
crypto libraries (both OpenSSL and Libsodium).

Windows's BCrypt library doesn't support it (hence,
`ChaCha20_Poly1305_CipherContext::IsAvailable() == false`).

In Libsodium, ChaCha20-Poly1305 is always available,
while in OpenSSL it depends on whether the library has
been compiled with the corresponding features or not
(controlled via `OPENSSL_NO_CHACHA` and `OPENSSL_NO_POLY1305`
feature macros).

Signed-off-by: Pavel Solodovnikov <[email protected]>
Now that there's ChaCha20-Poly1305 implementation alongside AES-GCM
(which is always available in libsodium), this restriction is not
needed anymore.

Signed-off-by: Pavel Solodovnikov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More flexible crypto config
2 participants