Documentation ¶
Overview ¶
Package cryptutil contains cryptographic utility functions.
Certificate generation code based on: go source src/crypto/tls/generate_cert.go
Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license.
Index ¶
- func DecryptString(passphrase, text string) (string, error)
- func EncryptString(passphrase, text string) (string, error)
- func GenCert(path string, certFile string, keyFile string, host string, validFrom string, ...) error
- func GenerateUUID() [16]byte
- func Md5CertFingerprint(cert *x509.Certificate) string
- func ReadX509Certs(certs []byte) ([]*x509.Certificate, error)
- func ReadX509CertsFromFile(filename string) ([]*x509.Certificate, error)
- func Sha1CertFingerprint(cert *x509.Certificate) string
- func Sha256CertFingerprint(cert *x509.Certificate) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptString ¶
DecryptString decrypts a given string using AES (cfb mode).
func EncryptString ¶
EncryptString encrypts a given string using AES (cfb mode).
func GenCert ¶
func GenCert(path string, certFile string, keyFile string, host string, validFrom string, validFor time.Duration, isCA bool, rsaBits int, ecdsaCurve string) error
GenCert generates certificate files in a given path.
path - Path to generate the certificate in. certFile - Certificate file to generate. keyFile - Key file to generate. host - Comma-separated hostnames and IPs to generate a certificate for. validFrom - Creation date formatted as Jan 1 15:04:05 2011. Default is empty string which means now. validFor - Duration that certificate is valid for. Default is 365*24*time.Hour. isCA - Flag whether this cert should be its own Certificate Authority. rsaBits - Size of RSA key to generate. Ignored if ecdsa-curve is set. Default is 2048. ecdsaCurve - ECDSA curve to use to generate a key. Valid values are P224, P256, P384, P521 or empty string (not set).
func GenerateUUID ¶
func GenerateUUID() [16]byte
GenerateUUID generates a version 4 (randomly generated) UUID according to RFC4122.
func Md5CertFingerprint ¶
func Md5CertFingerprint(cert *x509.Certificate) string
Md5CertFingerprint computes a md5 fingerprint for a certificate.
func ReadX509Certs ¶
func ReadX509Certs(certs []byte) ([]*x509.Certificate, error)
ReadX509Certs reads a list of pem encoded certificates from a byte array.
func ReadX509CertsFromFile ¶
func ReadX509CertsFromFile(filename string) ([]*x509.Certificate, error)
ReadX509CertsFromFile reads a list of pem encoded certificates from a given file.
func Sha1CertFingerprint ¶
func Sha1CertFingerprint(cert *x509.Certificate) string
Sha1CertFingerprint computes a sha1 fingerprint for a certificate.
func Sha256CertFingerprint ¶
func Sha256CertFingerprint(cert *x509.Certificate) string
Sha256CertFingerprint computes a sha256 fingerprint for a certificate.
Types ¶
This section is empty.