oid

package
v2.0.333 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oid names well-known X.509 object identifiers and gives the extensions of a certificate Go types.

Names

Name returns the name of an identifier, and Lookup and Parse the identifier of a name. Names are compared by their letters and digits only, so "Subject Alt Name", "subject_alt_name" and "subjectAltName" are one name. The names are in one namespace, whatever they identify: extensions, extended key usages, access methods, policy qualifiers and otherName types. ID is an identifier that is written in JSON and YAML as its name, or as dotted decimals when it has none.

The KeyUsage and ExtKeyUsage maps name the usages of a certificate profile. They are process-global and must not be mutated after init.

Extensions

An extension with a Go type implements ExtensionValue: UnmarshalDER reads the extnValue of the extension and MarshalDER writes it. The types have JSON and YAML tags, so a value is also the content of an extension in a certificate profile (csr.X509Extension) and what print.Extensions shows. The built-in types cover RFC 5280, the STIR/SHAKEN extensions of RFC 8226 and RFC 9118, Certificate Transparency, ACME, qualified certificates, S/MIME and the common Microsoft and Netscape extensions; Extensions lists them.

value, err := oid.DecodeExtension(ext.Id, ext.Value)
if errors.Is(err, oid.ErrNotRegistered) {
	// no Go type: use ext.Value
}
if list, ok := value.(*oid.TNAuthList); ok {
	// (*list)[0].SPC
}

der, err := oid.TNAuthList{{SPC: "1234"}}.MarshalDER()

RegisterExtension adds an extension of the caller, and Register a name:

err := oid.RegisterExtension(oid.ExtensionInfo{
	ID:   asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 99999, 1},
	Name: "Device Class",
	New:  func() oid.ExtensionValue { return new(oid.IA5String) },
})

The registry is process-global and safe for concurrent use. Nothing is removed from it, and a name cannot be given to a second identifier nor an identifier a second display name. Registering an extension again with a type replaces the type, so an application can give a built-in extension its own. Register at start-up, before profiles are read.

Decoding is strict and never panics on input: a value that is not the DER the extension defines, or that MarshalDER would not write, is an error, so what decodes always encodes. Parts a type does not model, such as a GeneralName form without a text representation, are kept as their DER and written back unchanged.

Index

Examples

Constants

View Source
const (
	// QualifierCPS is id-qt-cps: the value is the URI of a certification
	// practice statement.
	QualifierCPS = "id-qt-cps"
	// QualifierUserNotice is id-qt-unotice: the value is the explicit text
	// of a user notice.
	QualifierUserNotice = "id-qt-unotice"
)

Names of the policy qualifiers in PolicyQualifier.Type, the names a certificate profile uses.

Variables

View Source
var (
	// ExtensionIssuerAltName is the issuer alternative name (RFC 5280, 4.2.1.7).
	ExtensionIssuerAltName = asn1.ObjectIdentifier{2, 5, 29, 18}
	// ExtensionPolicyMappings is the policy mappings (RFC 5280, 4.2.1.5).
	ExtensionPolicyMappings = asn1.ObjectIdentifier{2, 5, 29, 33}
	// ExtensionPolicyConstraints is the policy constraints (RFC 5280, 4.2.1.11).
	ExtensionPolicyConstraints = asn1.ObjectIdentifier{2, 5, 29, 36}
	// ExtensionFreshestCRL is the freshest CRL, or delta CRL distribution
	// point (RFC 5280, 4.2.1.15).
	ExtensionFreshestCRL = asn1.ObjectIdentifier{2, 5, 29, 46}
	// ExtensionInhibitAnyPolicy is inhibit anyPolicy (RFC 5280, 4.2.1.14).
	ExtensionInhibitAnyPolicy = asn1.ObjectIdentifier{2, 5, 29, 54}
	// ExtensionNoRevAvail marks a certificate without revocation
	// information (RFC 9608).
	ExtensionNoRevAvail = asn1.ObjectIdentifier{2, 5, 29, 56}
	// ExtensionQCStatements is the qualified certificate statements (RFC 3739).
	ExtensionQCStatements = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 3}
	// ExtensionSubjectInfoAccess is the subject information access
	// (RFC 5280, 4.2.2.2).
	ExtensionSubjectInfoAccess = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 11}
	// ExtensionTLSFeature is the TLS feature, known as OCSP Must-Staple
	// (RFC 7633).
	ExtensionTLSFeature = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 24}
	// ExtensionTNAuthList is the STIR/SHAKEN TN authorization list
	// (RFC 8226, 9).
	ExtensionTNAuthList = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 26}
	// ExtensionJWTClaimConstraints is the STIR JWT claim constraints
	// (RFC 8226, 8).
	ExtensionJWTClaimConstraints = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 27}
	// ExtensionACMEIdentifier is the ACME TLS-ALPN-01 challenge identifier
	// (RFC 8737).
	ExtensionACMEIdentifier = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 31}
	// ExtensionEnhancedJWTClaimConstraints is the STIR enhanced JWT claim
	// constraints (RFC 9118).
	ExtensionEnhancedJWTClaimConstraints = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 33}
	// ExtensionSCTList is the Certificate Transparency signed certificate
	// timestamp list (RFC 6962, 3.3).
	ExtensionSCTList = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 2}
	// ExtensionCTPoison is the Certificate Transparency precertificate
	// poison (RFC 6962, 3.1).
	ExtensionCTPoison = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 3}
	// ExtensionMSCertificateTemplateName is the Microsoft certificate
	// template name, version 1.
	ExtensionMSCertificateTemplateName = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 311, 20, 2}
	// ExtensionMSCAVersion is the Microsoft CA version.
	ExtensionMSCAVersion = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 311, 21, 1}
	// ExtensionMSCertificateTemplate is the Microsoft certificate
	// template, version 2.
	ExtensionMSCertificateTemplate = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 311, 21, 7}
	// ExtensionMSApplicationPolicies is the Microsoft application policies.
	ExtensionMSApplicationPolicies = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 311, 21, 10}
	// ExtensionMSNTDSCASecurity is the Microsoft security identifier of
	// the subject (NTDS CA security extension).
	ExtensionMSNTDSCASecurity = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 311, 25, 2}
	// ExtensionNetscapeCertType is the Netscape certificate type.
	ExtensionNetscapeCertType = asn1.ObjectIdentifier{2, 16, 840, 1, 113730, 1, 1}
	// ExtensionNetscapeComment is the Netscape comment.
	ExtensionNetscapeComment = asn1.ObjectIdentifier{2, 16, 840, 1, 113730, 1, 13}
	// ExtensionSMIMECapabilities is the S/MIME capabilities (RFC 4262).
	ExtensionSMIMECapabilities = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 15}
)

