oid

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AlgUnknown specifies unknow algorithm
	AlgUnknown = iota
	// AlgHash specifies hash
	AlgHash
	// AlgPubKey specifies public key
	AlgPubKey
	// AlgSig specifies signature
	AlgSig
)

Variables

View Source
var (
	Data       = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 1}
	SignedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2}
	TSTInfo    = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 16, 1, 4}
)

Content type OIDs

View Source
var (
	AttributeContentType    = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 3}
	AttributeMessageDigest  = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 4}
	AttributeSigningTime    = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 5}
	AttributeTimeStampToken = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 16, 2, 14}
)

Attribute OIDs

View Source
var (
	SignatureAlgorithmRSA   = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1}
	SignatureAlgorithmECDSA = asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1}
)

Signature Algorithm OIDs

View Source
var (
	DigestAlgorithmSHA1     = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26}
	DigestAlgorithmMD5      = asn1.ObjectIdentifier{1, 2, 840, 113549, 2, 5}
	DigestAlgorithmSHA256   = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 1}
	DigestAlgorithmSHA384   = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 2}
	DigestAlgorithmSHA512   = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 3}
	DigestAlgorithmSHA3x224 = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 7}
)

Digest Algorithm OIDs

View Source
var AlgNameToInfo = map[string]Info{
	"RSA":             RSA,
	"ECDSA":           ECDSA,
	"SHA1":            SHA1,
	"SHA256":          SHA256,
	"SHA384":          SHA384,
	"SHA512":          SHA512,
	"SHA3x224":        SHA3x224,
	"SHA3-224":        SHA3x224,
	"SHA3x256":        SHA3x256,
	"SHA3-256":        SHA3x256,
	"SHA3x384":        SHA3x384,
	"SHA3-384":        SHA3x384,
	"SHA3x512":        SHA3x512,
	"SHA3-512":        SHA3x512,
	"SHAKE128":        SHAKE128,
	"SHAKE-128":       SHAKE128,
	"SHAKE256":        SHAKE256,
	"SHAKE-256":       SHAKE256,
	"RSAWithSHA1":     RSAWithSHA1,
	"RSA-SHA1":        RSAWithSHA1,
	"RSA_SHA1":        RSAWithSHA1,
	"RSAWithSHA256":   RSAWithSHA256,
	"RSA-SHA256":      RSAWithSHA256,
	"RSA_SHA256":      RSAWithSHA256,
	"RSAWithSHA384":   RSAWithSHA384,
	"RSA-SHA384":      RSAWithSHA384,
	"RSA_SHA384":      RSAWithSHA384,
	"RSAWithSHA512":   RSAWithSHA512,
	"RSA-SHA512":      RSAWithSHA512,
	"RSA_SHA512":      RSAWithSHA512,
	"ECDSAWithSHA1":   ECDSAWithSHA1,
	"ECDSA-SHA1":      ECDSAWithSHA1,
	"ECDSA_SHA1":      ECDSAWithSHA1,
	"ECDSAWithSHA256": ECDSAWithSHA256,
	"ECDSA-SHA256":    ECDSAWithSHA256,
	"ECDSA_SHA256":    ECDSAWithSHA256,
	"ECDSAWithSHA384": ECDSAWithSHA384,
	"ECDSA-SHA384":    ECDSAWithSHA384,
	"ECDSA_SHA384":    ECDSAWithSHA384,
	"ECDSAWithSHA512": ECDSAWithSHA512,
	"ECDSA-SHA512":    ECDSAWithSHA512,
	"ECDSA_SHA512":    ECDSAWithSHA512,
}

AlgNameToInfo provides mapping from algorith name to Info

DigestAlgorithmToHash maps digest OIDs to crypto.Hash values.

View Source
var ECDSA = PublicKeyAlgorithmInfo{
	// contains filtered or unexported fields
}

ECDSA specifies RFC 3279, Algorithms and Identifiers for the Internet X.509 Public Key Infrastructure

View Source
var ECDSAWithSHA1 = SignatureAlgorithmInfo{

	X509:               x509.ECDSAWithSHA1,
	PublicKeyAlgorithm: &ECDSA,
	HashAlgorithm:      &SHA1,
	// contains filtered or unexported fields
}

ECDSAWithSHA1 described in RFC 3279 2.2.3 ECDSA Signature Algorithm

