crypto

package
v10.267.31+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeHmac256

func ComputeHmac256(tags []byte, key []byte) ([]byte, error)

ComputeHmac256 computes the HMAC256 of the message

func CreateEphemeralKey

func CreateEphemeralKey(curve func() elliptic.Curve, pub *ecdsa.PublicKey) (*ecdsa.PrivateKey, []byte)

CreateEphemeralKey creates an ephmeral private/public key based on the provided public key and the corresponding elliptic curve

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func LoadAndVerifyCertificate

func LoadAndVerifyCertificate(certPEM []byte, roots *x509.CertPool) (*x509.Certificate, error)

LoadAndVerifyCertificate parses, validates, and creates a certificate structure from a PEM buffer It must be provided with the a CertPool

func LoadAndVerifyECSecrets

func LoadAndVerifyECSecrets(keyPEM, certPEM, caCertPEM []byte) (key *ecdsa.PrivateKey, cert *x509.Certificate, rootCertPool *x509.CertPool, err error)

LoadAndVerifyECSecrets loads all the certificates and keys to memory in the right data structures

func LoadCertificate

func LoadCertificate(certPEM []byte) (*x509.Certificate, error)

LoadCertificate loads a certificate from a PEM file without verifying Should only be used for loading a root CA certificate. It will only read the first certificate

func LoadEllipticCurveKey

func LoadEllipticCurveKey(keyPEM []byte) (*ecdsa.PrivateKey, error)

LoadEllipticCurveKey parses and creates an EC key

func LoadRootCertificates

func LoadRootCertificates(rootPEM []byte) *x509.CertPool

LoadRootCertificates loads the certificates in the provide PEM buffer in a CertPool

func VerifyHmac

func VerifyHmac(tags []byte, expectedMAC []byte, key []byte) bool

VerifyHmac verifies if the HMAC of the message matches the one provided

Types

This section is empty.

Jump to

Keyboard shortcuts

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