crypto

package
v0.0.0-...-579b097 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NonceSize is the default NonceSize
	NonceSize = 24
)

Variables

View Source
var ErrPubKeyMismatch = errors.New("public keys do not match")

ErrPubKeyMismatch is used by CertificatesWithSamePublicKey to indicate the two public keys mismatch

Functions

func CertificatesWithSamePublicKey

func CertificatesWithSamePublicKey(der1, der2 []byte) error

CertificatesWithSamePublicKey returns nil if both byte slices are valid DER encoding of certificates with the same public key.

func ExpiresAt

func ExpiresAt(identityBytes []byte) time.Time

ExpiresAt returns when the given identity expires, or a zero time.Time in case we cannot determine that

func GetRandomBytes

func GetRandomBytes(len int) ([]byte, error)

GetRandomBytes returns len random looking bytes

func GetRandomNonce

func GetRandomNonce() ([]byte, error)

GetRandomNonce returns a random byte array of length NonceSize

func LogNonPubKeyMismatchErr

func LogNonPubKeyMismatchErr(log func(template string, args ...interface{}), err error, cert1DER, cert2DER []byte)

LogNonPubKeyMismatchErr logs an error which is not an ErrPubKeyMismatch error

func SanitizeIdentity

func SanitizeIdentity(identity []byte) ([]byte, error)

SanitizeIdentity sanitizes the signature scheme of the identity

func SanitizeX509Cert

func SanitizeX509Cert(initialPEM []byte) ([]byte, error)

func TrackExpiration

func TrackExpiration(tls bool, serverCert []byte, clientCertChain [][]byte, sIDBytes []byte, info MessageFunc, warn MessageFunc, now time.Time, s Scheduler)

TrackExpiration warns a week before one of the certificates expires

Types

type MessageFunc

type MessageFunc func(format string, args ...interface{})

MessageFunc notifies a message happened with the given format, and can be replaced with Warnf or Infof of a logger.

type Scheduler

type Scheduler func(d time.Duration, f func()) *time.Timer

Scheduler invokes f after d time, and can be replaced with time.AfterFunc.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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