crypto

package
v0.0.0-...-822fa84 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package crypto provides utility functions for generating and handling certificates and key pairs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateIntermediateCA

func GenerateIntermediateCA(serialNumber big.Int, issuer, subject string, notBefore, notAfter time.Time, parentCrt x509.Certificate, parentPrivKey ed25519.PrivateKey) ([]byte, ed25519.PrivateKey, error)

GenerateIntermediateCA generates a new ed25519 keypair and returns a certificate signed by the provided parent.

If the generation of the keypair or the creation of the certificate fails an error is returned.

func GenerateRootCA

func GenerateRootCA(subject string) ([]byte, ed25519.PrivateKey, error)

GenerateRootCA generates a new ed25519 keypair and returns a self signed certificate and the private key.

If the generation of the keypair or the creation of the certificate fails an error is returned.

The generated certificate has the serial number '1' and is valid for 10 years.

func ReadCertificate

func ReadCertificate(r io.Reader) (*x509.Certificate, error)

ReadCertificate reads the certificate from the reader.

func ReadCertificateFile

func ReadCertificateFile(path string) (*x509.Certificate, error)

ReadCertificateFile reads the certificate from the path.

func ReadPrivateKey

func ReadPrivateKey(r io.Reader) (ed25519.PrivateKey, error)

ReadPrivateKey reads the private key from the reader.

func ReadPrivateKeyFile

func ReadPrivateKeyFile(path string) (ed25519.PrivateKey, error)

ReadPrivateKeyFile reads the private key from the path.

func WriteCertificate

func WriteCertificate(crt []byte, dst io.Writer) error

WriteCertificate pem encodes the certificate and writes it to dst.

func WriteCertificateFile

func WriteCertificateFile(crt []byte, path string) error

WriteCertificateFile pem encodes the certificate and writes it to the path.

func WritePrivateKey

func WritePrivateKey(key ed25519.PrivateKey, dst io.Writer) error

WritePrivateKey pem encodes the private key and writes it to dst.

func WritePrivateKeyFile

func WritePrivateKeyFile(key ed25519.PrivateKey, path string) error

WritePrivateKeyFile pem encodes the private key and writes it to the path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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