key

package
v0.0.0-...-c372385 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PEMPublicKey is the PEM encoding type for secrets public keys
	PEMPublicKey = "SECRETS PUBLIC KEY"
	// PEMPrivateKey is the PEM encoding type for secrets private keys
	PEMPrivateKey = "SECRETS PRIVATE KEY"
)

Variables

View Source
var (
	// OIDPublicKey is the ASN.1 object identifier for secrets public keys
	OIDPublicKey = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 27266, 11, 17, 1}
	// OIDPrivateKey is the ASN.1 object identifier for secrets private keys
	OIDPrivateKey = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 27266, 11, 17, 2}
)

Functions

func LoadPEMBlock

func LoadPEMBlock(file, kind string, v interface{}) (err error)

LoadPEMBlock loads a PEM block from a file.

func ParsePEMBlock

func ParsePEMBlock(data []byte, kind string, v interface{}) (err error)

ParsePEMBlock parsea a PEM block from a byte slice.

Types

type Key

type Key struct {
	ID         asn1.ObjectIdentifier
	PublicKey  []byte
	PrivateKey []byte `asn1:"omitempty"`
}

Key is a NaCL box key

func Load

func Load(file string) (*Key, error)

Load loads a NaCL box key from PEM file.

func LoadPrivateKey

func LoadPrivateKey(file string) (*Key, error)

LoadPrivateKey loads a NaCL box key pair PEM file.

func LoadPublicKey

func LoadPublicKey(file string) (*Key, error)

LoadPublicKey loads a NaCL box public key PEM file.

func NewPrivateKey

func NewPrivateKey() (key *Key, err error)

NewPrivateKey generates a new NaCL box key pair.

func Parse

func Parse(data []byte) (key *Key, err error)

Parse parses any NaCL box key from a PEM blob.

func ParsePublicKey

func ParsePublicKey(data []byte) *Key

ParsePublicKey parses a NaCL box public key byte slice. TODO: error checking

func (*Key) AsPublicKey

func (key *Key) AsPublicKey() *Key

AsPublicKey returns only the private part of the key.

func (*Key) BoxPrivateKey

func (key *Key) BoxPrivateKey() *[keySize]byte

BoxPrivateKey returns the public key in NaCL box usable format

func (*Key) BoxPublicKey

func (key *Key) BoxPublicKey() *[keySize]byte

BoxPublicKey returns the public key in NaCL box usable format

func (*Key) Decrypt

func (key *Key) Decrypt(in []byte, nonce *[24]byte, peer *Key) ([]byte, bool)

Decrypt decrypts a NaCL box message from a public key

func (*Key) Encrypt

func (key *Key) Encrypt(message []byte, nonce *[24]byte, peer *Key) []byte

Encrypt encrypts a message using a NaCL box to a public key

func (*Key) IsPrivate

func (key *Key) IsPrivate() bool

IsPrivate returns true if the key is a private key

func (*Key) IsPublic

func (key *Key) IsPublic() bool

IsPublic returns true if the key is a public key

func (*Key) Marshal

func (key *Key) Marshal() (out []byte, err error)

Marshal converts the key to PEM format.

func (*Key) Save

func (key *Key) Save(file string) (err error)

Save writes the key to disk in PEM format.

Jump to

Keyboard shortcuts

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