예제 #1
0
// New returns a new protocol client
func New(keyBackends []types.Backend) (*Client, error) {
	var err error
	c := new(Client)
	c.Curve = eccutil.SetCurve(Curve, Rand, HashFunc)
	c.Keypool = keypool.New(signkeys.New(Curve, Rand, HashFunc))
	for _, v := range keyBackends {
		if v.Type == "keydir" {
			err = keydir.Add(c.Keypool, v.Value.(string))
		} else if v.Type == "database" {
			err = keydb.Add(c.Keypool, v.Value)
		}
		if err != nil {
			return nil, err
		}
	}
	return c, nil
}
예제 #2
0
파일: keys.go 프로젝트: JonathanLogan/mute
// New returns a new key generator. The Usage and URL of the generator must be
// explicitely set.
func New(curve func() elliptic.Curve, rand io.Reader, hash func([]byte) []byte) *KeyGenerator {
	kg := new(KeyGenerator)
	kg.Curve = eccutil.SetCurve(curve, rand, hash)
	kg.ExpireTime = DefaultExpireTime
	return kg
}