Golang encoding/asn1.ObjectIdentifier type, Equal and String inner functions example

package encoding/asn1

An ObjectIdentifier represents an ASN.1 OBJECT IDENTIFIER.


Equal reports whether oi and other represent the same identifier.

Golang encoding/asn1.ObjectIdentifier type, Equal and String inner functions usage example ( taken from http://golang.org/src/pkg/crypto/x509/x509.go )

 func getPublicKeyAlgorithmFromOID(oid asn1.ObjectIdentifier) PublicKeyAlgorithm {
  switch {
  case oid.Equal(oidPublicKeyRSA):
 return RSA
  case oid.Equal(oidPublicKeyDSA):
 return DSA
  case oid.Equal(oidPublicKeyECDSA):
 return ECDSA
  }
  return UnknownPublicKeyAlgorithm
 }

Reference :

http://golang.org/pkg/encoding/asn1/#ObjectIdentifier

Advertisement