Object identifiers of the extensions this package has a type for, in addition to those in oidinfo.go.

View Source
var (
	ExtensionSubjectKeyID          = asn1.ObjectIdentifier{2, 5, 29, 14}
	ExtensionKeyUsage              = asn1.ObjectIdentifier{2, 5, 29, 15}
	ExtensionSubjectAltName        = asn1.ObjectIdentifier{2, 5, 29, 17}
	ExtensionBasicConstraints      = asn1.ObjectIdentifier{2, 5, 29, 19}
	ExtensionCRLNumber             = asn1.ObjectIdentifier{2, 5, 29, 20}
	ExtensionNameConstraints       = asn1.ObjectIdentifier{2, 5, 29, 30}
	ExtensionCRLDistributionPoints = asn1.ObjectIdentifier{2, 5, 29, 31}
	ExtensionCertificatePolicies   = asn1.ObjectIdentifier{2, 5, 29, 32}
	ExtensionAuthorityKeyID        = asn1.ObjectIdentifier{2, 5, 29, 35}
	ExtensionExtendedKeyUsage      = asn1.ObjectIdentifier{2, 5, 29, 37}
	ExtensionAuthorityInfoAccess   = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 1}
	AuthorityInfoAccessOcsp        = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 48, 1}
	OCSPNoCheck                    = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 48, 1, 5}
	AuthorityInfoAccessIssuers     = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 48, 2}

	NameEmailAddress = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 1}
	NameCN           = asn1.ObjectIdentifier{2, 5, 4, 3}
	NameSerial       = asn1.ObjectIdentifier{2, 5, 4, 5}
	NameC            = asn1.ObjectIdentifier{2, 5, 4, 6}
	NameL            = asn1.ObjectIdentifier{2, 5, 4, 7}
	NameST           = asn1.ObjectIdentifier{2, 5, 4, 8}
	NameStreet       = asn1.ObjectIdentifier{2, 5, 4, 9}
	NameO            = asn1.ObjectIdentifier{2, 5, 4, 10}
	NameOU           = asn1.ObjectIdentifier{2, 5, 4, 11}
	NamePostal       = asn1.ObjectIdentifier{2, 5, 4, 17}
)

well-known OIDs

View Source
var DisplayName = map[string]string{
	"2.5.29.14":            "Subject KeyID",
	"2.5.29.15":            "Key Usage",
	"2.5.29.17":            "Subject Alt Name",
	"2.5.29.19":            "Basic Constraints",
	"2.5.29.20":            "CRL Number",
	"2.5.29.30":            "Name Constraints",
	"2.5.29.31":            "CRL Distribution Point",
	"2.5.29.32":            "Certificate Policies",
	"2.5.29.35":            "Authority KeyID",
	"2.5.29.37":            "Extended KeyUsage",
	"1.3.6.1.5.5.7.1.1":    "Authority Info Access",
	"1.3.6.1.5.5.7.48.1":   "OCSP",
	"1.3.6.1.5.5.7.48.1.5": "OCSP No Check",
	"1.3.6.1.5.5.7.48.2":   "Issuers",
}

DisplayName provides the names of a few identifiers by their dotted decimals.

Deprecated: use Name, which knows every registered identifier.

View Source
var ErrNotRegistered = errors.New("not registered")

ErrNotRegistered is returned, wrapped, when an object identifier or a name is not in the registry, or when an extension has no registered Go type.

View Source
var ExtKeyUsage = map[string]x509.ExtKeyUsage{
	"any":              x509.ExtKeyUsageAny,
	"server auth":      x509.ExtKeyUsageServerAuth,
	"client auth":      x509.ExtKeyUsageClientAuth,
	"code signing":     x509.ExtKeyUsageCodeSigning,
	"email protection": x509.ExtKeyUsageEmailProtection,
	"s/mime":           x509.ExtKeyUsageEmailProtection,
	"ipsec end system": x509.ExtKeyUsageIPSECEndSystem,
	"ipsec tunnel":     x509.ExtKeyUsageIPSECTunnel,
	"ipsec user":       x509.ExtKeyUsageIPSECUser,
	"timestamping":     x509.ExtKeyUsageTimeStamping,
	"ocsp signing":     x509.ExtKeyUsageOCSPSigning,
	"microsoft sgc":    x509.ExtKeyUsageMicrosoftServerGatedCrypto,
	"netscape sgc":     x509.ExtKeyUsageNetscapeServerGatedCrypto,
}

ExtKeyUsage contains a mapping of string names to extended key usages.

View Source
var ExtKeyUsageName = map[x509.ExtKeyUsage]string{
	x509.ExtKeyUsageAny:                        "any",
	x509.ExtKeyUsageServerAuth:                 "server auth",
	x509.ExtKeyUsageClientAuth:                 "client auth",
	x509.ExtKeyUsageCodeSigning:                "code signing",
	x509.ExtKeyUsageEmailProtection:            "email protection",
	x509.ExtKeyUsageIPSECEndSystem:             "ipsec end system",
	x509.ExtKeyUsageIPSECTunnel:                "ipsec tunnel",
	x509.ExtKeyUsageIPSECUser:                  "ipsec user",
	x509.ExtKeyUsageTimeStamping:               "timestamping",
	x509.ExtKeyUsageOCSPSigning:                "ocsp signing",
	x509.ExtKeyUsageMicrosoftServerGatedCrypto: "microsoft sgc",
	x509.ExtKeyUsageNetscapeServerGatedCrypto:  "netscape sgc",
}

ExtKeyUsageName provides map of names

