Skip to content

feat(core): implement CryptoProvider for Arc<T> - #1073

Merged
Xuanwo merged 2 commits into
mainfrom
xuanwo/arc-crypto-provider-forwarding
Nov 25, 2026
Merged

Xuanwo merged 2 commits into
mainfrom
xuanwo/arc-crypto-provider-forwarding

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 25, 2026

Copy link
Copy Markdown
Member

Summary

CryptoProvider now has a blanket implementation for Arc<T> where T: CryptoProvider + ?Sized. A caller that already holds an Arc<dyn CryptoProvider> can pass it directly to the existing Context::with_crypto and crypto::install_default entry points instead of maintaining a forwarding newtype.

There are no with_crypto_arc or install_default_arc APIs. The process-wide installation policy is unchanged. Docs state the shared-Arc path; release and migration notes are intentionally not part of this PR.

Coverage

The forwarding impl overrides all ten CryptoProvider methods, including the defaulted optional methods, and preserves arguments, return values, the mutable fill_random buffer, and provider errors.

  • #[deny(clippy::missing_trait_methods)] is scoped to the Arc impl. The lint is allow-by-default upstream; this scoped deny makes a newly added defaulted trait method fail the existing cargo clippy --workspace --all-targets --all-features -- -D warnings gate unless the Arc impl forwards it. The lint exists on the 1.87 MSRV and current stable.
  • A runtime marker provider exercises all ten methods through P = Arc<dyn CryptoProvider> (generic dispatch, not autoderef), so an omitted current optional method or a stub fails behaviorally as well as through clippy. A separate integration-test binary covers install_default(Arc<dyn CryptoProvider>) without leaking global state into other tests; Context::with_crypto(Arc<dyn CryptoProvider>) is covered in the main Arc test binary.
  • Temporary probes verified the split: omitting md5 produced missing trait method provided by default: md5 and a runtime error mismatch; adding a default probe method produced missing trait method provided by default: probe; stubbing sha256 failed the runtime test. All probes were reverted.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo +1.87.0 clippy -p reqsign-core --lib --all-features -- -D warnings
  • cargo test --no-fail-fast
  • cargo test -p reqsign-core --no-fail-fast
  • cargo check -p reqsign-core --target wasm32-unknown-unknown
  • cargo check --manifest-path crypto/boring/Cargo.toml
  • RUSTDOCFLAGS="--cfg docsrs" cargo +nightly test --doc --all-features --workspace

No workflow or test suppression is added; Azure live checks remain enabled.

Closes #1068.

Forward every CryptoProvider operation through Arc<T>, including optional methods, so callers can pass an existing Arc<dyn CryptoProvider> to Context::with_crypto and crypto::install_default without a wrapper.

Add runtime marker coverage and a source audit that keeps the forwarding impl in sync with the trait as optional methods are added.

Refs #1068.
Scope clippy::missing_trait_methods to the Arc<T> CryptoProvider impl so any new defaulted trait method fails the existing clippy CI gate unless the Arc impl forwards it.

Remove the formatting-sensitive source audit and keep a compact runtime marker regression covering all ten methods, argument forwarding, the mutable random buffer, and the original error.

Refs #1068.
@Xuanwo
Xuanwo merged commit 7749c08 into main Nov 25, 2026
64 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/arc-crypto-provider-forwarding branch November 25, 2026 18:15
Xuanwo added a commit that referenced this pull request Nov 25, 2026
## Summary

- Add selectable `rsa`, `p256`, and `aes-gcm` features to
`reqsign-crypto-rustcrypto`, all enabled by default. MD5, SHA-1,
SHA-256, HMAC-SHA-1/256/512, and HMAC-SHA512 stay unconditional.
- Disabled operations return `ConfigInvalid` naming the missing feature,
including secure randomness. RSA, AES-GCM, and randomness remain
unsupported on `wasm32-unknown-unknown` when enabled; P-256 stays
available.
- The facade exposes no algorithm features. `default-crypto` depends on
the backend with `default-features = false`; service features weakly
select only what they need: `aws-v4a` -> `p256`; `azure`, `google`,
`oracle`, and `http-message-signatures` -> `rsa`. A service feature
alone does not pull the backend.
- Remove the facade `google-credential-access-boundary-client-side`
feature. Client-side CAB is now opt-in through
`reqsign-google/credential-access-boundary-client-side` with a provider
supporting AES-GCM and secure randomness, plus an `HttpSend` transport
for STS. If a graph also enables facade `google`, Cargo feature
unification can expose the type through facade re-exports; that is not a
facade feature.
- The 0.21 release notes cover both this feature selection and the
merged `Arc<T>` forwarding for `CryptoProvider` (#1068).

## Google client-side CAB migration

- First acquisition or refresh of intermediary credentials goes to STS.
A valid cached intermediary enables local issuance of downscoped tokens.
- The rustdoc example is runnable and uses a mock STS transport with the
public `Granter::grant(None)` path. Only the `aes-gcm` backend feature
is required; the example uses a public test vector, not credentials.
- The upgrade guide, service README, and facade docs describe the facade
feature removal, direct service opt-in, the Cargo-unification re-export
caveat, and the AES-GCM/secure-randomness plus `HttpSend` requirements.

## CI coverage

- Backend feature matrix: default, no-default, each algorithm alone, and
all three together, including missing-feature diagnostics.
- All 25 facade service features plus the `full` aggregate are built and
behavior-tested in isolated downstream Cargo invocations. Probes
exercise actual RSA, P-256, AES-GCM, randomness, hash, and HMAC
operations, and verify a service feature alone does not pull the
backend.
- A shared service table drives both the weak-mapping static check and
the actual-operation oracle. `full` is validated by resolved feature
expansion; deleting `vercel` from `full` fails with `full does not
enable service features: ['vercel']`.
- Existing crypto dependency-boundary and website provider-catalog
checks remain.

## Verification

- `cargo fmt --all -- --check`
- `cargo clippy --workspace --all-targets --all-features -- -D warnings`
- `cargo test --workspace --no-fail-fast`
- `cargo test --doc --all-features --workspace`
- `cargo test -p reqsign-google --features
credential-access-boundary-client-side --lib --tests`
- `python3 .github/scripts/check_crypto_features.py`
- `python3 .github/scripts/test_facade_features.py`
- `node website/scripts/validate-providers.mjs`
- Release plan: 32 packages. Workspace publish dry run: 31 staged
uploads / 31 dry-run aborts. Standalone `reqsign-crypto-boring`
packaging: 12 files, 4 staged local dependencies normalized without
paths.
- Integrated tree equals the #1073 merge-tree before the additive
release-note and review-fix commits; the original candidate patch-id is
preserved.

Part of #1069.

## Downstream follow-up

SMB lock resolution is downstream and is not claimed here. After the
actual 0.21 release, the maintainers will open and then notify the
dedicated OpenDAL issue for the SMB lockfile path. This PR does not edit
OpenDAL or notify it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement CryptoProvider for Arc<T> in reqsign-core

2 participants