View Source
var ECDSAWithSHA256 = SignatureAlgorithmInfo{

	X509:               x509.ECDSAWithSHA256,
	PublicKeyAlgorithm: &ECDSA,
	HashAlgorithm:      &SHA256,
	// contains filtered or unexported fields
}

ECDSAWithSHA256 described in RFC 5758 3.2 ECDSA Signature Algorithm

View Source
var ECDSAWithSHA384 = SignatureAlgorithmInfo{

	X509:               x509.ECDSAWithSHA384,
	PublicKeyAlgorithm: &ECDSA,
	HashAlgorithm:      &SHA384,
	// contains filtered or unexported fields
}

ECDSAWithSHA384 described in RFC 5758 3.2 ECDSA Signature Algorithm

View Source
var ECDSAWithSHA512 = SignatureAlgorithmInfo{

	X509:               x509.ECDSAWithSHA512,
	PublicKeyAlgorithm: &ECDSA,
	HashAlgorithm:      &SHA512,
	// contains filtered or unexported fields
}

ECDSAWithSHA512 described in RFC 5758 3.2 ECDSA Signature Algorithm

HashToDigestAlgorithm maps crypto.Hash values to digest OIDs.

View Source
var OIDStrToInfo = map[string]Info{
	"1.2.840.113549.1.1.1":    RSA,
	"1.2.840.10045.2.1":       ECDSA,
	"1.3.14.3.2.26":           SHA1,
	"2.16.840.1.101.3.4.2.1":  SHA256,
	"2.16.840.1.101.3.4.2.2":  SHA384,
	"2.16.840.1.101.3.4.2.3":  SHA512,
	"2.16.840.1.101.3.4.2.7":  SHA3x224,
	"2.16.840.1.101.3.4.2.8":  SHA3x256,
	"2.16.840.1.101.3.4.2.9":  SHA3x384,
	"2.16.840.1.101.3.4.2.10": SHA3x512,
	"2.16.840.1.101.3.4.2.11": SHAKE128,
	"2.16.840.1.101.3.4.2.12": SHAKE256,
	"1.2.840.113549.1.1.5":    RSAWithSHA1,
	"1.2.840.113549.1.1.11":   RSAWithSHA256,
	"1.2.840.113549.1.1.12":   RSAWithSHA384,
	"1.2.840.113549.1.1.13":   RSAWithSHA512,
	"1.2.840.10045.4.1":       ECDSAWithSHA1,
	"1.2.840.10045.4.3.2":     ECDSAWithSHA256,
	"1.2.840.10045.4.3.3":     ECDSAWithSHA384,
	"1.2.840.10045.4.3.4":     ECDSAWithSHA512,
}

OIDStrToInfo provides mapping from OID string to Info

View Source
var PublicKeyAlgorithmToSignatureAlgorithm = map[x509.PublicKeyAlgorithm]pkix.AlgorithmIdentifier{
	x509.RSA:   {Algorithm: SignatureAlgorithmRSA},
	x509.ECDSA: {Algorithm: SignatureAlgorithmECDSA},
}

PublicKeyAlgorithmToSignatureAlgorithm maps certificate public key algorithms to CMS signature algorithms.

View Source
var RSA = PublicKeyAlgorithmInfo{
	// contains filtered or unexported fields
}

RSA specifies RFC 3279, 2.3 Public Key Algorithm info

View Source
var RSAWithSHA1 = SignatureAlgorithmInfo{

	X509:               x509.SHA1WithRSA,
	PublicKeyAlgorithm: &RSA,
	HashAlgorithm:      &SHA1,
	// contains filtered or unexported fields
}

RSAWithSHA1 described in RFC 3279 2.2.1 RSA Signature Algorithms

View Source
var RSAWithSHA256 = SignatureAlgorithmInfo{

	X509:               x509.SHA256WithRSA,
	PublicKeyAlgorithm: &RSA,
	HashAlgorithm:      &SHA256,
	// contains filtered or unexported fields
}

RSAWithSHA256 described in RFC 4055 5 PKCS #1 Version 1.5

View Source
var RSAWithSHA384 = SignatureAlgorithmInfo{

	X509:               x509.SHA384WithRSA,
	PublicKeyAlgorithm: &RSA,
	HashAlgorithm:      &SHA384,
	// contains filtered or unexported fields
}

RSAWithSHA384 described in RFC 4055 5 PKCS #1 Version 1.5

View Source
var RSAWithSHA512 = SignatureAlgorithmInfo{

	X509:               x509.SHA512WithRSA,
	PublicKeyAlgorithm: &RSA,
	HashAlgorithm:      &SHA512,
	// contains filtered or unexported fields
}