View Source
var KeyUsage = map[string]x509.KeyUsage{
	"signing":            x509.KeyUsageDigitalSignature,
	"digital signature":  x509.KeyUsageDigitalSignature,
	"content commitment": x509.KeyUsageContentCommitment,
	"key encipherment":   x509.KeyUsageKeyEncipherment,
	"key agreement":      x509.KeyUsageKeyAgreement,
	"data encipherment":  x509.KeyUsageDataEncipherment,
	"cert sign":          x509.KeyUsageCertSign,
	"crl sign":           x509.KeyUsageCRLSign,
	"encipher only":      x509.KeyUsageEncipherOnly,
	"decipher only":      x509.KeyUsageDecipherOnly,
}

KeyUsage contains a mapping of string names to key usages.

View Source
var KeyUsageName = map[x509.KeyUsage]string{
	x509.KeyUsageDigitalSignature:  "signing",
	x509.KeyUsageContentCommitment: "content commitment",
	x509.KeyUsageKeyEncipherment:   "key encipherment",
	x509.KeyUsageKeyAgreement:      "key agreement",
	x509.KeyUsageDataEncipherment:  "data encipherment",
	x509.KeyUsageCertSign:          "cert sign",
	x509.KeyUsageCRLSign:           "crl sign",
	x509.KeyUsageEncipherOnly:      "encipher only",
	x509.KeyUsageDecipherOnly:      "decipher only",
}

KeyUsageName provides map of names

Functions

func ExtKeyUsages

func ExtKeyUsages(eku ...x509.ExtKeyUsage) []string

ExtKeyUsages returns list of names

func KeyUsages

func KeyUsages(ku x509.KeyUsage) []string

KeyUsages returns the canonical names (from KeyUsageName) of the usage bits set in ku, in RFC 5280 bit order. Each bit is reported once; the "digital signature" alias accepted by KeyUsage is reported as "signing".

func Lookup added in v2.0.333

func Lookup(name string) (asn1.ObjectIdentifier, bool)

Lookup returns the object identifier registered with a name or an alias. The spelling may differ in case, spaces and punctuation: "Subject Alt Name", "subject_alt_name" and "subjectAltName" are the same name.

Example
package main

import (
	"fmt"

	"github.com/effective-security/xpki/v2/oid"
)

func main() {
	for _, name := range []string{"Subject Alt Name", "subjectAltName", "subject_alt_name"} {
		id, _ := oid.Lookup(name)
		fmt.Println(id)
	}

}
Output:
2.5.29.17
2.5.29.17
2.5.29.17

func Name added in v2.0.333

func Name(id asn1.ObjectIdentifier) string

Name returns the registered name of an object identifier, or an empty string.

func Parse added in v2.0.333

func Parse(s string) (asn1.ObjectIdentifier, error)

Parse returns the object identifier written as dotted decimals ("2.5.29.15") or as a registered name ("key usage").

func Register added in v2.0.333

func Register(id asn1.ObjectIdentifier, name string, aliases ...string) error

Register gives an object identifier a name, and optional aliases, for Name, Lookup and Parse. Names are compared by their letters and digits only, without case, and one name belongs to one identifier: registering a name of another identifier, or another name for a registered identifier, is an error. Registering the same pair again is not.

func RegisterExtension added in v2.0.333

func RegisterExtension(info ExtensionInfo) error

RegisterExtension registers the name of an X.509 extension and, when info.New is set, its Go type, so that DecodeExtension, a certificate profile and the print package handle it. It follows the rules of Register. Registering an extension again with info.New replaces its type, which is how an application gives a built-in extension its own type; without info.New the extension keeps the type it has. An info.New that returns nil, or a nil pointer, is an error and registers nothing.

Example
package main

import (
	"encoding/asn1"
	"fmt"

	"github.com/effective-security/xpki/v2/oid"
)

func main() {
	deviceClass := asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 99999, 1}
	err := oid.RegisterExtension(oid.ExtensionInfo{
		ID:   deviceClass,
		Name: "Device Class",
		New: func() oid.ExtensionValue {
			return new(oid.IA5String)
		},
	})
	if err != nil {
		fmt.Println(err)
		return
	}

	id, _ := oid.Parse("device_class")
	fmt.Println(id, oid.Name(id))

	value, err := oid.DecodeExtension(id, []byte{0x16, 0x02, 'A', '1'})
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(*value.(*oid.IA5String))

}
Output:
1.3.6.1.4.1.99999.1 Device Class
A1

func Strings

func Strings(ids ...asn1.ObjectIdentifier) []string

Strings returns list of OID string values

Types

type AccessDescription added in v2.0.333

type AccessDescription struct {
	// Method is the access method, such as "ocsp" or "ca issuers".
	Method ID `json:"method" yaml:"method"`
	// Location is where the service or the information is, usually a URI.
	Location GeneralName `json:"location" yaml:"location"`
}

AccessDescription is one entry of an authority or subject information access extension.

type AuthorityKeyID added in v2.0.333

type AuthorityKeyID struct {
	// KeyID is the key identifier of the issuer's public key.
	KeyID HexBytes `json:"key_id,omitempty" yaml:"key_id,omitempty"`
	// Issuer names the issuer of the issuer's certificate; it comes with
	// SerialNumber.
	Issuer []GeneralName `json:"issuer,omitempty" yaml:"issuer,omitempty"`
	// SerialNumber is the serial number of the issuer's certificate, in
	// decimal. Quote it in YAML.
	SerialNumber string `json:"serial_number,omitempty" yaml:"serial_number,omitempty"`
}

AuthorityKeyID is the value of the authority key identifier extension (RFC 5280, 4.2.1.1).

func (AuthorityKeyID) MarshalDER added in v2.0.333

func (a AuthorityKeyID) MarshalDER() ([]byte, error)

MarshalDER returns the DER of AuthorityKeyIdentifier.

func (*AuthorityKeyID) UnmarshalDER added in v2.0.333

func (a *AuthorityKeyID) UnmarshalDER(der []byte) error

UnmarshalDER decodes AuthorityKeyIdentifier.

type BMPString added in v2.0.333

type BMPString string

BMPString is the value of an extension that is one BMPString, such as the Microsoft certificate template name.

func (BMPString) MarshalDER added in v2.0.333

func (s BMPString) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the BMPString.

func (*BMPString) UnmarshalDER added in v2.0.333

func (s *BMPString) UnmarshalDER(der []byte) error

UnmarshalDER decodes a BMPString.

type Base64Bytes added in v2.0.333

type Base64Bytes []byte

