Skip to content

v3: compile error (E0034) when hmac's "reset" feature is enabled #32

Description

@dobermai

I ran into a build failure with snmp2 0.5.0 — it stops compiling as soon as something else in my dependency tree turns on the reset feature of the hmac crate.

In src/v3.rs, calculate_hmac does mac.update(data) with both hmac::Mac and digest::DynDigest imported. Hmac<D> always implements Mac. With hmac/reset enabled it also picks up Reset/FixedOutputReset, which is enough to satisfy DynDigest's blanket impl — so both traits now offer update(&mut self, &[u8]) and the call is ambiguous.

Minimal repro — two dependencies, then cargo build:

[dependencies]
snmp2 = { version = "0.5", features = ["v3"] }
hmac = { version = "0.12", features = ["reset"] }
error[E0034]: multiple applicable items in scope
  --> snmp2-0.5.0/src/v3.rs:352:25
   = note: candidate #1 is defined in an impl of the trait `DynDigest` for the type `D`
   = note: candidate #2 is defined in an impl of the trait `Mac` for the type `T`

Six of these, one per HMAC variant in calculate_hmac. Without hmac/reset it builds fine, which is probably why CI hasn't caught it. The fix is just to fully-qualify the calls as Mac::update(...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions