Пример #1
0
func generateECDSAKey(t *testing.T) *ecdsa.PrivateKey {
	privateKey, err := keys.GenerateECDSA()
	if err != nil {
		t.Errorf("failed to generate a key")
	}
	return privateKey
}
Пример #2
0
func (srv *KeyService) GeneratePrivateKey(r *http.Request, args *GeneratePrivateKeyArgs, reply *GeneratePrivateKeyReply) error {
	key, err := keys.GenerateECDSA()
	if err != nil {
		reply.Success = false
		return err
	}
	err = env.DB.PutKey(args.Alias, key, false)
	if err != nil {
		reply.Success = false
		return err
	}
	reply.PublicKey = keys.ECDSAPublicKeyToString(key.PublicKey)
	reply.Success = true
	return nil
}
Пример #3
0
func newKeyAuth() (ka *KeyAuth, e error) {
	pk, e := keys.GenerateECDSA()
	ka = &KeyAuth{key: pk}
	return
}