Skip to content

crypto/hmac: Don't check length in Equal #16336

@leonklingele

Description

@leonklingele

As crypto/hmac.Equal is relying on crypto/subtle.ConstantTimeCompare, which already checks the length of the two byte slices, we do not need such a length check in crypto/hmac.Equal.

crypto/subtle.ConstantTimeCompare: https://github.com/golang/go/blob/master/src/crypto/subtle/constant_time.go#L12
crypto/hmac.Equal: https://github.com/golang/go/blob/master/src/crypto/hmac/hmac.go#L97

I think the length check was used in crypto/hmac.Equal as it was previously not included in crypto/subtle.ConstantTimeCompare.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions