legacyx509

package
v0.0.0-...-2cdf7eb Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package x509 implements a subset of the X.509 standard.

It allows parsing and generating certificates, certificate signing requests, certificate revocation lists, and encoded public and private keys. It provides a certificate verifier, complete with a chain builder.

The package targets the X.509 technical profile defined by the IETF (RFC 2459/3280/5280), and as further restricted by the CA/Browser Forum Baseline Requirements. There is minimal support for features outside of these profiles, as the primary goal of the package is to provide compatibility with the publicly trusted TLS certificate ecosystem and its policies and constraints.

On macOS and Windows, certificate verification is handled by system APIs, but the package aims to apply consistent validation rules across operating systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCertificates

func ParseCertificates(der []byte) ([]*stdx509.Certificate, error)

ParseCertificates parses one or more certificates from the given ASN.1 DER data. The certificates must be concatenated with no intermediate padding.

Types

type ExtKeyUsage

type ExtKeyUsage int

ExtKeyUsage represents an extended set of actions that are valid for a given key. Each of the ExtKeyUsage* constants define a unique action.

const (
	ExtKeyUsageAny ExtKeyUsage = iota
	ExtKeyUsageServerAuth
	ExtKeyUsageClientAuth
	ExtKeyUsageCodeSigning
	ExtKeyUsageEmailProtection
	ExtKeyUsageIPSECEndSystem
	ExtKeyUsageIPSECTunnel
	ExtKeyUsageIPSECUser
	ExtKeyUsageTimeStamping
	ExtKeyUsageOCSPSigning
	ExtKeyUsageMicrosoftServerGatedCrypto
	ExtKeyUsageNetscapeServerGatedCrypto
	ExtKeyUsageMicrosoftCommercialCodeSigning
	ExtKeyUsageMicrosoftKernelCodeSigning
)

type KeyUsage

type KeyUsage int

KeyUsage represents the set of actions that are valid for a given key. It's a bitmap of the KeyUsage* constants.

const (
	KeyUsageDigitalSignature KeyUsage = 1 << iota
	KeyUsageContentCommitment
	KeyUsageKeyEncipherment
	KeyUsageDataEncipherment
	KeyUsageKeyAgreement
	KeyUsageCertSign
	KeyUsageCRLSign
	KeyUsageEncipherOnly
	KeyUsageDecipherOnly
)

type OID

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

An OID represents an ASN.1 OBJECT IDENTIFIER.

func OIDFromInts

func OIDFromInts(oid []uint64) (OID, error)

OIDFromInts creates a new OID using ints, each integer is a separate component.

func ParseOID

func ParseOID(oid string) (OID, error)

ParseOID parses a Object Identifier string, represented by ASCII numbers separated by dots.

func (OID) AppendBinary

func (o OID) AppendBinary(b []byte) ([]byte, error)

AppendBinary implements encoding.BinaryAppender

func (OID) AppendText

func (o OID) AppendText(b []byte) ([]byte, error)

AppendText implements encoding.TextAppender

func (OID) Equal

func (oid OID) Equal(other OID) bool

Equal returns true when oid and other represents the same Object Identifier.

func (OID) EqualASN1OID

func (oid OID) EqualASN1OID(other asn1.ObjectIdentifier) bool

EqualASN1OID returns whether an OID equals an asn1.ObjectIdentifier. If asn1.ObjectIdentifier cannot represent the OID specified by oid, because a component of OID requires more than 31 bits, it returns false.

func (OID) MarshalBinary

func (o OID) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (OID) MarshalText

func (o OID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (OID) String

func (oid OID) String() string

Strings returns the string representation of the Object Identifier.

func (*OID) UnmarshalBinary

func (o *OID) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

func (*OID) UnmarshalText

func (o *OID) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type PublicKeyAlgorithm

type PublicKeyAlgorithm int
const (
	UnknownPublicKeyAlgorithm PublicKeyAlgorithm = iota
	RSA
	DSA // Only supported for parsing.
	ECDSA
	Ed25519
)

func (PublicKeyAlgorithm) String

func (algo PublicKeyAlgorithm) String() string

type SignatureAlgorithm

type SignatureAlgorithm int
const (
	UnknownSignatureAlgorithm SignatureAlgorithm = iota

	MD2WithRSA  // Unsupported.
	MD5WithRSA  // Only supported for signing, not verification.
	SHA1WithRSA // Only supported for signing, and verification of CRLs, CSRs, and OCSP responses.
	SHA256WithRSA
	SHA384WithRSA
	SHA512WithRSA
	DSAWithSHA1   // Unsupported.
	DSAWithSHA256 // Unsupported.
	ECDSAWithSHA1 // Only supported for signing, and verification of CRLs, CSRs, and OCSP responses.
	ECDSAWithSHA256
	ECDSAWithSHA384
	ECDSAWithSHA512
	SHA256WithRSAPSS
	SHA384WithRSAPSS
	SHA512WithRSAPSS
	PureEd25519
)

func (SignatureAlgorithm) String

func (algo SignatureAlgorithm) String() string

Jump to

Keyboard shortcuts

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