license

package module
v0.0.0-...-88c4800 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

License prototype

Godoc

TODO

  • add support for offline validation. This can be done by just communicating the signature.
  • add authentication to the API

Documentation

Index

Constants

View Source
const (
	// TimeFormat is the time format we use for licenses.  Also note
	// that we always use the UTC form of dates.
	TimeFormat = time.RFC3339
)

Variables

View Source
var (
	// ErrUnableToVerifyCreatedSignature indicates that we failed to verify a
	// signature we just created with Sign(). Most likely due to mismatched
	// public and private key.
	ErrUnableToVerifyCreatedSignature = errors.New("mismatched public and private key")

	// ErrFailedToVerifySignature indicates that Verify() failed to verify the signature.
	ErrFailedToVerifySignature = errors.New("failed to verify signature")

	// ErrLicenseExpired indicates that the license is expired.
	ErrLicenseExpired = errors.New("license is expired")

	// ErrFailedToParseExpiryDate indicates that the expiry date is not formatted properly.
	// It should be formatted according to RFC3339.
	ErrFailedToParseExpiryDate = errors.New("failed to parse expiry date")
)

Functions

func FromJSON

func FromJSON(jsonBytes []byte) (*lic.License, error)

FromJSON reads a license from JSON

func Sign

func Sign(privkey ed25519.PrivateKey, pubkey ed25519.PublicKey, license *lic.License) (*lic.SignedLicense, error)

Sign a license key to produce a SignedLicense.

func SignedLicenseFromJSON

func SignedLicenseFromJSON(jsonBytes []byte) (*lic.SignedLicense, error)

SignedLicenseFromJSON reads a license from JSON

func SignedLicenseToJSON

func SignedLicenseToJSON(signedLicense *lic.SignedLicense) ([]byte, error)

SignedLicenseToJSON returns a signed license as JSON

func ToJSON

func ToJSON(license *lic.License) ([]byte, error)

ToJSON returns a license as JSON

func Verify

func Verify(pubkey ed25519.PublicKey, signedLicense *lic.SignedLicense) error

Verify signed license. If the error returned is nil, it means the verification was successful.

Types

type KeyPair

type KeyPair struct {
	Public  ed25519.PublicKey
	Private ed25519.PrivateKey
}

KeyPair represents an ed25519 keypair.

func MakeKeypair

func MakeKeypair() (KeyPair, error)

MakeKeypair creates an ed25519 keypair.

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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