encryption

package
v0.0.0-...-120a5a4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCertificate

func CreateCertificate(key *ed25519.PrivateKey, hostnames []string, expire time.Duration) (tls.Certificate, error)

createCertificate is responsible for creating a certificate.

func DecodeText

func DecodeText(state, key string) (string, error)

decodeText decodes the session state cookie value.

func DecryptDataBlock

func DecryptDataBlock(cipherText, key []byte) ([]byte, error)

decryptDataBlock decrypts some cipher text.

func EncodeText

func EncodeText(plaintext string, key string) (string, error)

encodeText encodes the session state information into a value for a cookie to consume.

func EncryptDataBlock

func EncryptDataBlock(plaintext, key []byte) ([]byte, error)

encryptDataBlock encrypts the plaintext string with the key.

func LoadCert

func LoadCert(certPath string) (*x509.CertPool, error)

func LoadKeyPair

func LoadKeyPair(certPath, keyPath string) (*tls.Certificate, error)

loadKeyPair loads the tls key pair.

Types

type CertificationRotation

type CertificationRotation struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCertificateRotator

func NewCertificateRotator(
	cert,
	key string,
	log *zap.Logger,
	metric *prometheus.Counter,
) (*CertificationRotation, error)

newCertificateRotator creates a new certificate.

func (*CertificationRotation) GetCertificate

func (c *CertificationRotation) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate is responsible for retrieving.

func (*CertificationRotation) StoreCertificate

func (c *CertificationRotation) StoreCertificate(certifacte tls.Certificate) error

StoreCertificate provides entrypoint to update the certificate.

func (*CertificationRotation) Watch

func (c *CertificationRotation) Watch() error

watch is responsible for adding a file notification and watch on the files for changes.

type SelfSignedCertificate

type SelfSignedCertificate struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSelfSignedCertificate

func NewSelfSignedCertificate(
	hostnames []string,
	expiry time.Duration,
	log *zap.Logger,
) (*SelfSignedCertificate, error)

newSelfSignedCertificate creates and returns a self signed certificate manager.

func (*SelfSignedCertificate) GetCertificate

func (c *SelfSignedCertificate) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate is responsible for retrieving.

Jump to

Keyboard shortcuts

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