sig-auth/keydirectory/keyentry.go

34 lines
569 B
Go
Raw Normal View History

2025-02-17 19:55:53 -05:00
package keydirectory
2025-02-20 20:45:49 -05:00
import (
"crypto"
"crypto/ed25519"
"fmt"
2025-02-17 19:55:53 -05:00
2025-02-20 20:45:49 -05:00
"github.com/common-fate/httpsig/alg_ed25519"
"github.com/common-fate/httpsig/verifier"
)
type keyEntry struct {
2025-02-17 19:55:53 -05:00
Alg string
PublicKey crypto.PublicKey
UserId string
}
2025-02-20 20:45:49 -05:00
func (k keyEntry) toAlg() (verifier.Algorithm, error) {
var alg verifier.Algorithm
var err error
switch k.Alg {
case "ed25519":
alg = alg_ed25519.Ed25519{
PublicKey: k.PublicKey.(ed25519.PublicKey),
Attrs: k.UserId,
}
default:
err = fmt.Errorf("unknown algoritm: %s", k.Alg)
}
return alg, err
}