Documentation ¶
Index ¶
- func ComputeHmac256(tags []byte, key []byte) ([]byte, error)
- func CreateEphemeralKey(curve func() elliptic.Curve, pub *ecdsa.PublicKey) (*ecdsa.PrivateKey, []byte)
- func DecodePublicKeyV1(key []byte) (*ecdsa.PublicKey, error)
- func DecodePublicKeyV2(key []byte) (*ecdsa.PublicKey, error)
- func EncodePrivateKey(privateKey *ecdsa.PrivateKey) []byte
- func EncodePublicKeyV1(publicKey *ecdsa.PublicKey) []byte
- func EncodePublicKeyV2(publicKey *ecdsa.PublicKey) []byte
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func LoadAndVerifyCertificate(certPEM []byte, roots *x509.CertPool) (*x509.Certificate, error)
- func LoadAndVerifyECSecrets(keyPEM, certPEM, caCertPEM []byte) (key *ecdsa.PrivateKey, cert *x509.Certificate, rootCertPool *x509.CertPool, ...)
- func LoadCertificate(certPEM []byte) (*x509.Certificate, error)
- func LoadEllipticCurveKey(keyPEM []byte) (*ecdsa.PrivateKey, error)
- func LoadRootCertificates(rootPEM []byte) *x509.CertPool
- func VerifyHmac(tags []byte, expectedMAC []byte, key []byte) bool
- type Nonce16Byte
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeHmac256 ¶
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 DecodePublicKeyV1 ¶
DecodePublicKeyV1 decodes the provided public key
func DecodePublicKeyV2 ¶
DecodePublicKeyV2 decodes the provided public key
func EncodePrivateKey ¶
func EncodePrivateKey(privateKey *ecdsa.PrivateKey) []byte
EncodePrivateKey encodes the private key to a byte slice.
func EncodePublicKeyV1 ¶
EncodePublicKeyV1 encodes the public key to a byte slice
func EncodePublicKeyV2 ¶
EncodePublicKeyV2 encodes the public key to a byte slice
func GenerateRandomBytes ¶
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 ¶
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 ¶
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 ¶
LoadRootCertificates loads the certificates in the provide PEM buffer in a CertPool
Types ¶
type Nonce16Byte ¶
type Nonce16Byte interface {
GenerateNonce16Bytes([]byte)
}
Nonce16Byte interface generates 16 byte nonce