util

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MPL-2.0 Imports: 18 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCertificateIPAddresses = []net.IP{net.IPv4(127, 0, 0, 1), net.IPv6loopback}

DefaultCertificateIPAddresses defines a placeholder value used for automated x509 certificate generation.

Functions

func DecryptOAEP added in v0.3.0

func DecryptOAEP(priv *rsa.PrivateKey, ciphertext []byte) ([]byte, error)

DecryptOAEP is a wrapper function for rsa.DecryptOAEP for a nicer syntax.

func DeriveKey

func DeriveKey(secret, salt []byte, length uint) ([]byte, error)

DeriveKey derives a key from a secret.

func EncryptOAEP added in v0.3.0

func EncryptOAEP(pub *rsa.PublicKey, plaintext []byte) ([]byte, error)

EncryptOAEP is a wrapper function for rsa.EncryptOAEP for a nicer syntax.

func ExtractIPsFromAltNames added in v1.4.0

func ExtractIPsFromAltNames(subjAltNames []string) ([]net.IP, []string)

ExtractIPsFromAltNames extracts IP addresses and DNS names from a list of subject alternative names.

func GenerateCSR

func GenerateCSR(subjAltNames []string, privk *ecdsa.PrivateKey) (*x509.CertificateRequest, error)

GenerateCSR generates a new CSR for the given DNSNames and private key.

func GenerateCert

func GenerateCert(subjAltNames []string, ipAddrs []net.IP, isCA bool) (*x509.Certificate, *ecdsa.PrivateKey, error)

GenerateCert generates a new self-signed certificate associated key-pair.

func GenerateCertificateSerialNumber

func GenerateCertificateSerialNumber() (*big.Int, error)

GenerateCertificateSerialNumber generates a random serial number for an X.509 certificate.

func Getenv added in v0.3.1

func Getenv(name string, fallback string) string

Getenv returns the environment variable `name` if it exists or the handed fallback value elsewise.

func LoadGRPCTLSCredentials

func LoadGRPCTLSCredentials(cert *x509.Certificate, privk *ecdsa.PrivateKey, insecureSkipVerify bool) (credentials.TransportCredentials, error)

LoadGRPCTLSCredentials returns a TLS configuration based on cert and privk.

func MustGenerateTestMarbleCredentials

func MustGenerateTestMarbleCredentials() (cert *x509.Certificate, csrRaw []byte, privk *ecdsa.PrivateKey)

MustGenerateTestMarbleCredentials returns dummy Marble TLS credentials for testing.

func MustGetLocalListenerAndAddr

func MustGetLocalListenerAndAddr() (net.Listener, string)

MustGetLocalListenerAndAddr returns a TCP listener on a system-chosen port on localhost and its address.

func MustGetenv

func MustGetenv(name string) string

MustGetenv returns the environment variable `name` if it exists or panics otherwise.

func MustGetwd added in v0.3.1

func MustGetwd() string

MustGetwd returns the current working directory and panics if it cannot be dcetermined.

func TLSCertFromDER

func TLSCertFromDER(certDER []byte, privk interface{}) *tls.Certificate

TLSCertFromDER converts a DER certificate to a TLS certificate.

func XORBytes added in v0.3.0

func XORBytes(a, b []byte) ([]byte, error)

XORBytes XORs two byte slices.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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