Base64Bytes is a byte string inside an extension value, written in base64 in YAML and JSON. A "base64:" prefix is accepted, and a "hex:" prefix reads hex.

func (Base64Bytes) MarshalText added in v2.0.333

func (h Base64Bytes) MarshalText() ([]byte, error)

MarshalText returns the bytes in standard base64.

func (*Base64Bytes) UnmarshalText added in v2.0.333

func (h *Base64Bytes) UnmarshalText(text []byte) error

UnmarshalText reads base64, or hex with the "hex:" prefix.

type BasicConstraints added in v2.0.333

type BasicConstraints struct {
	// IsCA marks a CA certificate.
	IsCA bool `json:"is_ca" yaml:"is_ca"`
	// MaxPathLen is pathLenConstraint: the number of intermediate CA
	// certificates that may follow this one. Nil leaves it out.
	MaxPathLen *int `json:"max_path_len,omitempty" yaml:"max_path_len,omitempty"`
}

BasicConstraints is the value of the basic constraints extension (RFC 5280, 4.2.1.9).

func (BasicConstraints) MarshalDER added in v2.0.333

func (c BasicConstraints) MarshalDER() ([]byte, error)

MarshalDER returns the DER of BasicConstraints.

func (*BasicConstraints) UnmarshalDER added in v2.0.333

func (c *BasicConstraints) UnmarshalDER(der []byte) error

UnmarshalDER decodes BasicConstraints.

type CRLDistributionPoints added in v2.0.333

type CRLDistributionPoints []DistributionPoint

CRLDistributionPoints is the value of the CRL distribution points and freshest CRL extensions (RFC 5280, 4.2.1.13 and 4.2.1.15):

func (CRLDistributionPoints) MarshalDER added in v2.0.333

func (p CRLDistributionPoints) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of distribution points; it needs one or more.

func (*CRLDistributionPoints) UnmarshalDER added in v2.0.333

func (p *CRLDistributionPoints) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of distribution points.

type CertificatePolicies added in v2.0.333

type CertificatePolicies []PolicyInformation

CertificatePolicies is the value of the certificate policies extension (RFC 5280, 4.2.1.4), and of the Microsoft application policies, in the form of the policies of a certificate profile:

A user notice with a notice reference, and a qualifier of another type, have the dotted decimals of the qualifier as the type and the hex of its DER as the value.

func (CertificatePolicies) MarshalDER added in v2.0.333

func (p CertificatePolicies) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of policies; it needs one or more.

func (*CertificatePolicies) UnmarshalDER added in v2.0.333

func (p *CertificatePolicies) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of policies.

type DistributionPoint added in v2.0.333

type DistributionPoint struct {
	// FullName lists the locations of the CRL, usually one URI.
	FullName []GeneralName `json:"full_name,omitempty" yaml:"full_name,omitempty"`
	// RelativeName is nameRelativeToCRLIssuer as an RFC 4514 string of one
	// RDN, an alternative to FullName.
	RelativeName string `json:"relative_name,omitempty" yaml:"relative_name,omitempty"`
	// Reasons lists the revocation reasons the CRL covers, such as "key
	// compromise"; empty means all.
	Reasons []string `json:"reasons,omitempty" yaml:"reasons,omitempty"`
	// CRLIssuer names the issuer of an indirect CRL.
	CRLIssuer []GeneralName `json:"crl_issuer,omitempty" yaml:"crl_issuer,omitempty"`
}

DistributionPoint is one CRL distribution point (RFC 5280, 4.2.1.13).

type EnhancedJWTClaimConstraints added in v2.0.333

type EnhancedJWTClaimConstraints struct {
	// MustInclude lists the claims that must be present.
	MustInclude []string `json:"must_include,omitempty" yaml:"must_include,omitempty"`
	// PermittedValues lists the claims limited to some values.
	PermittedValues []JWTClaimValues `json:"permitted_values,omitempty" yaml:"permitted_values,omitempty"`
	// MustExclude lists the claims that must be absent.
	MustExclude []string `json:"must_exclude,omitempty" yaml:"must_exclude,omitempty"`
}

EnhancedJWTClaimConstraints is the value of the enhanced JWT claim constraints extension (RFC 9118): JWTClaimConstraints and the claims a PASSporT must not include.

func (EnhancedJWTClaimConstraints) MarshalDER added in v2.0.333

func (c EnhancedJWTClaimConstraints) MarshalDER() ([]byte, error)

MarshalDER returns the DER of EnhancedJWTClaimConstraints; it needs one field or more.

func (*EnhancedJWTClaimConstraints) UnmarshalDER added in v2.0.333

func (c *EnhancedJWTClaimConstraints) UnmarshalDER(der []byte) error

UnmarshalDER decodes EnhancedJWTClaimConstraints.

type ExtendedKeyUsage added in v2.0.333

type ExtendedKeyUsage []ID

ExtendedKeyUsage is the value of the extended key usage extension (RFC 5280, 4.2.1.12): a list of key purposes, by registered name or dotted decimals:

[server auth, client auth, 1.3.6.1.4.1.311.20.2.2]

func (ExtendedKeyUsage) MarshalDER added in v2.0.333

func (e ExtendedKeyUsage) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of key purposes; it needs one or more.

func (*ExtendedKeyUsage) UnmarshalDER added in v2.0.333

func (e *ExtendedKeyUsage) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of key purposes.

type ExtensionInfo added in v2.0.333

type ExtensionInfo struct {
	// ID is the object identifier of the extension.
	ID asn1.ObjectIdentifier
	// Name is the display name, such as "Key Usage". It is also the name
	// Lookup accepts, in any spelling that keeps its letters and digits:
	// "key usage", "key_usage" or "keyUsage".
	Name string
	// New returns an empty value of the extension, a pointer that is not
	// nil. It is nil for an extension that is named but has no Go type.
	New func() ExtensionValue
}

ExtensionInfo describes a registered X.509 extension.

func Extensions added in v2.0.333

func Extensions() []ExtensionInfo

Extensions returns the registered extensions ordered by identifier.

func LookupExtension added in v2.0.333

func LookupExtension(id asn1.ObjectIdentifier) (ExtensionInfo, bool)

LookupExtension returns the registered extension with the identifier.

type ExtensionValue added in v2.0.333

type ExtensionValue interface {
	// MarshalDER returns the DER encoding of extnValue. A value the
	// extension does not allow, such as an empty list, is an error.
	MarshalDER() ([]byte, error)
	// UnmarshalDER replaces the value with the decoded extnValue. Trailing
	// data, an element the type does not model, and a value MarshalDER
	// does not write, are errors: what is decoded encodes again.
	UnmarshalDER(der []byte) error
}

ExtensionValue is the decoded value of an X.509 extension: a Go type that maps to the DER of extnValue on one side and to YAML or JSON on the other, so the same type prints a certificate and describes the extension in a certificate profile. The registered types are pointers to the types of this package.

Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/effective-security/xpki/v2/oid"
)

func main() {
	list := oid.TNAuthList{
		{SPC: "969H"},
	}
	der, err := list.MarshalDER()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(hex.EncodeToString(der))

}
Output:
3008a006160439363948

func DecodeExtension added in v2.0.333

func DecodeExtension(id asn1.ObjectIdentifier, der []byte) (ExtensionValue, error)

DecodeExtension decodes the DER value of the extension with the identifier into its registered Go type. The error wraps ErrNotRegistered when the extension has no type.

Example
package main

import (
	"encoding/asn1"
	"encoding/hex"
	"fmt"

	"github.com/cockroachdb/errors"
	"github.com/effective-security/xpki/v2/oid"
)

func main() {
	// the TN Authorization List of a STIR/SHAKEN certificate
	der, _ := hex.DecodeString("3008a006160439363948")

	value, err := oid.DecodeExtension(oid.ExtensionTNAuthList, der)
	if err != nil {
		fmt.Println(err)
		return
	}
	if list, ok := value.(*oid.TNAuthList); ok {
		fmt.Println("SPC:", (*list)[0].SPC)
	}

	// an extension without a Go type
	_, err = oid.DecodeExtension(asn1.ObjectIdentifier{1, 2, 3, 4}, der)
	fmt.Println(errors.Is(err, oid.ErrNotRegistered))

}
Output:
SPC: 969H
true

func NewExtensionValue added in v2.0.333

func NewExtensionValue(id asn1.ObjectIdentifier) (ExtensionValue, error)

NewExtensionValue returns an empty value of the Go type registered for the extension. The error wraps ErrNotRegistered when the extension is unknown or only named; a registered constructor that returns nil is another error.

type GeneralName added in v2.0.333

type GeneralName struct {
	// Other is an otherName: a type identifier and its value.
	Other *OtherName `json:"other,omitempty" yaml:"other,omitempty"`
	// Email is an rfc822Name.
	Email string `json:"email,omitempty" yaml:"email,omitempty"`
	// DNS is a dNSName; in name constraints, a domain.
	DNS string `json:"dns,omitempty" yaml:"dns,omitempty"`
	// DirName is a directoryName as an RFC 4514 string, the most specific
	// attribute first: "CN=Example CA,O=Example,C=US". Values are encoded
	// as UTF8String, except PrintableString for C, SERIALNUMBER and the DN
	// qualifier, and IA5String for DC and emailAddress. A value written as
	// #hex is the DER of the value, for any other type.
	DirName string `json:"dirname,omitempty" yaml:"dirname,omitempty"`
	// URI is a uniformResourceIdentifier.
	URI string `json:"uri,omitempty" yaml:"uri,omitempty"`
	// IP is an iPAddress: an IPv4 or IPv6 address, or in name constraints
	// an address range as a prefix, "10.0.0.0/8".
	IP string `json:"ip,omitempty" yaml:"ip,omitempty"`
	// RegisteredID is a registeredID.
	RegisteredID ID `json:"rid,omitempty" yaml:"rid,omitempty"`
	// Raw is the DER of a name of a form the other fields do not model: an
	// x400Address, an ediPartyName, or a name that does not decode.
	Raw HexBytes `json:"raw,omitempty" yaml:"raw,omitempty"`
}

GeneralName is one name of a GeneralNames list (RFC 5280, 4.2.1.6), with exactly one field set:

  • dns: example.com
  • ip: 192.0.2.1
  • dirname: CN=Example CA,O=Example,C=US

type GeneralNames added in v2.0.333

type GeneralNames []GeneralName

GeneralNames is the value of the subject and issuer alternative name extensions (RFC 5280, 4.2.1.6 and 4.2.1.7): a list of names.

func (GeneralNames) MarshalDER added in v2.0.333

func (g GeneralNames) MarshalDER() ([]byte, error)

MarshalDER returns the DER of a GeneralNames sequence with one name or more.

func (*GeneralNames) UnmarshalDER added in v2.0.333

func (g *GeneralNames) UnmarshalDER(der []byte) error

UnmarshalDER decodes a GeneralNames sequence.

type HexBytes added in v2.0.333

type HexBytes []byte

HexBytes is a byte string inside an extension value, written in hex in YAML and JSON. A "hex:" prefix and colons between the bytes are accepted, and a "base64:" prefix reads base64. Quote a value of digits only, or give it the prefix: YAML reads 0012 and 12e4 as numbers.

func (HexBytes) MarshalText added in v2.0.333

func (h HexBytes) MarshalText() ([]byte, error)

MarshalText returns the bytes in lower case hex.

func (*HexBytes) UnmarshalText added in v2.0.333

func (h *HexBytes) UnmarshalText(text []byte) error

UnmarshalText reads hex, or base64 with the "base64:" prefix.

type IA5String added in v2.0.333

type IA5String string

IA5String is the value of an extension that is one IA5String, such as the Netscape comment.

func (IA5String) MarshalDER added in v2.0.333

func (s IA5String) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the IA5String.

func (*IA5String) UnmarshalDER added in v2.0.333

func (s *IA5String) UnmarshalDER(der []byte) error

UnmarshalDER decodes an IA5String.

type ID added in v2.0.333

ID is an object identifier inside an extension value. In YAML and JSON it is the registered name when it has one ("server auth") and dotted decimals otherwise; both forms are read.

func (ID) Equal added in v2.0.333

func (id ID) Equal(other ID) bool

Equal reports whether both identifiers are the same.

func (ID) MarshalText added in v2.0.333

func (id ID) MarshalText() ([]byte, error)

MarshalText returns the registered name, or the dotted decimals.

func (ID) OID added in v2.0.333

