Commit Graph

53 Commits

Author SHA1 Message Date
Franz Busch d11194ad26
Provide AES-GCM-SIV in CryptoExtras (#133)
# 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`.
2022-10-14 09:50:36 +01:00
George Barnett d89caf3006
Update BoringSSL to cab31f65f1ad6e6daca62e95b25dd6cd805fce0b (#132) 2022-09-28 12:08:04 +01:00
Alex Shatberashvili 30eab5ad37
Make BoringSSL wrapper match CryptoKit behaviour when working with x9.63 (#128)
* 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
2022-08-23 11:47:08 +01:00
Cory Benfield 4832fa0d13
Update Swift Crypto for the Ventura beta API (#123)
* 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
2022-06-27 14:12:38 +01:00
Saleem Abdulrasool 126981ae16
Crypto: explicitly type the array slice (#122)
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>
2022-06-21 08:48:03 -07:00
Cory Benfield 57a0c7dde9
Update BoringSSL to 1f51cfc7d7f54d2bee30bb5793470ef9c36a5083 (#121) 2022-06-20 14:24:03 +01:00
swiftty 9580d7e187
Fix ASN.1 serialization when content greater than or equal to 128 bytes (#120) 2022-06-17 17:09:49 +01:00
Daiki Matsudate 03399ef465
truncating for big contentLength (#119)
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.
2022-06-16 23:44:20 -07:00
Cory Benfield d9825fa541
Update BoringSSL to f961de5c47ed265c3e758ec70dd15ece20809962 (#115)
This patch also cleans up an include issue. The actual code change is in
`scripts/vendor_boringssl.sh`, the rest is just the update.
2022-04-21 10:39:48 +01:00
Cory Benfield d180057628
Update BoringSSL to 2fc6d38391cb76839c76b2a462619e7d69fd998d (#113) 2022-04-20 03:50:13 -07:00
Cory Benfield 17d95a6782
Avoid unnecessary copies of BoringSSL (#94)
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.
2022-04-20 11:47:19 +01:00
Cory Benfield 067254c794
Update BoringSSL to 8bbefbfeee609b17622deedd100163c12f5c95dc (#110) 2022-03-22 13:43:20 +01:00
Cory Benfield a8911e0fad
Update BoringSSL to 295b31324f8c557dcd3c1c831857e33a7f23bc52 (#101) 2022-01-11 09:07:22 +00:00
Cory Benfield 9c53b7a758
Update BoringSSL to 2042972e8458833714bce23386931b1c79978439 (#97) 2021-12-09 11:12:34 +00:00
Cory Benfield bd5abc2a12
Update BoringSSL to 3a667d10e94186fd503966f5638e134fe9fb4080 (#96) 2021-11-25 17:00:52 +00:00
Cory Benfield 9b5ef28601
Update BoringSSL to a9670a8b476470e6f874fef3554e8059683e1413 (#95) 2021-11-10 09:06:17 +00:00
Cory Benfield 127d3745c3
Update BoringSSL to 25773430c07075a368416c3646fa4b07daf4968a (#91) 2021-09-08 16:17:47 +01:00
Benedek Kozma d89b2ef9ed
fix possible overindexing (#90) 2021-09-02 10:43:04 +01:00
Cory Benfield 684952cafa
Update BoringSSL to 2e68a05c9943a8dec1758d4a393b2ae906fd3295 (#88)
Also update the vendor script to pass an explicit destination
2021-08-17 09:37:33 +01:00
Cory Benfield 53da7b3706
Support compressed keys. (#87)
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.
2021-07-30 07:20:33 +01:00
Cory Benfield 22fd389195
Update to CryptoKit 2021 API (#86)
This patch adds Crypto support for new API added in CryptoKit during the
summer releases of 2021.
2021-06-09 09:51:01 +01:00
buttaface 01c3fdfb85
Fix build for 32-bit platforms (#85)
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>
2021-06-01 10:30:49 +01:00
Cory Benfield eefb07cc59
Futz around with Swift versions. (#84)
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.
2021-06-01 10:27:50 +01:00
buttaface 8b7b68753f
build: add amd64 and aarch64 assembly files to CMake build for Android (#81) 2021-05-19 14:55:27 +01:00
Cory Benfield 6c245a7f7f
Provide initial proposal for RSA signing (#80)
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.
2021-04-23 15:01:56 +01:00
Cory Benfield 3bea268b22
Update BoringSSL to 04b3213d43492b6c9e0434d8e2a4530a9938f958 (#79) 2021-03-10 14:25:25 +00:00
Yim Lee 0141f53dd5
Add ARM64 assembly files to cmake build (#78)
Motivation:
See https://github.com/apple/swift-crypto/issues/74

Modifications:
- Add ARM64 assembly files to cmake build
- Update script to handle ARM64 assembly files

Result:
Resolves https://github.com/apple/swift-crypto/issues/74

Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-03-03 09:52:54 +00:00
Yim Lee 296d3308b4
Fix typo in license header (#72) 2021-02-09 07:51:02 +00:00
Saleem Abdulrasool 8ff3d9dc83
build: explicitly include `include` in interface directories (#71)
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.
2021-02-05 18:55:23 -08:00
Saleem Abdulrasool 26d3f525eb
build: allow using a build tree of dispatch, Foundation (#67)
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>
2021-02-05 08:44:03 +00:00
Yim Lee 03581fe6ef
Setup docker for cmake build (#70)
* 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
2021-02-04 13:45:56 -08:00
Cory Benfield f9e47ba809
Update BoringSSL to bb43a45d6de7375f3310511d37f040d1055f8a10 (#66) 2021-02-04 12:31:56 +00:00
Yim Lee 47640ada33
Add CMake build files (#60)
Motivation:
This is to support https://github.com/apple/swift-package-manager/pull/3202, which adds swift-crypto as a dependency to SwiftPM.

Modifications:
Add CMake files.

Result:
Can build swift-crypto with cmake.

Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
Co-authored-by: Saleem Abdulrasool <abdulras@google.com>
2021-01-27 20:21:59 +00:00
Colin Tremblay 73dc51e2b2
fix a typo in documentation (#64)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-01-26 18:15:55 +00:00
Cory Benfield 0effb70b52
Update BoringSSL to 9dae0ac4f0ae18ebed988d36bfb4c4e4023fc574. (#54) 2020-12-02 15:44:56 +00:00
Saleem Abdulrasool 6eee6ab1d9
CCryptoBoringSSL: add Windows generated assembly (#56)
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>
2020-12-02 15:43:03 +00:00
YOCKOW 9680b7251c
Make `memset_s` consistent with Darwin. (#52)
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.
2020-10-06 10:22:50 +01:00
Cory Benfield 3c632a678e
Update BoringSSL to 67818bea6690a230e2f42e8a588e0f54949bbbf1 (#50) 2020-09-30 15:31:23 +01:00
Cory Benfield afe4c9b5f6
Update BoringSSL to 54858b63c1d886f6c8d903d4a4f594f1485de189 (#47) 2020-08-03 15:57:04 +01:00
Cory Benfield d82f7d8ce8
Update to Developer Beta 3 build. (#46) 2020-07-31 19:50:26 +01:00
Cory Benfield 794901c991
Update Swift Crypto with API from CryptoKit @ WWDC20 (#40)
Motivation:

At WWDC 2020 Apple updated the CryptoKit APIs. This PR brings those new
APIs to Swift Crypto. This brings Swift Crypto up-to-date with the
latest CryptoKit API support, including PEM/DER key support and HKDF API
extensions.

Modifications:

- Bring forward the CryptoKit API files
- Update to have API match the WWDC seed.

Result:

Users will have access to the seed APIs.
2020-06-22 21:40:34 +01:00
Johannes Weiss 82503a48ce
fix warnings in with newer Swift compilers (#37)
Motiviation:

One `let` was hiding as a `var` and a few `#file` parameters have been
forwarded to (now) `#filePath` ones.

Modification:

- make the `var` a `let`
- silence the `#file`/`#filePath` warning by adding `(#file)` because we
  can't forward them properly right now
  (https://bugs.swift.org/browse/SR-12934). That's okay because even on
  the Swift master branch, `#file` == `#filePath`.

Result:

No warnings in newer Swift compilers.
2020-06-15 13:52:24 +01:00
Cory Benfield 9b9d186860
Update BoringSSL to 53a17f55247101105ae35767d5c5a6c311843a8e (#36) 2020-06-02 09:39:37 +01:00
Cory Benfield d67ac68d09
Update BoringSSL to 5298ef99bf2b2d77600b3bb74dd572027bf495be (#31) 2020-03-17 21:06:10 +00:00
Cory Benfield 20053871fa
Mitigate Folly/BoringSSL static linking issue. (#28)
Motivation:

BoringSSL and Folly both attempt to play silly buggers with the sdallocx
symbol defined in jemalloc. Unfortunately, they don't play nicely
together, and the end result if you have both present is that BoringSSL
will reliably SIGBUS or SIGSEGV on initialization. Naturally, this isn't
good.

See also apple/swift-nio-ssl#191.

Modifications:

- Resolve the issue by patching out BoringSSL's allocator optimisation.
- Update BoringSSL to 6432bb46ab44731567ec923e6c8fc182f13d0070.

Result:

Flow and BoringSSL will play better together.
2020-02-24 16:58:54 +00:00
Alexander Cyon 64a1a98e47
Search replace "CONTRIBUTORS.txt" -> "CONTRIBUTORS.md" (#24) 2020-02-06 11:28:29 +00:00
Alexander Cyon 77b30226ac
Adding `MARK` delimiter for different curves within gyb generated files. (#19) 2020-02-06 10:22:29 +00:00
Alexander Cyon de232cbd67
Adding `gyb` discrepancy check to `sanity` script. (#13)
* 1) Adding gyb to scripts
2) Adding warning in gyb files about gyb overwritting manual edits to gyb generated swift files
3) Updated README with gyb instructions
4) Adding script for running all gyb generation
5) Adding CI check for discrepancies in gyb generated files

* Updating Dockerfile
2020-02-05 17:44:21 +00:00
Alexander Cyon 5000bef967
Cyon fix typos (#16)
* Fixing several typos

* add math/code formatting of Weierstrass equation in docs.
2020-02-04 16:00:23 +00:00
Cory Benfield 9be4a93a76 Clean up HKDF code. (#5)
The UnsafePointer constructors are best avoided, let's use scoped
pointers instead.
2020-01-20 16:34:22 +00:00