keys

package
v0.0.0-...-56cd1df Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrType indicates an invalid option for a key (Public/Private)
	ErrType = errors.New("Invalid key type")
	// ErrConvert indicates that the key could not be converted to bytes
	ErrConvert = errors.New("Cannot convert key to bytes")
)

Functions

func EncodeRsaDer

func EncodeRsaDer(keytype Type, key *rsa.PrivateKey) ([]byte, error)

EncodeRsaDer encodes an RSA key into a slice of DER bytes

func EncodeRsaPem

func EncodeRsaPem(keytype Type, key *rsa.PrivateKey) ([]byte, error)

EncodeRsaPem encodes an RSA key into a slice of PEM bytes

func GenerateRsaKey

func GenerateRsaKey(keysize int) (*rsa.PrivateKey, error)

GenerateRsaKey is a wrapper function around rsa.GenerateKey function.

func ParsePemFile

func ParsePemFile(filepath string) ([]*pem.Block, error)

ParsePemFile reads and marshals a key from an io.Reader

func StoreRsaDer

func StoreRsaDer(keytype Type, key *rsa.PrivateKey, filepath string, perm os.FileMode) error

StoreRsaDer writes a RSA key in DER byte format to file.

func StoreRsaPem

func StoreRsaPem(keytype Type, key *rsa.PrivateKey, filepath string, perm os.FileMode) error

StoreRsaPem writes RSA keys to file in PEM format

Types

type Type

type Type int8

Type is either Public or Private, for public and private keys.

const (
	// Private key
	Private Type = iota
	// Public key
	Public
)

Jump to

Keyboard shortcuts

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