func (id ID) OID() asn1.ObjectIdentifier

OID returns the identifier as an asn1.ObjectIdentifier.

func (ID) String added in v2.0.333

func (id ID) String() string

String returns the registered name, or the dotted decimals.

func (*ID) UnmarshalText added in v2.0.333

func (id *ID) UnmarshalText(text []byte) error

UnmarshalText reads a registered name or dotted decimals.

type InfoAccess added in v2.0.333

type InfoAccess []AccessDescription

InfoAccess is the value of the authority and subject information access extensions (RFC 5280, 4.2.2.1 and 4.2.2.2):

func (InfoAccess) MarshalDER added in v2.0.333

func (a InfoAccess) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of access descriptions; it needs one or more.

func (*InfoAccess) UnmarshalDER added in v2.0.333

func (a *InfoAccess) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of access descriptions.

type Integer added in v2.0.333

type Integer int64

Integer is the value of an extension that is one INTEGER, such as inhibit anyPolicy (RFC 5280, 4.2.1.14).

func (Integer) MarshalDER added in v2.0.333

func (i Integer) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the INTEGER.

func (*Integer) UnmarshalDER added in v2.0.333

func (i *Integer) UnmarshalDER(der []byte) error

UnmarshalDER decodes an INTEGER that fits in 64 bits.

type JWTClaimConstraints added in v2.0.333

type JWTClaimConstraints struct {
	// MustInclude lists the claims that must be present.
	MustInclude []string `json:"must_include,omitempty" yaml:"must_include,omitempty"`
	// PermittedValues lists the claims limited to some values.
	PermittedValues []JWTClaimValues `json:"permitted_values,omitempty" yaml:"permitted_values,omitempty"`
}

JWTClaimConstraints is the value of the JWT claim constraints extension (RFC 8226, 8): the claims a PASSporT signed with the certificate must include and the values it may give them.

must_include: [rcd]
permitted_values:
  - claim: attest
    values: ['"A"', '"B"']

func (JWTClaimConstraints) MarshalDER added in v2.0.333

func (c JWTClaimConstraints) MarshalDER() ([]byte, error)

MarshalDER returns the DER of JWTClaimConstraints; it needs one field or both.

func (*JWTClaimConstraints) UnmarshalDER added in v2.0.333

func (c *JWTClaimConstraints) UnmarshalDER(der []byte) error

UnmarshalDER decodes JWTClaimConstraints.

type JWTClaimValues added in v2.0.333

type JWTClaimValues struct {
	// Claim is the name of the claim.
	Claim string `json:"claim" yaml:"claim"`
	// Values lists the permitted values, each a JSON value as a string.
	Values []string `json:"values" yaml:"values"`
}

JWTClaimValues lists the values a PASSporT claim may have.

type KeyUsageBits added in v2.0.333

type KeyUsageBits x509.KeyUsage

KeyUsageBits is the value of the key usage extension (RFC 5280, 4.2.1.3). In YAML and JSON it is the list of usage names KeyUsages returns, and every name of the KeyUsage map is read:

[signing, key encipherment]

func (KeyUsageBits) MarshalDER added in v2.0.333

func (k KeyUsageBits) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the KeyUsage BIT STRING. A value without a usage is an error.

func (KeyUsageBits) MarshalJSON added in v2.0.333

func (k KeyUsageBits) MarshalJSON() ([]byte, error)

MarshalJSON returns the list of usage names.

func (KeyUsageBits) MarshalYAML added in v2.0.333

func (k KeyUsageBits) MarshalYAML() (any, error)

MarshalYAML returns the list of usage names.

func (*KeyUsageBits) UnmarshalDER added in v2.0.333

func (k *KeyUsageBits) UnmarshalDER(der []byte) error

UnmarshalDER decodes a KeyUsage BIT STRING.

func (*KeyUsageBits) UnmarshalJSON added in v2.0.333

func (k *KeyUsageBits) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a list of usage names.

func (*KeyUsageBits) UnmarshalYAML added in v2.0.333

func (k *KeyUsageBits) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML reads a list of usage names.

type MSCertificateTemplate added in v2.0.333

type MSCertificateTemplate struct {
	// ID is the object identifier of the template.
	ID ID `json:"template_id" yaml:"template_id"`
	// MajorVersion is the optional major version of the template.
	MajorVersion *int `json:"major_version,omitempty" yaml:"major_version,omitempty"`
	// MinorVersion is the optional minor version of the template.
	MinorVersion *int `json:"minor_version,omitempty" yaml:"minor_version,omitempty"`
}

MSCertificateTemplate is the value of the Microsoft certificate template extension, version 2: the template an Active Directory Certificate Services CA issued the certificate from.

func (MSCertificateTemplate) MarshalDER added in v2.0.333

func (t MSCertificateTemplate) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the template.

func (*MSCertificateTemplate) UnmarshalDER added in v2.0.333

func (t *MSCertificateTemplate) UnmarshalDER(der []byte) error

UnmarshalDER decodes the template.

type NameConstraints added in v2.0.333

type NameConstraints struct {
	// Permitted lists the permitted subtrees.
	Permitted []GeneralName `json:"permitted,omitempty" yaml:"permitted,omitempty"`
	// Excluded lists the excluded subtrees.
	Excluded []GeneralName `json:"excluded,omitempty" yaml:"excluded,omitempty"`
}

NameConstraints is the value of the name constraints extension (RFC 5280, 4.2.1.10). A subtree is a GeneralName: a DNS domain, an email address or domain, a URI host, a directory name, or an IP range written as a prefix.

permitted:
  - dns: example.com
  - ip: 10.0.0.0/8

func (NameConstraints) MarshalDER added in v2.0.333

func (c NameConstraints) MarshalDER() ([]byte, error)

MarshalDER returns the DER of NameConstraints; it needs one subtree or more.

func (*NameConstraints) UnmarshalDER added in v2.0.333

func (c *NameConstraints) UnmarshalDER(der []byte) error

UnmarshalDER decodes NameConstraints. A subtree with a minimum or a maximum, which RFC 5280 forbids, is an error.

type NetscapeCertType added in v2.0.333

type NetscapeCertType []string

NetscapeCertType is the value of the legacy Netscape certificate type extension: the list of the uses of the certificate, such as "ssl server".

