Documentation
¶
Index ¶
- Constants
- func AESGCMDecrypt(key, data []byte) ([]byte, error)
- func AESGCMDecryptWithNonce(key, nonce, data []byte) ([]byte, error)
- func AESGCMEncrypt(key, data []byte) ([]byte, error)
- func AESGCMEncryptWithSalt(key, salt, data []byte) ([]byte, error)
- func GenerateCACertificate(t *CertificateTemplate) (*x509.Certificate, error)
- func GenerateServiceCertificate(t *CertificateTemplate) (*x509.Certificate, error)
- func GenerateVerificationCode(max int) (string, error)
- func LoadCertificate(file string) (*x509.Certificate, error)
- func LoadPrivateKey(password []byte, file string) (crypto.PrivateKey, error)
- func NewPassword(length int) string
- func PEMDecodeCertificate(pemBytes []byte) (*x509.Certificate, error)
- func PEMDecodePublicKey(pemBytes []byte) (interface{}, string, error)
- func PEMEncodeCertificate(cert *x509.Certificate) ([]byte, error)
- func PEMEncodeKey(key crypto.PrivateKey) ([]byte, error)
- func PEMEncodePublicKey(k crypto.PublicKey) ([]byte, error)
- func RandomCode(max int) (string, error)
- func Reveal(phrase string, info *Info) ([]byte, error)
- func StoreCertificate(cert *x509.Certificate, file string, perm os.FileMode) error
- func StorePrivateKey(key crypto.PrivateKey, password []byte, file string) error
- type AESGCMDecryptWrapper
- type AESGCMEncryptWrapper
- type CertificateTemplate
- type Info
- type ReadOption
- type ReaderWrapper
- type WriterWrapper
Constants ¶
View Source
const (
AESGCMNonceSize = 12
)
View Source
const (
// PBKDF2Iterations set to 10 000 which is the acceptable number of pbkdf2 iterations for year 2020
PBKDF2Iterations = 10000
)
Variables ¶
This section is empty.
Functions ¶
func AESGCMDecrypt ¶
func AESGCMDecryptWithNonce ¶
func AESGCMEncrypt ¶
func AESGCMEncryptWithSalt ¶
func GenerateCACertificate ¶
func GenerateCACertificate(t *CertificateTemplate) (*x509.Certificate, error)
GenerateCACertificate generates a certificate for a CA
func GenerateServiceCertificate ¶
func GenerateServiceCertificate(t *CertificateTemplate) (*x509.Certificate, error)
GenerateServiceCertificate generates a certificate for a service
func LoadCertificate ¶
func LoadCertificate(file string) (*x509.Certificate, error)
LoadCertificate load file and decode it into a x509.Certificate
func LoadPrivateKey ¶
func LoadPrivateKey(password []byte, file string) (crypto.PrivateKey, error)
LoadPrivateKey load encrypted private key from "file" and decrypts it
func NewPassword ¶
func PEMDecodeCertificate ¶
func PEMDecodeCertificate(pemBytes []byte) (*x509.Certificate, error)
PEMDecodeCertificate creates certificate from pem bytes
func PEMDecodePublicKey ¶
func PEMEncodeCertificate ¶
func PEMEncodeCertificate(cert *x509.Certificate) ([]byte, error)
PEMEncodeCertificate encodes certificate chain into pem file
func PEMEncodeKey ¶
func PEMEncodeKey(key crypto.PrivateKey) ([]byte, error)
func RandomCode ¶
func StoreCertificate ¶
StoreCertificate encode certificate and store the result in "file"
func StorePrivateKey ¶
func StorePrivateKey(key crypto.PrivateKey, password []byte, file string) error
StorePrivateKey encrypts the private key and save it in "file"
Types ¶
type AESGCMDecryptWrapper ¶
type AESGCMDecryptWrapper struct {
// contains filtered or unexported fields
}
func NewDecryptWrapper ¶
func NewDecryptWrapper(key []byte, opts ...ReadOption) *AESGCMDecryptWrapper
type AESGCMEncryptWrapper ¶
type AESGCMEncryptWrapper struct {
// contains filtered or unexported fields
}
func NewEncryptWrapper ¶
func NewEncryptWrapper(key []byte, opts ...ReadOption) *AESGCMEncryptWrapper
func (*AESGCMEncryptWrapper) WithOutputSize ¶
func (d *AESGCMEncryptWrapper) WithOutputSize(inputSize int64) int64
type CertificateTemplate ¶
type CertificateTemplate struct {
Organization string
Name string
Domains []string
IPs []net.IP
Expiry time.Duration
PublicKey crypto.PublicKey
SignerPrivateKey crypto.PrivateKey
SignerCertificate *x509.Certificate
}
CertificateTemplate specs for generating a certificate
type Info ¶
type Info struct {
Iterations int `json:"iterations"`
Salt string `json:"salt"`
Length int `json:"length"`
Hash string `json:"hash"`
Alg string `json:"alg"`
EncryptedKey string `json:"encrypted_key"`
}
Info about encrypted key parameter
type ReadOption ¶
type ReadOption func(*readOptions)
func WithBlockSize ¶
func WithBlockSize(size int64) ReadOption
func WithLimit ¶
func WithLimit(limit int64) ReadOption
func WithOffset ¶
func WithOffset(offset int64) ReadOption
Click to show internal directories.
Click to hide internal directories.