Refactor Common AEAD Code in Ciphersuite Package#789
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #789 +/- ##
==========================================
+ Coverage 82.04% 82.18% +0.13%
==========================================
Files 111 111
Lines 6501 6490 -11
==========================================
Hits 5334 5334
+ Misses 766 759 -7
+ Partials 401 397 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
19ea7d2 to
8ed00b7
Compare
|
BTW - all the ciphers are tested by the end-to-end tests in |
721e40e to
303b739
Compare
|
I'll have a look on Monday. It also seems like the new record header for DTLS 1.3 won't cause too much trouble/change. |
|
Great @theodorsm . I think i’ll leave the chacha20poly addition outside of this PR and keep only refactors here. Then i’ll open a new PR with full support for chacha20poly ciphersuite. Will also be easier to review that way. |
5897587 to
c054e3f
Compare
Signed-off-by: Adriano Sela Aviles <adriano.selaviles@gmail.com>
c054e3f to
19bc50b
Compare
|
This PR is now just a refactor of common code (in preparation to add ChaCha20-Poly1305 support, which will also use the same underlying |
JoTurk
left a comment
There was a problem hiding this comment.
Yeah this direction makes sense. thank you.
|
Note to self, for later: I've found that I can make all AEAD crypto primitives even faster by having a single re-usable buffer for nonces in encrypt, and another re-usable buffer for nonces in decrypt instead of using buffer pools, e.g.: The numbers are really significant:
However, making the change would make This is OK given usage here in Unfortunately this package is public ( ...So it would be unwise to go from thread-safe to thread-unsafe without a major release. I will remember to make that change right before the next major release. |
|
See #795 related to my comment above. |
Refactor Common AEAD Code in Ciphersuite Package
CCM, and GCM are all AEAD based, so I've refactored the encrypt/decrypt logic into a generic
aeadimplementation.This is in preparation to add support for ChaCha20-Poly1305, which is also AEAD based.
Also refactors all the common code in all the benchmark tests into helper functions
benchmarkEncryptandbenchmarkDecryptThe refactor also includes using buffer-pools for nonces for all of the ciphers... which comes with some nice side effects. Performance is neutral to slightly better for the refactored cipher implementations (CCM and GCM), and memory allocations per operation are reduced:
CCM:
GCM:
Next PR will add a ChaCha20-Poly1305 crypto primitive and full cipher suite implementations (TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, etc...).