You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HMAC uses key to derive a state. We can keep hasher state to save redundant compute. The tradeoff is to keep calculated state. Because we always compute HMAC state by stored key, we are simply adding a parallel hasher along with credentials.
HMAC key setup does produce reusable state, but on current main the helpers are one-shot: the AWS SigV4 path derives the signing key with four HMAC-SHA256 calls and then computes the signature with a fifth, and each call creates a fresh keyed HMAC state. Signer caches the credential itself, but sign_request receives it per call; there is no keyed HMAC state to reuse. A stateful path would need a keyed-state object (or an internal cache), an owner for it, and invalidation when the credential or signing scope changes. For SigV4, the scope includes the date, region, and service.
For context, #766 reported about 20% faster sequential AWS SigV4 signing with one signer and credential by caching the derived signing key. That skips the four key-derivation HMACs on cache hits, but it does not isolate the benefit of reusing an initialized HMAC state; the signature HMAC still starts from a fresh state. The PR was closed unmerged, partly because the cache made RequestSigner stateful and coupled it to credentials.
To judge whether the extra state is worthwhile, could you share:
which signing service or workload prompted this;
how often requests reuse the same credential, and whether the signing scope (date, region, service) stays constant;
any profile or end-to-end signing measurements showing HMAC key initialization is a material cost.
On the feature check: on current main, reqsign-core has non-optional hmac, sha1, and sha2 dependencies. A build with default features disabled still includes RustCrypto, so at least one crypto backend is always compiled today. An "at least one backend" check would only be needed if those dependencies become optional.
First of all, you are right this is a micro-optimization in performance. For how SHA works, no benefits. For HMAC, I am thinking to start with the root credentials.
The other part is organization. Crypto providers provide implementation by an interface.
Agreed on the HMAC direction: the reusable part is the initialized keyed state, while a plain SHA state has no equivalent carry-over.
One clarification: what matters for reuse is a long-lived signing secret with a stable signing scope, not whether the credential is a root-account key. If there is a workload to optimize, please name one specific signer (for example AWS SigV4) and share an end-to-end signing measurement under credential and scope reuse. That would show whether the additional state is worthwhile.
For the backend and interface organization, the published CryptoProvider proposal in #961 is the right place; the provider shape and installation semantics remain open there.
Activity
Xuanwo commentedon Nov 19, 2026
HMAC key setup does produce reusable state, but on current
mainthe helpers are one-shot: the AWS SigV4 path derives the signing key with four HMAC-SHA256 calls and then computes the signature with a fifth, and each call creates a fresh keyed HMAC state.Signercaches the credential itself, butsign_requestreceives it per call; there is no keyed HMAC state to reuse. A stateful path would need a keyed-state object (or an internal cache), an owner for it, and invalidation when the credential or signing scope changes. For SigV4, the scope includes the date, region, and service.For context, #766 reported about 20% faster sequential AWS SigV4 signing with one signer and credential by caching the derived signing key. That skips the four key-derivation HMACs on cache hits, but it does not isolate the benefit of reusing an initialized HMAC state; the signature HMAC still starts from a fresh state. The PR was closed unmerged, partly because the cache made
RequestSignerstateful and coupled it to credentials.To judge whether the extra state is worthwhile, could you share:
On the feature check: on current
main,reqsign-corehas non-optionalhmac,sha1, andsha2dependencies. A build with default features disabled still includes RustCrypto, so at least one crypto backend is always compiled today. An "at least one backend" check would only be needed if those dependencies become optional.erickguan commentedon Nov 19, 2026
First of all, you are right this is a micro-optimization in performance. For how SHA works, no benefits. For HMAC, I am thinking to start with the root credentials.
The other part is organization. Crypto providers provide implementation by an interface.
Xuanwo commentedon Nov 19, 2026
Agreed on the HMAC direction: the reusable part is the initialized keyed state, while a plain SHA state has no equivalent carry-over.
One clarification: what matters for reuse is a long-lived signing secret with a stable signing scope, not whether the credential is a root-account key. If there is a workload to optimize, please name one specific signer (for example AWS SigV4) and share an end-to-end signing measurement under credential and scope reuse. That would show whether the additional state is worthwhile.
For the backend and interface organization, the published CryptoProvider proposal in #961 is the right place; the provider shape and installation semantics remain open there.