RSAWithSHA512 described in RFC 4055 5 PKCS #1 Version 1.5

View Source
var SHA1 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA1 described in RFC 3370, Cryptographic Message Syntax (CMS) Algorithms

View Source
var SHA256 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA256 described in RFC 3560, Use of the RSAES-OAEP Key Transport Algorithm in the Cryptographic Message Syntax (CMS)

View Source
var SHA384 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA384 described in RFC 3560, Use of the RSAES-OAEP Key Transport Algorithm in the Cryptographic Message Syntax (CMS)

View Source
var SHA3x224 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA3x224 described in RFC for SHA-3 is pending

View Source
var SHA3x256 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA3x256 described in RFC for SHA-3 is pending

View Source
var SHA3x384 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA3x384 described in RFC for SHA-3 is pending

View Source
var SHA3x512 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA3x512 described in RFC for SHA-3 is pending

View Source
var SHA512 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHA512 described in RFC 3560, Use of the RSAES-OAEP Key Transport Algorithm in the Cryptographic Message Syntax (CMS)

View Source
var SHAKE128 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHAKE128 described in RFC for SHA-3 is pending

View Source
var SHAKE256 = HashAlgorithmInfo{
	// contains filtered or unexported fields
}

SHAKE256 described in RFC for SHA-3 is pending

SignatureAlgorithmToDigestAlgorithm maps x509.SignatureAlgorithm to digestAlgorithm OIDs.

SignatureAlgorithmToSignatureAlgorithm maps x509.SignatureAlgorithm to signatureAlgorithm OIDs.

SignatureAlgorithms maps digest and signature OIDs to x509.SignatureAlgorithm values.

View Source
var (
	SubjectKeyIdentifier = asn1.ObjectIdentifier{2, 5, 29, 14}
)

X509 extensions

Functions

func NewObjectIdentifier

func NewObjectIdentifier(oid string) (oi asn1.ObjectIdentifier, err error)

NewObjectIdentifier creates an object identifier from it's string representation. Supports ASN.1 notation and dot notation. OID-IRI notation is not supported.

Types

type AlgType

type AlgType int

AlgType specifies OID algorithm type

type HashAlgorithmInfo

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

HashAlgorithmInfo provides OID info for Hash algorithms

func HashAlgorithmByCrypto

func HashAlgorithmByCrypto(hash crypto.Hash) *HashAlgorithmInfo

HashAlgorithmByCrypto returns an algorithm by crypto identifier

func HashAlgorithmByName

func HashAlgorithmByName(name string) (*HashAlgorithmInfo, error)

HashAlgorithmByName returns an algorithm by name

func HashAlgorithmByOID

func HashAlgorithmByOID(oid string) (*HashAlgorithmInfo, error)

HashAlgorithmByOID returns an algorithm by OID

func HashAlgorithmForPublicKey

func HashAlgorithmForPublicKey(pub crypto.PublicKey) *HashAlgorithmInfo

HashAlgorithmForPublicKey returns a suitable hash algorithm for public key

func (HashAlgorithmInfo) HashFunc

func (h HashAlgorithmInfo) HashFunc() crypto.Hash

HashFunc allows HashAlgorithmInfo to satisfry the crypto.SignerOpts interface for signing digests. You can use a cryptoid.HashAlgorithm directly when using a crypto.Signer interface to sign digests.

func (HashAlgorithmInfo) Name

func (h HashAlgorithmInfo) Name() string

Name is friendly name of the OID: SHA1, etc

func (HashAlgorithmInfo) OID

OID is ASN1 ObjectIdentifier

func (HashAlgorithmInfo) Registration

func (h HashAlgorithmInfo) Registration() string

Registration returns official registration info in "{iso(1) identified-organization(3) oiw(14) secsig(3) algorithm(2) 26}" format

func (HashAlgorithmInfo) String

func (h HashAlgorithmInfo) String() string

String returns string representation of OID: "1.2.840.113549.1"

func (HashAlgorithmInfo) Type

func (h HashAlgorithmInfo) Type() AlgType

Type specifies OID algorithm type for Hash

type Info

type Info interface {
	// Name is friendly name of the OID: SHA1, etc
	Name() string
	// Type returns AlgType
	Type() AlgType
	// OID is ASN1 ObjectIdentifier
	OID() asn1.ObjectIdentifier
	// Registration returns official registration info in
	// "{iso(1) identified-organization(3) oiw(14) secsig(3) algorithm(2) 26}" format
	Registration() string
	// String returns string representation of OID: "1.2.840.113549.1"
	String() string
}

