pubkeyauth

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlgoRSA  = "rsa"
	AlgoNaCl = "nacl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPair

type KeyPair interface {
	ImportPublicKey(key string) error
	ImportPrivateKey(key string) error
	ExportPublicKey() (string, error)
	ExportPrivateKey() (string, error)
	PublicKeyEquals(string) bool
	Sign(sessionId string) (code string, err error)
	Verify(message, code string) error
}

type NaClKeyPair

type NaClKeyPair struct {
	// contains filtered or unexported fields
}

func NewNaClKeyPair

func NewNaClKeyPair() (*NaClKeyPair, error)

func (*NaClKeyPair) ExportPrivateKey

func (k *NaClKeyPair) ExportPrivateKey() (string, error)

func (*NaClKeyPair) ExportPublicKey

func (k *NaClKeyPair) ExportPublicKey() (string, error)

func (*NaClKeyPair) ImportPrivateKey

func (k *NaClKeyPair) ImportPrivateKey(key string) error

func (*NaClKeyPair) ImportPublicKey

func (k *NaClKeyPair) ImportPublicKey(key string) error

func (*NaClKeyPair) PublicKeyEquals

func (k *NaClKeyPair) PublicKeyEquals(key string) bool

func (*NaClKeyPair) Sign

func (k *NaClKeyPair) Sign(message string) (string, error)

func (*NaClKeyPair) Verify

func (k *NaClKeyPair) Verify(message, sig string) error

type PublicKeyAuthenticator

type PublicKeyAuthenticator struct {
	Algo       string               `json:"algo"`
	PublicKeys []string             `json:"public_keys"`
	Sessions   map[string]time.Time `json:"sessions"`
	SessionTTL int                  `json:"session_ttl"`
	// contains filtered or unexported fields
}

func NewPublicKeyAuthenticator

func NewPublicKeyAuthenticator(algo string, sessionTTL time.Duration) *PublicKeyAuthenticator

func (*PublicKeyAuthenticator) AddPublicKey

func (auth *PublicKeyAuthenticator) AddPublicKey(key string)

func (*PublicKeyAuthenticator) Authenticate

func (auth *PublicKeyAuthenticator) Authenticate(code string) error

func (*PublicKeyAuthenticator) CleanupSessions

func (auth *PublicKeyAuthenticator) CleanupSessions()

func (*PublicKeyAuthenticator) CreateSession

func (auth *PublicKeyAuthenticator) CreateSession() (string, error)

func (*PublicKeyAuthenticator) GenerateCode

func (auth *PublicKeyAuthenticator) GenerateCode(privateKey, sessionId string) (string, error)

func (*PublicKeyAuthenticator) GetAlgo

func (auth *PublicKeyAuthenticator) GetAlgo() (KeyPair, error)

func (*PublicKeyAuthenticator) IsDirty

func (auth *PublicKeyAuthenticator) IsDirty() bool

type RSAKeyPair

type RSAKeyPair struct {
	// contains filtered or unexported fields
}

func NewRSAKeyPair

func NewRSAKeyPair(bits int) (*RSAKeyPair, error)

func (*RSAKeyPair) ExportPrivateKey

func (k *RSAKeyPair) ExportPrivateKey() (string, error)

func (*RSAKeyPair) ExportPublicKey

func (k *RSAKeyPair) ExportPublicKey() (string, error)

func (*RSAKeyPair) ImportPrivateKey

func (k *RSAKeyPair) ImportPrivateKey(key string) error

func (*RSAKeyPair) ImportPublicKey

func (k *RSAKeyPair) ImportPublicKey(key string) error

func (*RSAKeyPair) PublicKeyEquals

func (k *RSAKeyPair) PublicKeyEquals(key string) bool

func (*RSAKeyPair) Sign

func (k *RSAKeyPair) Sign(message string) (string, error)

func (*RSAKeyPair) Verify

func (k *RSAKeyPair) Verify(message, sig string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL