types/key: add missing ChallengePublic.UnmarshalText

Forgot it when adding the Challenge types earlier.

Change-Id: Ie0872c4e6dc25e5d832aa58c7b3f66d450bf6b71
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-10-27 10:34:07 -07:00
committed by Brad Fitzpatrick
parent 8c09ae9032
commit 4021ae6b9d
2 changed files with 22 additions and 0 deletions
+6
View File
@@ -7,6 +7,7 @@ package key
import (
"errors"
"go4.org/mem"
"tailscale.com/types/structs"
)
@@ -76,3 +77,8 @@ func (k ChallengePublic) String() string {
func (k ChallengePublic) MarshalText() ([]byte, error) {
return toHex(k.k[:], chalPublicHexPrefix), nil
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (k *ChallengePublic) UnmarshalText(b []byte) error {
return parseHex(k.k[:], mem.B(b), mem.S(chalPublicHexPrefix))
}