keygen

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Package keygen provides helper methods for generating, serializing, and deserializing public keys, private keys and certificates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertToPEM

func CertToPEM(cert *x509.Certificate) []byte

CertToPEM encodes an x509 certificate in PEM format.

func GenerateCA

func GenerateCA() (pk *ecdsa.PrivateKey, ca *x509.Certificate, err error)

GenerateCA returns a certificate authority for generating new certificates.

func GenerateECDSAPrivateKey

func GenerateECDSAPrivateKey() (pk *ecdsa.PrivateKey, err error)

GenerateECDSAPrivateKey returns a new ECDSA private key.

func GenerateRootCert

func GenerateRootCert(privateKey *ecdsa.PrivateKey) (cert *x509.Certificate, err error)

GenerateRootCert generates a self-signed TLS certificate to act as a CA.

func GenerateTLSCert

func GenerateTLSCert(id hotstuff.ID, hosts []string, parent *x509.Certificate, signeeKey *ecdsa.PublicKey, signerKey *ecdsa.PrivateKey) (cert *x509.Certificate, err error)

GenerateTLSCert generates a TLS certificate for the server that is valid for the given hosts.

func ParsePrivateKey

func ParsePrivateKey(buf []byte) (key consensus.PrivateKey, err error)

ParsePrivateKey parses a PEM encoded private key.

func ParsePublicKey

func ParsePublicKey(buf []byte) (key consensus.PublicKey, err error)

ParsePublicKey parses a PEM encoded public key

func PrivateKeyToPEM

func PrivateKeyToPEM(key consensus.PrivateKey) ([]byte, error)

PrivateKeyToPEM encodes the private key in PEM format.

func PublicKeyToPEM

func PublicKeyToPEM(key consensus.PublicKey) ([]byte, error)

PublicKeyToPEM encodes the public key in PEM format.

func ReadCertFile

func ReadCertFile(certFile string) (cert *x509.Certificate, err error)

ReadCertFile read an x509 certificate from a file.

func ReadPrivateKeyFile

func ReadPrivateKeyFile(keyFile string) (key consensus.PrivateKey, err error)

ReadPrivateKeyFile reads a private key from the specified file.

func ReadPublicKeyFile

func ReadPublicKeyFile(keyFile string) (key consensus.PublicKey, err error)

ReadPublicKeyFile reads a public key from the specified file.

func WriteCertFile

func WriteCertFile(cert *x509.Certificate, file string) (err error)

WriteCertFile writes an x509 certificate to a file.

func WritePrivateKeyFile

func WritePrivateKeyFile(key consensus.PrivateKey, filePath string) (err error)

WritePrivateKeyFile writes a private key to the specified file.

func WritePublicKeyFile

func WritePublicKeyFile(key consensus.PublicKey, filePath string) (err error)

WritePublicKeyFile writes a public key to the specified file.

Types

type KeyChain

type KeyChain struct {
	PrivateKey     []byte
	PublicKey      []byte
	Certificate    []byte
	CertificateKey []byte
}

KeyChain contains the keys and certificates needed by a replica, in PEM format.

func GenerateKeyChain

func GenerateKeyChain(id hotstuff.ID, validFor []string, crypto string, ca *x509.Certificate, caKey *ecdsa.PrivateKey) (KeyChain, error)

GenerateKeyChain generates keys and certificates for a replica.

Jump to

Keyboard shortcuts

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