signify

package
v0.0.0-...-0049b06 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PassphrasePrompt = func(confirm bool) ([]byte, error) {
	fmt.Printf("Password: ")
	passphrase, err := terminal.ReadPassword(0)
	if err != nil {
		return nil, err
	}

	fmt.Println()
	if !confirm {
		return passphrase, nil
	}

	fmt.Printf("Confirm password: ")
	confirmPassphrase, err := terminal.ReadPassword(0)
	if err != nil {
		return nil, err
	}
	defer zero(&confirmPassphrase)
	fmt.Println()

	if !bytes.Equal(passphrase, confirmPassphrase) {
		return nil, errors.New("passphrases don't match")
	}

	return passphrase, nil
}

PassphrasePrompt prompts the user for a passphrase. If confirm is true, the passphrase will be confirmed.

Functions

func GenerateKey

func GenerateKey(keyPath string, passphrase []byte, opts *GenerateOptions) error

GenerateKey generates a new signify keypair under keypath.sec and keypath.pub. If passphrase is provided, the private key is encrypted. If opts is nil, a set of sane defaults is provided.

func GenerateKeypair

func GenerateKeypair(passphrase []byte, opts *GenerateOptions) (*Private, *Public, error)

GenerateKeypair returns a new private and public key.

func Sign

func Sign(privatePath, messagePath, signaturePath string) error

Sign signs the message and outputs a well-formed signify signature.

func Verify

func Verify(publicPath, messagePath, signaturePath string) error

Verify checks the signature on a message.

Types

type GenerateOptions

type GenerateOptions struct {
	Rounds int
}

GenerateOptions control the generation of private keys.

type Private

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

Private is a signify private key.

func LoadPrivateKey

func LoadPrivateKey(path string) (*Private, error)

LoadPrivateKey reads a signify private key from disk.

func (*Private) Check

func (priv *Private) Check() error

Check verifies that the key has been decrypted properly.

func (*Private) IsEncrypted

func (priv *Private) IsEncrypted() bool

IsEncrypted returns true if the key is passphrase-protected.

func (*Private) ToBox

func (priv *Private) ToBox() (*[32]byte, error)

ToBox returns a nacl/box private key.

type Public

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

Public is a Signify public key.

func LoadPublicKey

func LoadPublicKey(path string) (*Public, error)

LoadPublicKey reads a signify public key from disk.

func (*Public) ToBox

func (pub *Public) ToBox() (*[32]byte, error)

ToBox returns a nacl/box public key from this key.

type Signature

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

Signature is a signify signature.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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