* Add cxx interop build pipeline
* Update docker-compose.2204.59.yaml
* Change cxx interop CI step to build separate project instead of using cxx compiler flag
* Update docker-compose for 5.10
* Fix package name in docker
* Change code root dirname and remove test target
---------
Co-authored-by: Yim Lee <yim_lee@apple.com>
Motivation
Add Sendable annotations to Crypto Extras to reflect current sandability
so that downstream packages can implement sendable conformance.
Modifications
* Add Sendable conformance to some missed public symbols.
* RSA public and private keys are now marked sendable with their backing storage on darwin OS marked unchecked sendable until SecKey from security framework has sendability annotations
Result
* More accurate Sendable annotations
Motivation
Add Sendable annotations to Crypto Extras to reflect current sandability
so that downstream packages can implement sendable conformance.
Modifications
* Add Sendable conformance to appropriate public symbols.
* RSA public and private keys are notable omissions, this is because
they are backed by SecKey from security framework and we have no
guarantees about their sendability
Result
* Accurate Sendable annotations
Motivation:
As described in #209, I personally need this to migrate an oracle driver from a third party crypto lib to swift-crypto. I think other users might benefit from this addition too.
Modifications:
I've added an overload to the encrypt and decrypt methods of AES._CBC, allowing the user to configure if padding should be added or not. With noPadding set to true, an error will be thrown if the plaintext isn't a multiple of the block size. I've added the corresponding inline documentation.
I've also added tests to ensure both encrypting and decrypting without padding work as expected. Although those tests might not be sufficient enough, because I couldn't find good resources online. I've created a bunch of random hex strings and encrypted/decrypted them using another implementation of paddingless CBC and checked if I receive the expected results. To further validate the feature, I've tested it as part of the authentication in oracle-nio, which worked in all test scenarios I've been running.
Result:
After merging this, it will be possible to use CBC without padding. This closes#209
Motivation
Add RSA OAEP-sha256 support in addition to the increasingly aged SHA-1
implementation.
Modifications
* Add a `Digest` enum to `_RSA.Encryption.Padding`
* Add a digest associated type to the `.pkcs1_oaep` padding enum case
to allow us to distinguish different digest hash functions.
* Add a `PKCS1_OAEP_SHA256` public static let to allow users to use the
new hash function.
* Enable SHA-256 RSA encryption tests
Result
* Support for RSA OAEP-sha256
Motivation
Increased versatility of the `BoringSSLRSAPublicKey` encrypt and decrypt
methods to make future extensions possible.
Modifications
Switch the `BoringSSLRSAPublicKey` encrypt and decrypt methods to use
the `EVP_PKEY_*` API directly rather than going through the RSA
abstractions.
Result
Increased versatility of the `BoringSSLRSAPublicKey` encrypt and decrypt
methods.
Motivation:
Now that Swift 5.9 is GM we should update the supported versions and
remove 5.6
Modifications:
* Update `Package.swift`
* Delete the 5.6 docker compose file and make a 5.10 one
* Update docs
Result:
Remove support for Swift 5.6, add 5.10
Co-authored-by: Cory Benfield <lukasa@apple.com>
# Motivation
We want to support AES-CBC for encryption and decryption purposes.
# Modification
This PR adds support AES-CBC. Furthermore, it adds wycheproof tests for it.
Motivation
This patch brings us up-to-date with CryptoKit's final 2023 API form.
Modifications
Slight tweak to exporter secrets for HPKE to match final spec.
New representation for SecureBytes when empty.
Result
We're ready for the future
Motivation
We need a few extra Windows defines to match what BoringSSL does, and
to suppress warnings.
Modifications
Add the missing defines.
Result
Fewer warnings.
Resolves#195.
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
* Add basic RSA encrypt/decrypt API.
* Add test vectors and tests for RSA encryption API
* Fix build failures
* Fix soundness issue
* Remove support for RSA encryption using the unsafe PKCS1 v1.5 padding
* Fix deprecation warning about the "pointer" version of Data.withUnsafeMutableBytes() by nudging the compiler to infer the "buffer" version.
* Fix deprecation warning about String.init(bytesNoCopy:length:freeWhenDone:) by using String.init(unsafeInitializedCapacity:initializingWith:) instead.
* Make _RSA.Encryption.[Public|Private]Key their own types
* Remove _RSA.Encryption.RSA[Encrypted|Decrypted]Data and just use Data directly. Don't use intermediate Array in BoringSSL implementations.
* Document the message size limits on RSA encrypt/decrypt operations
* Mark `_RSA` visible to documentation so the new docs can actually be seen (underscored name is assumed private by default)
* Fix generic type parameter shadowing warning (new warning in Swift 5.9)
* Fix pre-5.8 build
* Un-correct switch case indentation to make it wrong
Motivation
WWDC has arrived! 🎉 As part of the celebration, let's
bring Crypto up to speed with the new CryptoKit API surface.
Modifications
Substantial new docstrings
HPKE support
Result
WWDC 2023 support.
Needed to expose SecureEncalve through SwiftCrypto when building for
Swift-Certificates. CRYPTO_IN_SWIFTPM is set all of the time in
package.swift, while CRYPTO_IN_SWIFTPM_FORCE_BUILD_API is only set in
development. Lets enable the one that's on all of the time, and remove
the one that isn't so that we get our declarations.
* 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
* Add five new ECDSA Wycheproof test vectors with signatures on IEEE P1363 format, remove four unused Wycheproof test vectors.
* Revert unnecessary protocol extension
* Update ASN1 test helpers to not fatalError but rather fail/throw, needed for some new tests in Wycheproof v1
* Update Wycheproof ecdh_secp521r1_test.json to v1
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>
* Update ASN1 test helpers to not fatalError but rather fail/throw, needed for some new tests in Wycheproof v1
* Update Wycheproof ecdh_secp384r1_test.json to v1
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>
* Exclude AES from CMake
SwiftPM doesn't need it and this would allow removal of CCryptoBoringSSL dependency on non-Darwin platforms, thus reducing SwiftPM size.
* Update update_cmakelists.sh to exclude AES source files