func (NetscapeCertType) MarshalDER added in v2.0.333

func (t NetscapeCertType) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the BIT STRING; it needs one use or more.

func (*NetscapeCertType) UnmarshalDER added in v2.0.333

func (t *NetscapeCertType) UnmarshalDER(der []byte) error

UnmarshalDER decodes the BIT STRING.

type Null added in v2.0.333

type Null struct{}

Null is the value of an extension that is present or absent and carries an ASN.1 NULL, such as OCSP no-check (RFC 6960, 4.2.2.2.1) or the precertificate poison (RFC 6962, 3.1). In YAML and JSON it is {}.

func (Null) MarshalDER added in v2.0.333

func (Null) MarshalDER() ([]byte, error)

MarshalDER returns the DER of NULL.

func (*Null) UnmarshalDER added in v2.0.333

func (*Null) UnmarshalDER(der []byte) error

UnmarshalDER decodes a NULL.

type OctetString added in v2.0.333

type OctetString []byte

OctetString is the value of an extension that is one OCTET STRING, such as the subject key identifier (RFC 5280, 4.2.1.2) or the ACME identifier (RFC 8737). In YAML and JSON it is written in hex, as HexBytes is.

func (OctetString) MarshalDER added in v2.0.333

func (o OctetString) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the OCTET STRING.

func (OctetString) MarshalText added in v2.0.333

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

MarshalText returns the bytes in lower case hex.

func (*OctetString) UnmarshalDER added in v2.0.333

func (o *OctetString) UnmarshalDER(der []byte) error

UnmarshalDER decodes an OCTET STRING.

func (*OctetString) UnmarshalText added in v2.0.333

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

UnmarshalText reads hex, or base64 with the "base64:" prefix.

type OtherName added in v2.0.333

type OtherName struct {
	// Type identifies the kind of name, for example "ms upn".
	Type ID `json:"type" yaml:"type"`
	// UTF8 is the value when it is a UTF8String, as in a Microsoft UPN.
	UTF8 string `json:"utf8,omitempty" yaml:"utf8,omitempty"`
	// Value is the DER of a value of any other type.
	Value HexBytes `json:"value,omitempty" yaml:"value,omitempty"`
}

OtherName is the otherName form of a GeneralName. Exactly one of UTF8 and Value is set.

type PolicyConstraints added in v2.0.333

type PolicyConstraints struct {
	// RequireExplicitPolicy is the number of certificates after which an
	// explicit policy is required.
	RequireExplicitPolicy *int `json:"require_explicit_policy,omitempty" yaml:"require_explicit_policy,omitempty"`
	// InhibitPolicyMapping is the number of certificates after which
	// policy mapping is no longer permitted.
	InhibitPolicyMapping *int `json:"inhibit_policy_mapping,omitempty" yaml:"inhibit_policy_mapping,omitempty"`
}

PolicyConstraints is the value of the policy constraints extension (RFC 5280, 4.2.1.11).

func (PolicyConstraints) MarshalDER added in v2.0.333

func (c PolicyConstraints) MarshalDER() ([]byte, error)

MarshalDER returns the DER of PolicyConstraints; it needs one field or both.

func (*PolicyConstraints) UnmarshalDER added in v2.0.333

func (c *PolicyConstraints) UnmarshalDER(der []byte) error

UnmarshalDER decodes PolicyConstraints.

type PolicyInformation added in v2.0.333

type PolicyInformation struct {
	// ID is the policy identifier.
	ID ID `json:"oid" yaml:"oid"`
	// Qualifiers lists the optional qualifiers.
	Qualifiers []PolicyQualifier `json:"qualifiers,omitempty" yaml:"qualifiers,omitempty"`
}

PolicyInformation is one certificate policy and its qualifiers.

type PolicyMapping added in v2.0.333

type PolicyMapping struct {
	// IssuerDomainPolicy is the policy in the issuer's domain.
	IssuerDomainPolicy ID `json:"issuer_domain_policy" yaml:"issuer_domain_policy"`
	// SubjectDomainPolicy is the policy in the subject's domain.
	SubjectDomainPolicy ID `json:"subject_domain_policy" yaml:"subject_domain_policy"`
}

PolicyMapping maps a policy of the issuer to an equivalent policy of the subject CA.

type PolicyMappings added in v2.0.333

type PolicyMappings []PolicyMapping

PolicyMappings is the value of the policy mappings extension (RFC 5280, 4.2.1.5).

func (PolicyMappings) MarshalDER added in v2.0.333

func (m PolicyMappings) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of mappings; it needs one or more.

func (*PolicyMappings) UnmarshalDER added in v2.0.333

func (m *PolicyMappings) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of mappings.

type PolicyQualifier added in v2.0.333

type PolicyQualifier struct {
	// Type is QualifierCPS, QualifierUserNotice, or the dotted decimals of
	// a qualifier given by its DER.
	Type string `json:"type" yaml:"type"`
	// Value is the CPS URI, the explicit text of the user notice, or for a
	// type in dotted decimals the hex of the DER of the qualifier.
	Value string `json:"value" yaml:"value"`
}

PolicyQualifier is one qualifier of a certificate policy, in the form a certificate profile uses.

type QCStatement added in v2.0.333

type QCStatement struct {
	// ID is the statement identifier, such as "qc compliance".
	ID ID `json:"id" yaml:"id"`
	// Info is the DER of the optional statement information.
	Info HexBytes `json:"info,omitempty" yaml:"info,omitempty"`
}

QCStatement is one statement of a qualified certificate.

type QCStatements added in v2.0.333

type QCStatements []QCStatement

QCStatements is the value of the qualified certificate statements extension (RFC 3739, 3.2.6; ETSI EN 319 412-5).

func (QCStatements) MarshalDER added in v2.0.333

func (q QCStatements) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of statements.

func (*QCStatements) UnmarshalDER added in v2.0.333

func (q *QCStatements) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of statements.

type SCT added in v2.0.333

