Skip to content

crypto/hmac: panics #45252

@Mr-Leshiy

Description

@Mr-Leshiy

Hello I have found a weird behaviour of the sha256 Reset() method with the hmac. So I have the following question.
Why does this example produce panics ?

sha256Hash := sha256.New()

salt := []byte{1, 2, 3}

hmac.New(func() hash.Hash {
	sha256Hash.Reset()
	return sha256Hash
}, salt)
panic: crypto/hmac: hash generation function does not produce unique values

But this example does not produce panics

salt := []byte{1, 2, 3}

hmac.New(func() hash.Hash {
	return sha256.New()
}, salt)

What is the difference between these examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions