skid

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package skid provides type SKID, along with supporting functions and methods. SKID is a byte slice representing an x509 Subject Key Identifier as defined by RFC-5280 Section 4.2.1.2.

SKID values constructed by this package are compatible with those generated by openssl or the standard library's crtpto/x509 package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCertificate = errors.New("nil cert")
	ErrNoCSR         = errors.New("nil csr")
)

Functions

This section is empty.

Types

type SKID

type SKID []byte

SKID is a byte slice representing an x509 Subject Key Identifier per RFC-5280 Section 4.2.1.2.

func FromCSR

func FromCSR(csr *x509.CertificateRequest) (SKID, error)

FromCSR returns a SKID constructed using the public key contained within the given certificate request. If csr is nil, then FromCSR returns a nil SKID and ErrNoCSR.

func FromCertificate

func FromCertificate(cert *x509.Certificate) (SKID, error)

FromCertificate returns a SKID from the given certificate. If cert is nil then FromCertificate returns a nil skid and ErrNoCertificate. If the given certificate has no Subject Key Identifier, one will be generated from its Public Key (if possible) by calling FromPublicKey.

func FromPublicKey

func FromPublicKey(pub crypto.PublicKey) (SKID, error)

FromPublicKey returns a SKID constructed from the given public key or nil and an error if pub is of an unsupported type.

Currently supported key types are the same as for the standard library's x509.CreateCertificate function -- namely: *rsa.PublicKey, *ecdsa.PublicKey, and *ed25519.PublicKey.

Additionally, FromPublicKey may also return an error if pub is of type *rsa.PublicKey and fails to encode as ASN.1.

func FromString

func FromString(s string) (SKID, error)

FromString returns a SKID value parsed from the given string -- which should be a colon-separated, hexadecimal representattion (as generated by SKID's String method). If s is the empty string then FromString will return a nil SKID and no error. FromString will return a non-nil error if any of its elements fails to parse as a hexadecimal value.

func (SKID) Equal

func (s SKID) Equal(o SKID) bool

Equal returns true if the receiver and the argument are both nil or if all of their values agree -- or false if either are nil (but not both), their lengths are different, or if any of their values disagree.

func (SKID) String

func (s SKID) String() string

String returns the colon-separated, hexadecimal representating of the receiver -- similar to the following:

"67:ED:5B:3B:3B:82:BE:2C:2C:60:E5:ED:5B:39:5F:19:BC:BB:E7:B8"

Jump to

Keyboard shortcuts

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