cryptutil

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: CC0-1.0 Imports: 24 Imported by: 3

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptString

func DecryptString(passphrase, text string) (string, error)

DecryptString decrypts a given string using AES (cfb mode).

func EncryptString

func EncryptString(passphrase, text string) (string, error)

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.

Jump to

Keyboard shortcuts

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