func (a *sshizzleAgent) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) {
	return a.signer.Sign(rand.Reader, data)
}
Signs a challenge required to authenticate with an SSH host
package sshizzleagent
import (
	"crypto/rand"
	"encoding/json"
	"errors"
	"io/ioutil"
	"log"
	"path/filepath"
	"time"
	"github.com/thalesgroup/sshizzle/internal/azure"
	"github.com/thalesgroup/sshizzle/internal/config"
	"golang.org/x/crypto/ssh"
	"golang.org/x/crypto/ssh/agent"
	"golang.org/x/oauth2"
)
type sshizzleAgent struct {
	signer      ssh.Signer
	certificate *ssh.Certificate
	config      *config.SSHizzleConfig
	token       *oauth2.Token
	state       string
}
func NewSSHizzleAgent(c *config.SSHizzleConfig) agent.Agent {
	token := &oauth2.Token{}
	tokenFile, err := config.GetSSHizzleTokenFile()
	if err == nil {
		data, err := ioutil.ReadFile(filepath.Clean(tokenFile))
		if err == nil {
			err = json.Unmarshal(data, token)
		}
	}
	return &sshizzleAgent{
		signer:      c.Signer,
		certificate: &ssh.Certificate{},
		config:      c,
		state:       "",
		token:       token,
	}
}
func (a *sshizzleAgent) RemoveAll() error {
	a.certificate = &ssh.Certificate{}
	a.token = &oauth2.Token{}
	return nil
}
func (a *sshizzleAgent) Remove(key ssh.PublicKey) error {
	return a.RemoveAll()
}
func (a *sshizzleAgent) List() ([]*agent.Key, error) {
	now := time.Now().Unix()
	before := int64(a.certificate.ValidBefore)
	var ids []*agent.Key
	log.Println("Agent invoked, trying to get credentials")
	if a.certificate.ValidBefore != uint64(ssh.CertTimeInfinity) && (now >= before || before < 0) {
		token, err := Authenticate(a.token, a.config.OauthConfig)
		if err != nil {
			return ids, err
		}
		a.token = token
		publicKey := a.signer.PublicKey()
		certificate, err := azure.InvokeSignFunction(&publicKey, a.config.FuncHost, a.config.OauthConfig, a.token)
		if err != nil {
			return ids, err
		}
		log.Printf("New certificate acquired with ID: %s", certificate.KeyId)
		a.certificate = certificate
	}
	ids = append(ids, &agent.Key{
		Format:  a.certificate.Type(),
		Blob:    a.certificate.Marshal(),
		Comment: a.certificate.KeyId,
	})
	return ids, nil
}