-
Notifications
You must be signed in to change notification settings - Fork 170
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 CTR Encryption #169
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I've left some notes in the diff.
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
…ved unnecessary array allocations in favor of withUnsafeBytes.
…elp enforce parameter constraints and type safety.
…test checking for invalid parameters.
… a similar situation elsewhere in the codebase.
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
Sources/_CryptoExtras/ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift
Outdated
Show resolved
Hide resolved
…e the withContiguousStorageIfAvailable method. If our DataProtocol is contiguous we encrypt directly, otherwise we consolidate before encrypting. Removed inLen param from chacha20CTR call.
…SSL_CRYPTO_chacha_20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, this is getting really close to ready to land. I've left a few more notes, but they're getting very trivial now.
…afer UInt32 construction.
…ymmetric bugs in the load.
@swift-server-bot test this please |
@swift-server-bot test this please |
Excellent, one quick fixup: can you run |
@swift-server-bot test this please |
Awesome! Thanks for guiding me through this PR, I really appreciate all the comments / help. Sorry for taking up so much of your time! 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got nothing to apologise for! This has been a great patch, and there's nothing wrong with going through a few review cycles to get to a final state we're all happy with. Thanks for doing the work!
Added a method to interact with BoringSSL's
CCryptoBoringSSL_CRYPTO_chacha_20()
Checklist
Motivation:
Having the ability to explicitly set the Counter in the ChaCha20 Cipher allows us to generate 'Header Protection Masks' as described in RFC 9001 - Using TLS to Secure QUIC and issue #168
Modifications:
Added a single encryption method under the
Insecure.ChaCha20CTR
enum that lets the user of this library perform single block encryptions with an explicitly defined Counter and Nonce / IV.The ChaCha20CTR enum described above is defined in the
_CryptoExtras
product.Result:
After including both
Crypto
and_CryptoExtras
in your project you'll have access to the ChaCha20CTR enum and the associated encryption method that enables one off encryption operations.See the included ChaCha20CTRTests.swift file for usage examples.