Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugin/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
package plugin

import (
"errors"
"fmt"
"strings"

"filippo.io/age/internal/bech32"
)

var ErrNonPluginIdentity = errors.New("not a plugin identity")

// EncodeIdentity encodes a plugin identity string for a plugin with the given
// name. If the name is invalid, it returns an empty string.
func EncodeIdentity(name string, data []byte) string {
Expand All @@ -29,7 +32,7 @@ func ParseIdentity(s string) (name string, data []byte, err error) {
return "", nil, fmt.Errorf("invalid identity encoding: %v", err)
}
if !strings.HasPrefix(hrp, "AGE-PLUGIN-") || !strings.HasSuffix(hrp, "-") {
return "", nil, fmt.Errorf("not a plugin identity: %v", err)
return "", nil, ErrNonPluginIdentity
}
name = strings.TrimSuffix(strings.TrimPrefix(hrp, "AGE-PLUGIN-"), "-")
name = strings.ToLower(name)
Expand Down
Loading