crypto

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertReaderWriter

type CertReaderWriter interface {
	fmt.Stringer
	PEMBlock() []byte
	ReadFile(path string) error
	WriteFile(path string) error
}

type KeyPair

type KeyPair struct {
	Private *PrivateKey
	Public  *PublicKey
}

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair creates a new RSA key pair

func NewKeyPair

func NewKeyPair() *KeyPair

type KeyReaderWriter

type KeyReaderWriter interface {
	fmt.Stringer
	PEMBlock() []byte
	ReadFile(path string) error
	WriteFile(path string) error
}

type PrivateKey

type PrivateKey struct {
	*rsa.PrivateKey
}

PrivateKey is a Golang structure which represents a Cryptographic key

func (*PrivateKey) PEMBlock

func (k *PrivateKey) PEMBlock() []byte

func (*PrivateKey) ReadFile

func (k *PrivateKey) ReadFile(path string) error

ReadFile loads the key from a PEM encoded file

func (*PrivateKey) String

func (k *PrivateKey) String() string

String returns a PEM encoded version of the Key

func (*PrivateKey) WriteFile

func (k *PrivateKey) WriteFile(path string) error

type PublicKey added in v0.3.0

type PublicKey struct {
	*rsa.PublicKey
}

func (PublicKey) PEMBlock added in v0.3.0

func (k PublicKey) PEMBlock() []byte

func (*PublicKey) String added in v0.3.0

func (k *PublicKey) String() string

String returns a PEM encoded version of the Key

func (*PublicKey) WriteFile added in v0.3.0

func (k *PublicKey) WriteFile(path string) error

type X509

type X509 struct {
	*x509.Certificate
}

func GenerateCA

func GenerateCA(name string, pk *PrivateKey) (*X509, error)

GenerateCA creates an X509 CA certificate

func GenerateLeaf

func GenerateLeaf(name string, ipAddresses []string, dnsNames []string, rootCert *X509, rootKey *PrivateKey, leafKey *PrivateKey) (*X509, error)

GenerateLeaf creates an X509 leaf certificate

func (*X509) PEMBlock

func (x *X509) PEMBlock() []byte

PEMBlock encodes the certificate to a PEM encoded byte array

func (*X509) ReadFile

func (x *X509) ReadFile(path string) error

ReadFile loads the key from a PEM encoded file

func (*X509) String

func (x *X509) String() string

func (*X509) WriteFile

func (x *X509) WriteFile(path string) error

WriteFile writes the Certificate to the given path

Jump to

Keyboard shortcuts

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