Info provides basic OID info: friendly name, OID and registration string

func LookupByName

func LookupByName(name string) Info

LookupByName returns an algorithm by name

func LookupByOID

func LookupByOID(oid string) Info

LookupByOID returns an algorithm by OID

type PublicKeyAlgorithmInfo

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

PublicKeyAlgorithmInfo provides OID info for Public Key algorithms

func PublicKeyAlgorithmByName

func PublicKeyAlgorithmByName(name string) (*PublicKeyAlgorithmInfo, error)

PublicKeyAlgorithmByName returns an algorithm by name

func PublicKeyAlgorithmByOID

func PublicKeyAlgorithmByOID(oid string) (*PublicKeyAlgorithmInfo, error)

PublicKeyAlgorithmByOID returns an algorithm by OID

func SignatureAlgorithmByKey

func SignatureAlgorithmByKey(pkey interface{}) (*PublicKeyAlgorithmInfo, error)

SignatureAlgorithmByKey returns an algorithm by key

func (PublicKeyAlgorithmInfo) Algorithm

Algorithm returns x509.PublicKeyAlgorithm

func (PublicKeyAlgorithmInfo) Name

func (h PublicKeyAlgorithmInfo) Name() string

Name is friendly name of the OID: SHA1, etc

func (PublicKeyAlgorithmInfo) OID

OID is ASN1 ObjectIdentifier

func (PublicKeyAlgorithmInfo) Registration

func (h PublicKeyAlgorithmInfo) Registration() string

Registration returns official registration info in "{iso(1) identified-organization(3) oiw(14) secsig(3) algorithm(2) 26}" format

func (PublicKeyAlgorithmInfo) String

func (h PublicKeyAlgorithmInfo) String() string

String returns string representation of OID: "1.2.840.113549.1"

func (PublicKeyAlgorithmInfo) Type

Type specifies OID algorithm type for PubKey

type SignatureAlgorithmInfo

type SignatureAlgorithmInfo struct {
	X509               x509.SignatureAlgorithm
	PublicKeyAlgorithm *PublicKeyAlgorithmInfo
	HashAlgorithm      *HashAlgorithmInfo
	// contains filtered or unexported fields
}

SignatureAlgorithmInfo provides OID info for Signature algorithms

func SignatureAlgorithmByKeyAndHash

func SignatureAlgorithmByKeyAndHash(pkey interface{}, hash crypto.Hash) (*SignatureAlgorithmInfo, error)

SignatureAlgorithmByKeyAndHash returns an algorithm by key and Hash

func SignatureAlgorithmByName

func SignatureAlgorithmByName(name string) (SignatureAlgorithmInfo, error)

SignatureAlgorithmByName returns an algorithm by name

func SignatureAlgorithmByOID

func SignatureAlgorithmByOID(oid string) (*SignatureAlgorithmInfo, error)

SignatureAlgorithmByOID returns an algorithm by OID

func SignatureAlgorithmByX509

func SignatureAlgorithmByX509(sig x509.SignatureAlgorithm) *SignatureAlgorithmInfo

SignatureAlgorithmByX509 returns an algorithm by X509 identifier

func (SignatureAlgorithmInfo) HashFunc

func (h SignatureAlgorithmInfo) HashFunc() crypto.Hash

HashFunc allows SignatureAlgorithmInfo to satisfry the crypto.SignerOpts interface for signing digests. You can use a cryptoid.HashAlgorithm directly when using a crypto.Signer interface to sign digests.

func (SignatureAlgorithmInfo) Name

func (h SignatureAlgorithmInfo) Name() string

Name is friendly name of the OID: SHA1, etc

func (SignatureAlgorithmInfo) OID

OID is ASN1 ObjectIdentifier

func (SignatureAlgorithmInfo) Registration

func (h SignatureAlgorithmInfo) Registration() string

Registration returns official registration info in "{iso(1) identified-organization(3) oiw(14) secsig(3) algorithm(2) 26}" format

func (SignatureAlgorithmInfo) String

func (h SignatureAlgorithmInfo) String() string

String returns string representation of OID: "1.2.840.113549.1"

func (SignatureAlgorithmInfo) Type

Type specifies OID algorithm type for Sig

Jump to

Keyboard shortcuts

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