util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MPL-2.0 Imports: 19 Imported by: 9

Documentation

Index

Constants

View Source
const (
	IntelEpc       corev1.ResourceName = "sgx.intel.com/epc"
	IntelEnclave   corev1.ResourceName = "sgx.intel.com/enclave"
	IntelProvision corev1.ResourceName = "sgx.intel.com/provision"
	AzureEpc       corev1.ResourceName = "kubernetes.azure.com/sgx_epc_mem_in_MiB"
)

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 GenerateCSR

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

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

func GenerateCert

func GenerateCert(dnsNames []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 GetEPCResourceLimit added in v0.4.0

func GetEPCResourceLimit(resourceKey string) string

GetEPCResorceLimit returns the amount of EPC to set for k8s deployments depending on the used sgx device plugin

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.

Jump to

Keyboard shortcuts

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