sig-auth/keydirectory/keyentry.go

33 lines
569 B
Go

package keydirectory
import (
"crypto"
"crypto/ed25519"
"fmt"
"github.com/common-fate/httpsig/alg_ed25519"
"github.com/common-fate/httpsig/verifier"
)
type keyEntry struct {
Alg string
PublicKey crypto.PublicKey
UserId string
}
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
}