x509

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package crypto collects common cryptographic constants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitX509

func InitX509(algo string) error

func RegisterHash

func RegisterHash(h Hash, size uint8, f func() hash.Hash)

RegisterHash registers a function that returns a new instance of the given hash function. This is intended to be called from the init function in packages that implement hash functions.

Types

type AlgoCapacity

type AlgoCapacity interface {
	// contains filtered or unexported methods
}

type Context

type Context interface {
	// ParsePKIXPublicKey parses a public key in PKIX, ASN.1 DER form.
	//
	// It returns a *rsa.PublicKey, *dsa.PublicKey, *ecdsa.PublicKey,
	// ed25519.PublicKey or *sm.PublicKey. More types might be supported in the future.
	//
	// This kind of key is commonly encoded in PEM blocks of type "PUBLIC KEY".
	ParsePKIXPublicKey(derBytes []byte) (pub interface{}, err error)

	// MarshalPKIXPublicKey converts a public key to PKIX, ASN.1 DER form.
	//
	// The following key types are currently supported: *rsa.PublicKey, *ecdsa.PublicKey,
	// ed25519.PublicKey and *sm2.PublicKey. Unsupported key types result in an error.
	//
	// This kind of key is commonly encoded in PEM blocks of type "PUBLIC KEY".
	MarshalPKIXPublicKey(pub interface{}) ([]byte, error)

	// CreateCertificateRequest creates a new certificate request based on a template.
	CreateCertificateRequest(rand io.Reader, template *x.CertificateRequest, priv interface{}) (csr []byte, err error)

	// ParseCertificateRequest parses a single certificate request from the
	// given ASN.1 DER data.
	ParseCertificateRequest(asn1Data []byte) (*x.CertificateRequest, error)

	// CheckCertificateRequestSignature reports whether the signature on c is valid.
	CheckCertificateRequestSignature(c *x.CertificateRequest) error

	// CreateCertificate creates a new X.509v3 certificate based on a template.
	CreateCertificate(rand io.Reader, template, parent *x.Certificate, pub, priv interface{}) (cert []byte, err error)

	// ParseCertificate parses a single certificate from the given ASN.1 DER data.
	ParseCertificate(asn1Data []byte) (*x.Certificate, error)

	ParseCertificates(asn1Data []byte) ([]*x.Certificate, error)
	// CheckCertSignature verifies that signature is a valid signature over signed from
	// cert's public key.
	CheckCertSignature(cert *x.Certificate, algo x.SignatureAlgorithm, signed, signature []byte) error

	// CheckCertSignatureFrom verifies that the signature on cert is a valid signature
	// from parent.
	CheckCertSignatureFrom(cert *x.Certificate, parent *x.Certificate) error

	// WARNING: this function doesn't do any revocation checking.
	Verify(c *x.Certificate, opts x.VerifyOptions) (chains [][]*x.Certificate, err error)

	CheckCRLSignature(cert *x.Certificate, crl *pkix.CertificateList) error

	// CreateCRL returns a DER encoded CRL, signed by this Certificate, that
	// contains the given list of revoked certificates.
	CreateCRL(cert *x.Certificate, rand io.Reader, priv interface{}, revokedCerts []pkix.RevokedCertificate, now, expiry time.Time) (crlBytes []byte, err error)
}
var X509Instance Context

func GetX509

func GetX509() Context

type Hash

type Hash uint

Hash identifies a cryptographic hash function that is implemented in another package.

func (Hash) Available

func (h Hash) Available() bool

Available reports whether the given hash function is linked into the binary.

func (Hash) HashFunc

func (h Hash) HashFunc() crypto.Hash

HashFunc simply returns the value of h so that Hash implements SignerOpts.

func (Hash) New

func (h Hash) New() hash.Hash

New returns a new hash.Hash calculating the given hash function. New panics if the hash function is not linked into the binary.

func (Hash) Size

func (h Hash) Size() int

Size returns the length, in bytes, of a digest resulting from the given hash function. It doesn't require that the hash function in question be linked into the program.

Jump to

Keyboard shortcuts

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