Documentation
¶
Overview ¶
Package secure holds the node's small cryptographic helpers: random tokens, token hashing, constant-time comparison, AES-256-GCM encryption of stored credentials and HMAC signing.
Index ¶
- Variables
- func CheckPassword(hash, pw string) bool
- func DummyPasswordCheck(pw string)
- func Equal(a, b string) bool
- func HashPassword(pw string) (string, error)
- func HashToken(token string) string
- func PasswordProblem(pw string) string
- func RandomString(n int) string
- func Token(prefix string) string
- func WebhookSignature(secret, timestamp string, body []byte) string
- type Keys
Constants ¶
This section is empty.
Variables ¶
var ErrWeakPassword = errors.New("weak password")
ErrWeakPassword explains why a password is refused.
Functions ¶
func CheckPassword ¶
CheckPassword verifies pw against a hash produced by HashPassword.
func DummyPasswordCheck ¶
func DummyPasswordCheck(pw string)
DummyPasswordCheck spends the same time as a real check, so login does not reveal whether an account exists.
func HashPassword ¶
HashPassword returns a PHC-formatted argon2id hash.
func HashToken ¶
HashToken is the SHA-256 hex of a high-entropy token (sufficient for random secrets; passwords use argon2id, see password.go).
func PasswordProblem ¶
PasswordProblem returns "" when pw is acceptable, else a human reason.
func RandomString ¶
RandomString returns n random bytes encoded as unpadded base64url.
func WebhookSignature ¶
WebhookSignature computes the OBX webhook signature header value: v1=hex(HMAC-SHA256(secret, "<ts>.<raw body>")), keyed with the secret's UTF-8 bytes including the whsec_ prefix.
Types ¶
type Keys ¶
type Keys struct {
// contains filtered or unexported fields
}
Keys derives purpose-specific keys from the node secret.