security

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package security is responsible for generating keys and certificate requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptAES

func DecryptAES(key string, data []byte) ([]byte, error)

DecryptAES deciphers the data using AES-256 algorithm

func EncryptStringAES

func EncryptStringAES(key string, data []byte) ([]byte, error)

EncryptStringAES enciphers the data using AES-256 algorithm

func GenerateCertificateRequest

func GenerateCertificateRequest(country, organization, unit, mail string, key *rsa.PrivateKey) (string, error)

GenerateCertificateRequest generate a certificate request from data, and return a PEM-encoded certificate as a string

func GenerateKeys

func GenerateKeys(bits int, passphrase string) (*rsa.PrivateKey, error)

GenerateKeys generate a pair of keys and save it to the disk

func GetCertificate

func GetCertificate(filename string) (*x509.Certificate, error)

GetCertificate return the Certificate stored on the disk

func GetPrivateKey

func GetPrivateKey(filename, passphrase string) (*rsa.PrivateKey, error)

GetPrivateKey return the private key stored on the disk

func SaveCertificate

func SaveCertificate(cert, filename string) error

SaveCertificate saves a PEM-encoded certificate on disk

Types

type AuthContainer

type AuthContainer struct {
	Passphrase string

	CA   *x509.Certificate
	Cert *x509.Certificate
	Key  *rsa.PrivateKey
}

AuthContainer contains common information for TLS authentication. Files are not loaded from the beginning, call LoadFiles to load them.

func NewAuthContainer

func NewAuthContainer(passphrase string) *AuthContainer

NewAuthContainer is a shortcut to build an AuthContainer

func (*AuthContainer) LoadFiles

func (a *AuthContainer) LoadFiles() (ca *x509.Certificate, cert *x509.Certificate, key *rsa.PrivateKey, err error)

LoadFiles tries to load the required certificates and key for TLS authentication

Jump to

Keyboard shortcuts

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