* 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
Motivation
CryptoExtras RSA public keys support being exported in DER and PEM form.
These exports work great, but it turns out they are inconsistent between
the Darwin and non-Darwin implementations. Darwin platforms would export
the public keys in PKCS1 format, while non-Darwin was exporting them as
SPKI. This isn't great!
Modifications
- Make the two consistent. `.derRepresentation` should export SPKI
formatted public keys, because that's what it does for all the EC
keys.
- Add `.pkcs1DERRepresentation` and `.pkcs1PEMRepresentation` for those
users that require the PKCS1 formatted key.
Result
Key export types are now consistent on all platforms.
In some cases developers have need of AES modes other than what we
support today, or need the ability to implement algorithms that require
access to the core AES permutation function. As a starting point, we can
provide access to the AES block function in CryptoExtras.
The package DLL `Crypto.dll` was building the BoringSSL wrapper
(`CryptoBoringWrapper`) in the style that the user requested (static or
shared). However, there is a single user of the library and is not
directly included by the SPM client. Furthermore, the library was not
setup for installation which makes redistribution of it impossible.
Always build the library in a static mode to allow compaction into the
`Crypto` target.
Motivation
The init(derRepresentation:) and init(pemRepresentation:) constructors
for RSA public keys support both PKCS#8 and PKCS#1 key formats on
Darwin. This support was missing from Linux, with only PKCS#8 support.
This patch brings the two platforms into parity.
Modifications
Add code to try both versions on Linux.
Add tests.
Results
PKCS#1 keys are supported on Linux too!
# Motivation
BoringSSL exposes AES-GCM-SIV algorithms which are in general useful to have and provide a nonce-misuse resistant mode of AES-GCM. Since, `CryptoKit` is not exposing AES-GCM-SIV we need to add this to `_CryptoExtras`
# Modification
Exposes `AES-GCM-SIV` through `_CryptoExtras`.
# Result
We can now use `AES-GCM-SIV` through `_CryptoExtras`.
* Make BoringSSL wrapper match CryptoKit behaviour when working with x963 representation
* Revert Package.swift changes
* Fix Signing tests and add test cases for invalid key lengths
* Bring over API files from macOS Ventura
* Implement the new API surface
This patch implements the new API surface, and removes anything that's
no longer compatible with the expected API surface from CryptoKit
Without the explicit typing, the build fails with recent toolchain
builds expecting the type to conform to an incorrect type. This
repairs the build.
Co-authored-by: Cory Benfield <lukasa@apple.com>
When contentLength is greater than 8 bits, i.e., greater than UInt8.max, the original implementation crashes.
To work around this, use UInt8.init(truncatingIfNeeded:) to truncate only the lower 8 bits.
Motivation:
When using only the CryptoKit API on Apple platforms we have always
thunked through to the CryptoKit interface and implementation. However,
we didn't do a thorough job of preventing the BoringSSL target from
getting compiled and linked.
We can do a better job now, which will save compile times and binary
sizes in many cases.
Modifications:
- Change Package.swift to express a target specific dependency in most
cases.
- Preserve a development mode which overrides that target specific
dependency.
- Add the missing compile guards.
Results:
Smaller binaries and faster compiles on Apple platforms.
Motivation:
CryptoKit supports the compressed key format: we should as well.
Modifications:
Extend the constructors of public keys to tolerate the compressed
representation.
Result:
Users holding compressed keys can use them.
Motivation:
I couldn't build for Android armv7 on the CI I set up without this.
Modifications:
Initialize with the right size of UInt to BoringSSL.
Result:
I can build for armv7 again.
Co-authored-by: Cory Benfield <lukasa@apple.com>
Motivation:
The various Apple SoS projects are currently dropping Swift 5.1 support.
Swift Crypto should do the same. While we're here, let's add CI for 5.4,
5.5 nightlies, and main nightlies.
Modifications:
- Remove 5.1 dockerfile.
- Stop claiming we support 5.1.
- Add 5.4, 5.5, and main dockerfiles.
- Updated Swift Format to 5.2.
- Associated formatting changes.
Result:
Better test matrix and support matrix.
Motivation:
Some critical use-cases require RSA signing support. This is most
commonly required when interacting with legacy systems. While RSA is an
older and less efficient cryptosystem than the elliptic-curve algorithms
supported by Swift Crypto already, those interop use-cases are
unavoidable.
This version of the patch does not promote RSA to supported API at this
time, as we'd like to let the API bake somewhat. Users are free to use
it, but these APIs are not covered by semantic versioning at this time
and may break in future.
Modifications:
- Defined new RSA API
- Implemented on top of `Security` when available
- Implemented on top of BoringSSL when `Security` is unavailable
Result:
Users can do RSA if needed.
The `include` directory is required for the interface include
directories for using `CCryptoBoringSSL` as a module from an external
package (i.e. SPM). This allows SPM to include `CCryptoBoringSSL`
and find the module map.
When building swift-crypto from source for a toolchain build, it is
convenient to build it without building up a toolchain image. This
additional knob allows for building swift-crypto with the build
artifacts of previous builds, allowing building up a toolchain image
while chaining multiple builds together.
Co-authored-by: tomer doron <tomer@apple.com>
* Setup docker for cmake build
Motivation:
Be able to run cmake build in CI
Modifications:
- Add "cmake" service to `docker-compose.yaml`
- Update `Dockerfile` to install `cmake` and `ninja`. Remove unneeded dependencies.
- Add `docker-compose.2004.53.yaml`. `cmake` on previous Ubuntu versions are too old and it would be a pain to upgrade, so using Ubuntu 20.04 to simplify things.
- Add back modulemap to ensure cmake build is successful
Result:
Can run cmake in CI
This adds the generated assembly files for Windows. Unfortunately, the
x64 generated assembly appears to be ELF-esque and SYSV ABI rather than
Win64. Additionally, the ARM targets do not seem to generate valid
Windows ARM code either (quick perusal shows at least invalid SP
handling on ARMv7 NT and non-conforming prologues on AArch64). Add x86
Windows assembly only for the time being.
Co-authored-by: Cory Benfield <lukasa@apple.com>
Resolves [issue#51](https://github.com/apple/swift-crypto/issues/51).
In Swift 5.3, a warning is viewed on Linux because `memset_s` implemented in this module returns `Void`.
This commit let the function return the same type with Darwin.