2021-05-04 22:06:05 +00:00
|
|
|
package oidc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/subtle"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Compare compares the hash with the data and returns an error if they don't match.
|
2022-04-07 05:33:53 +00:00
|
|
|
func (h PlainTextHasher) Compare(_ context.Context, hash, data []byte) (err error) {
|
2021-05-04 22:06:05 +00:00
|
|
|
if subtle.ConstantTimeCompare(hash, data) == 0 {
|
|
|
|
return errPasswordsDoNotMatch
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hash creates a new hash from data.
|
2022-04-07 05:33:53 +00:00
|
|
|
func (h PlainTextHasher) Hash(_ context.Context, data []byte) (hash []byte, err error) {
|
2021-05-04 22:06:05 +00:00
|
|
|
return data, nil
|
|
|
|
}
|