crypto

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MinimalAllowedKeyLength = KeyLength2048Bit

Variables

This section is empty.

Functions

func CreateCert

func CreateCert(serialNumber *big.Int, validityDays int,
	keyLength KeyLength, subject CertificateSubject) ([]byte, *rsa.PrivateKey, error)

func CreateSelfsignedX509Certificate

func CreateSelfsignedX509Certificate(serialNumber *big.Int,
	validityDays int,
	rsaKeyLen KeyLength,
	subject CertificateSubject) (certificate []byte, privateKey []byte, err error)

func EncodeCertificatePEMForm

func EncodeCertificatePEMForm(certificate []byte) []byte

func EncodePEMForm

func EncodePEMForm(content []byte, typ string) []byte

func EncodeRsaKeyPEMForm

func EncodeRsaKeyPEMForm(privateKey *rsa.PrivateKey) []byte

func RandBool

func RandBool() (bool, error)

func RandCharacters

func RandCharacters(length int, capital bool) ([]byte, error)

func RandFloat

func RandFloat(max float64) float64

func RandInt16

func RandInt16(min int16, max int16) (int16, error)

func RandInt32

func RandInt32(min int32, max int32) (int32, error)

func RandInt64

func RandInt64(min int64, max int64) (int64, error)

func RandInt8

func RandInt8(min int8, max int8) (int8, error)

func RandString

func RandString(length int) (string, error)

func RandomGenerator

func RandomGenerator() (rng *rand.Rand)

Types

type CertChecker

type CertChecker struct {
	// contains filtered or unexported fields
}

func NewCustomCertChecker

func NewCustomCertChecker(rootCAs *x509.CertPool) *CertChecker

func (*CertChecker) X509CeckCertNoSAN

func (c *CertChecker) X509CeckCertNoSAN(rawCerts [][]byte,
	verifiedChains [][]*x509.Certificate) (err error)

This Certificate checker ignores the SAN and CN

type CertificateSubject

type CertificateSubject struct {
	Organisation string
	Country      string
	Province     string
	Locality     string
	OrgUnit      string
	CommonName   string
}

type KeyLength

type KeyLength int
const (
	KeyLength1024Bit KeyLength = 1024
	KeyLength2048Bit KeyLength = 2048
	KeyLength4096Bit KeyLength = 4096
	KeyLength8192Bit KeyLength = 8192
)

Jump to

Keyboard shortcuts

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