## Motivation
We've long since used `@_implementationOnly import` (IOI) for our
vendored C modules (BoringSSL and libXKCP) in an attempt to not leak our
dependency into downstream builds. This is important because leaking
might cause symbol collisions (build failures) or, worse, layout
mismatches (latent runtime failures).
IOI was intended to be used with library evolution, which this project
does not support, and use of IOI without library evolution has been
soft-deprecated. Users are encouraged to move to `internal import` (II),
which is usually the right choice for Swift packages. But II does not
provide the same guarantees as IOI and, for this project, we really need
the protections given by IOI so we will continue to use it, even with
library evolution disabled.
One of the reasons for the soft-deprecation was the implementation of
IOI used an incomplete checker, that won't catch all interface leaks
without library evolution. However, Swift has also introduced a new
feature, `CheckImplementationOnly` (CIO), which enables the stricter
interface checking that we need, which we should adopt.
Aside: This feature is visible in 6.3 but is incomplete and the Swift
team only recommend adopting in 6.4+. Indeed, this PR is a cut-back
version of #452, which which included a lengthy patch and discussion,
boxing many types that were a result of false positives from the
`CheckImplementationOnly` feature on 6.3.
## Modifications
This patch enables `CheckImplementationOnly`, when building with 6.4, or
newer.
Additionally, as we're approaching a new major, it's a good opportunity
to get warnings-clean and lock in warnings-as-errors, so this PR does
that, suppressing only `ImplementationOnlyDeprecated`, which we cannot
eliminate. So we now build in CI using:
-Xswiftc -warnings-as-errors -Xswiftc -Wwarning -Xswiftc
ImplementationOnlyDeprecated
However, Swift 6.4 introduces `SourceWarningControl`, which we can use
to actually _silence_ these warnings, using `@diagnose(_:as:)`, which we
do conditionally:
#if hasFeature(SourceWarningControl)
@diagnose(ImplementationOnlyDeprecated, as: ignored)
@_implementationOnly import ...
#else
@_implementationOnly import ...
#endif
When we raise the minimum supported Swift compiler version to one that
supports `SourceWarningControl`, we can remove the `#if hasFeature`
guards.
We've had to drop to `--build-system native` (vs swift-build) for Swift
6.4 CI because SwiftPM is not stripping the warning-related compiler
flags when building dependencies.
## Result
- Stricter checks for not leakingC dependencies from BoringSSL and
libXKCP -- project builds cleanly with `CheckImplementationOnly`.
- All other compiler warnings have been addressed and project builds
with `-warnings-as-errors -Wwarning ImplementationOnlyDeprecated` in CI.
- On Swift 6.4+, `ImplementationOnlyDeprecated` warnings are completely
silenced and the project is completely warnings-free.
Add SHA-512/256 digest implementation via BoringSSL
### Checklist
- [x] I've run tests to see all new and existing tests pass
- [x] I've followed the code style of the rest of the project
- [x] I've read the [Contribution Guidelines](CONTRIBUTING.md)
- [x] I've updated the documentation if necessary
#### If you've made changes to `gyb` files
- [N/A] I've run `.script/generate_boilerplate_files_with_gyb` and
included updated generated files in a commit of this pull request
### Motivation:
Neither CryptoKit nor swift-crypto currently explore the SHA-512/256
hashing function. SHA-512/256 provides the same 256-bit security level
as SHA-256 but can be significantly faster on 64-bit platforms because
it uses the SHA-512 internal structure, which operates on 64-bit words.
### Modifications:
We modified CryptoExtras to include support using the BoringSSL
implementation.
### Result:
Swift ecosystem supports SHA-512/256.
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>