Repository navigation
Conversation
erickguan
left a comment
There was a problem hiding this comment.
I like this feature.
Some requests:
- Reuse hasher. boring will allocate much less when signing again.
- Feel free to change data structure and function signatures. It can be lazy init hasher. It can be a struct.
- We validate at least reqsign compiles with at least one feature.
845cc4a to
c62ef85
Compare
|
Thanks for the review! Pushed eb4db64 (and rebased on
|
c62ef85 to
eb4db64
Compare
|
Is thread-local safe? How do you think about APIs in user ends? |
yes it's safe if the question about API means how API changes for user - nothing changes |
|
Following up on your review (#923 (review)) against the current head
Could you let us know whether these changes address the concerns from your review, especially whether the one-shot HMAC choice is acceptable? CI is green on the current head. |
|
Thanks for the work on #923. The contribution raised a concrete need to choose the hash backend for applications that use Reqsign through another library. We are discussing a process-wide provider that the application can install at startup, with RustCrypto built into reqsign-core. Please see the CryptoProvider discussion for the proposal and open API questions. |
The functions in `reqsign_core::hash` keep their API and now go through a private backend. RustCrypto stays the default. With the new `boring` feature, SHA-1, SHA-256, HMAC-SHA1 and HMAC-SHA256 use BoringSSL through the `boring` crate instead. The facade `reqsign` crate forwards the feature. Known-answer tests (the standard SHA "abc" and empty-input digests, RFC 4231 and RFC 2202 HMAC, and the AWS SigV4 signing-key example) run on both backends. CI runs the reqsign-core and reqsign-aws-v4 tests with the feature enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e63b7ae to
562a4b2
Compare
|
Hi @erickguan, what do you think of #961? If it's possible, I don't want to add a boring feature. I'm thinking of building |
Thank you @erickguan and @vovacf201! Sorry for not making this clear. I will start a PR soon and this should not block you for long. |
|
Check #970 instead |
What
Adds an opt-in
boringcargo feature toreqsign-corethat computes the SHA and HMAC inreqsign_core::hashwith BoringSSL (through theboringcrate) instead of RustCrypto.reqsign_core::hashkeeps its public API. The functions now call a privatebackendmodule, which is either RustCrypto (default, unchanged) or BoringSSL (boringfeature). Covered:hex_sha1,hex_sha256,hmac_sha256,base64_hmac_sha256,hex_hmac_sha1,hex_hmac_sha256,base64_hmac_sha1.reqsigncrate gets a matchingboringfeature that forwards toreqsign-core/boring.""and"abc", RFC 4231 test cases 1 and 6 (including a key longer than the block size), RFC 2202 test case 1, and the AWS SigV4 signing-key example from the AWS documentation.reqsign-coreandreqsign-aws-v4tests with--features reqsign-core/boring. Clippy already builds the feature through--all-features.Why
Some applications standardize all their cryptography on BoringSSL and don't want a second implementation of SHA/HMAC on the request-signing path. Today they have to fork
reqsign-coreto changehash.rs. Higher-level users such as OpenDAL build the signingContextinternally, so a runtime hook wouldn't reach them without API changes in those crates as well.A cargo feature works through feature unification. An application can add
reqsign-core = { version = "3", features = ["boring"] }as a direct dependency, and the copy used by OpenDAL (or any other dependent) switches backends with no changes in the intermediate crates.Scope and compatibility
boringcan't break a dependent that disables default features. When both are compiled,boringtakes precedence.reqsign_core::hash. That is all of the hashing and HMAC behind AWS SigV4 (reqsign-aws-v4) and the other services that call these helpers. Asymmetric signing (SigV4a ECDSA, Google/Oracle RSA, thejwtfeature, Azure client certificates) is unchanged.boringbuilds BoringSSL from source (CMake and a C/C++ toolchain) and isn't available onwasm32-unknown-unknown. The wasm-supported crates are unaffected because the feature is off by default. The CI wasm builds still pass.Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --no-fail-fast -p reqsign-core -p reqsign-aws-v4(RustCrypto): reqsign-core 45, reqsign-aws-v4 69 (+ integration test binaries), all pass.cargo test --no-fail-fast -p reqsign-core -p reqsign-aws-v4 --features reqsign-core/boring(BoringSSL): the same results.cargo build --target wasm32-unknown-unknown --no-default-features --features=aws,aws-v4a,azure,aliyun,tencent(facade): passes.🤖 Generated with Claude Code