mirror of
https://github.com/apple/swift-crypto
synced 2026-11-23 04:34:21 +00:00
* OpenSSLChaCha20CTR Implementation. Wraps CCryptoBoringSSL_CRYPTO_chacha_20. * Insecure extension implementing the ChaCha20 CTR encrypt method. * Added ChaCha20CTR Tests based on vectors provided in RFC9001 Appendix A.5 * Corrected year in header * Changed return type to Data. Removed redundant pointer castings. Removed unnecessary array allocations in favor of withUnsafeBytes. * Introduced a typed ChaCha20CTR Nonce and Counter struct in order to help enforce parameter constraints and type safety. * Formatting * Updated tests to use new Nonce and Counter structs. Added additional test checking for invalid parameters. * Switch to HexStrings for better readability. * Removed empty line at top of file * Fixed UInt32.max counter assertion. * Moved the bindMemory calls out of the function and copied a note from a similar situation elsewhere in the codebase. * Formatting * Implemented an _encryptContiguous function that prevents having to use the withContiguousStorageIfAvailable method. If our DataProtocol is contiguous we encrypt directly, otherwise we consolidate before encrypting. Removed inLen param from chacha20CTR call. * Replaced the chacha20CTR function with a direct call to CCryptoBoringSSL_CRYPTO_chacha_20. * Counter is now backed by a UInt32 instead of Data. Removed Sequence conformance. * Formatting * Formatting * Replaced unsafe code (unsafeBytes and load) with a more generic and safer UInt32 construction. * Replaced counterAsUInt32 definitions with integer literals to avoid symmetric bugs in the load. * Updated _CryptoExtras/CMakeList.txt