type SCT struct {
	// Version is 1.
	Version int `json:"version" yaml:"version"`
	// LogID is the SHA-256 hash of the log's public key.
	LogID Base64Bytes `json:"log_id" yaml:"log_id"`
	// Timestamp is when the log promised to include the certificate, with
	// millisecond precision.
	Timestamp time.Time `json:"timestamp" yaml:"timestamp"`
	// Extensions is the opaque extensions field, usually empty.
	Extensions HexBytes `json:"extensions,omitempty" yaml:"extensions,omitempty"`
	// Algorithm is the algorithm of the signature.
	Algorithm SCTAlgorithm `json:"algorithm" yaml:"algorithm"`
	// Signature is the log's signature.
	Signature Base64Bytes `json:"signature" yaml:"signature"`
}

SCT is one signed certificate timestamp of RFC 6962.

type SCTAlgorithm added in v2.0.333

type SCTAlgorithm struct {
	// Hash is the TLS HashAlgorithm.
	Hash uint8
	// Signature is the TLS SignatureAlgorithm.
	Signature uint8
}

SCTAlgorithm is the signature algorithm of a signed certificate timestamp. In YAML and JSON it is "ecdsa-sha256" or "rsa-sha256"; an algorithm without a name is written by its TLS numbers, "3-4".

func (SCTAlgorithm) MarshalText added in v2.0.333

func (a SCTAlgorithm) MarshalText() ([]byte, error)

MarshalText returns the name of the algorithm.

func (SCTAlgorithm) String added in v2.0.333

func (a SCTAlgorithm) String() string

String returns the name of the algorithm.

func (*SCTAlgorithm) UnmarshalText added in v2.0.333

func (a *SCTAlgorithm) UnmarshalText(text []byte) error

UnmarshalText reads the name of the algorithm.

type SCTList added in v2.0.333

type SCTList []SCT

SCTList is the value of the signed certificate timestamp list extension (RFC 6962, 3.3): the promises of Certificate Transparency logs to include the certificate.

func (SCTList) MarshalDER added in v2.0.333

func (l SCTList) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the OCTET STRING that holds the list; it needs one timestamp or more.

func (*SCTList) UnmarshalDER added in v2.0.333

func (l *SCTList) UnmarshalDER(der []byte) error

UnmarshalDER decodes the OCTET STRING that holds the list.

type SMIMECapabilities added in v2.0.333

type SMIMECapabilities []SMIMECapability

SMIMECapabilities is the value of the S/MIME capabilities extension (RFC 4262): the algorithms the subject supports, in order of preference.

func (SMIMECapabilities) MarshalDER added in v2.0.333

func (c SMIMECapabilities) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of capabilities.

func (*SMIMECapabilities) UnmarshalDER added in v2.0.333

func (c *SMIMECapabilities) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of capabilities.

type SMIMECapability added in v2.0.333

type SMIMECapability struct {
	// ID identifies the capability, usually an algorithm.
	ID ID `json:"id" yaml:"id"`
	// Parameters is the DER of the optional parameters.
	Parameters HexBytes `json:"parameters,omitempty" yaml:"parameters,omitempty"`
}

SMIMECapability is one capability of an S/MIME client.

type TLSFeature added in v2.0.333

type TLSFeature int

TLSFeature is the number of a TLS extension. In YAML and JSON it is its name, "status_request" or "status_request_v2", or the number.

const (
	// TLSFeatureStatusRequest is status_request: the server must staple an
	// OCSP response ("OCSP Must-Staple").
	TLSFeatureStatusRequest TLSFeature = 5
	// TLSFeatureStatusRequestV2 is status_request_v2.
	TLSFeatureStatusRequestV2 TLSFeature = 17
)

TLS extension numbers a TLS feature extension usually lists.

func (TLSFeature) MarshalText added in v2.0.333

func (f TLSFeature) MarshalText() ([]byte, error)

MarshalText returns the name of the TLS extension, or its number.

func (TLSFeature) String added in v2.0.333

func (f TLSFeature) String() string

String returns the name of the TLS extension, or its number.

func (*TLSFeature) UnmarshalJSON added in v2.0.333

func (f *TLSFeature) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the name of a TLS extension, or its number as a string or a JSON number.

func (*TLSFeature) UnmarshalText added in v2.0.333

func (f *TLSFeature) UnmarshalText(text []byte) error

UnmarshalText reads the name or the number of a TLS extension.

type TLSFeatures added in v2.0.333

type TLSFeatures []TLSFeature

TLSFeatures is the value of the TLS feature extension (RFC 7633): the TLS extensions a server presenting the certificate must support.

[status_request]

func (TLSFeatures) MarshalDER added in v2.0.333

func (f TLSFeatures) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the sequence of TLS extension numbers; it needs one or more.

func (*TLSFeatures) UnmarshalDER added in v2.0.333

func (f *TLSFeatures) UnmarshalDER(der []byte) error

UnmarshalDER decodes a sequence of TLS extension numbers.

type TNAuthList added in v2.0.333

type TNAuthList []TNEntry

TNAuthList is the value of the TN authorization list extension (RFC 8226, 9) of a STIR/SHAKEN certificate: the service provider codes and telephone numbers the subject is authorized for.

  • spc: "709J"
  • range: start: "12025550100" count: 100

func (TNAuthList) MarshalDER added in v2.0.333

func (l TNAuthList) MarshalDER() ([]byte, error)

MarshalDER returns the DER of the TNAuthorizationList; it needs one entry or more.

func (*TNAuthList) UnmarshalDER added in v2.0.333

func (l *TNAuthList) UnmarshalDER(der []byte) error

UnmarshalDER decodes a TNAuthorizationList.

type TNEntry added in v2.0.333

type TNEntry struct {
	// SPC is a service provider code, such as an OCN.
	SPC string `json:"spc,omitempty" yaml:"spc,omitempty"`
	// Range is a range of telephone numbers.
	Range *TNRange `json:"range,omitempty" yaml:"range,omitempty"`
	// One is one telephone number: 1 to 15 of the characters 0-9, # and *.
	One string `json:"one,omitempty" yaml:"one,omitempty"`
}

TNEntry is one entry of a TN authorization list, with exactly one field set. Quote the numbers in YAML: an unquoted number is read as an integer and loses a leading zero.

type TNRange added in v2.0.333

type TNRange struct {
	// Start is the first telephone number of the range.
	Start string `json:"start" yaml:"start"`
	// Count is the number of telephone numbers, two or more.
	Count int `json:"count" yaml:"count"`
}

TNRange is a range of telephone numbers: Count numbers from Start.

Jump to

Keyboard shortcuts

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