func namedCurveFromOID(oid asn1.ObjectIdentifier) *bitelliptic.BitCurve { switch { case oid.Equal(oidNamedCurveS256): return bitelliptic.S256() } return nil }
func getHashForOID(oid asn1.ObjectIdentifier) (crypto.Hash, error) { switch { case oid.Equal(oidDigestAlgorithmSHA1): return crypto.SHA1, nil } return crypto.Hash(0), ErrUnsupportedAlgorithm }
// TODO(agl): this is taken from crypto/x509 and so should probably be exported // from crypto/x509 or crypto/x509/pkix. func getSignatureAlgorithmFromOID(oid asn1.ObjectIdentifier) x509.SignatureAlgorithm { for _, details := range signatureAlgorithmDetails { if oid.Equal(details.oid) { return details.algo } } return x509.UnknownSignatureAlgorithm }
func extKeyUsageFromOID(oid asn1.ObjectIdentifier) (eku ExtKeyUsage, ok bool) { for _, pair := range extKeyUsageOIDs { if oid.Equal(pair.oid) { return pair.extKeyUsage, true } } return }
func getPublicKeyAlgorithmFromOID(oid asn1.ObjectIdentifier) PublicKeyAlgorithm { switch { case oid.Equal(oidPublicKeyRsa): return RSA case oid.Equal(oidPublicKeyDsa): return DSA } return UnknownPublicKeyAlgorithm }
func getAttributeNameFromOID(oid asn1.ObjectIdentifier) CsrAttribute { switch { case oid.Equal(oidAttrUnstructuredName): return CsrAttrUnstructuredName case oid.Equal(oidAttrChallengePassword): return CsrAttrChallengePassword } return CsrAttrUnknown }
func hashFromOID(oid asn1.ObjectIdentifier) func() hash.Hash { switch { case oid.Equal(oidSHA1): return sha1.New case oid.Equal(oidSHA224): return sha256.New224 case oid.Equal(oidSHA256): return sha256.New case oid.Equal(oidSHA384): return sha512.New384 case oid.Equal(oidSHA512): return sha512.New } return nil }
func namedCurveFromOID(oid asn1.ObjectIdentifier) elliptic.Curve { switch { case oid.Equal(oidNamedCurveP224): return elliptic.P224() case oid.Equal(oidNamedCurveP256): return elliptic.P256() case oid.Equal(oidNamedCurveP384): return elliptic.P384() case oid.Equal(oidNamedCurveP521): return elliptic.P521() } return nil }
func getTagForOid(oid asn1.ObjectIdentifier) string { type oidNameMap struct { oid []int name string } oidTags := []oidNameMap{ {[]int{2, 5, 4, 3}, "CN"}, {[]int{2, 5, 4, 5}, "SN"}, {[]int{2, 5, 4, 6}, "C"}, {[]int{2, 5, 4, 7}, "L"}, {[]int{2, 5, 4, 8}, "ST"}, {[]int{2, 5, 4, 10}, "O"}, {[]int{2, 5, 4, 11}, "OU"}, {[]int{1, 2, 840, 113549, 1, 9, 1}, "E"}} for _, v := range oidTags { if oid.Equal(v.oid) { return v.name } } return fmt.Sprint(oid) }
func getPublicKeyAlgorithmFromOID(oid asn1.ObjectIdentifier) x509.PublicKeyAlgorithm { switch { case oid.Equal(oidPublicKeyRSA): return x509.RSA case oid.Equal(oidPublicKeyDSA): return x509.DSA case oid.Equal(oidPublicKeyECDSA): return x509.ECDSA } return x509.UnknownPublicKeyAlgorithm }
func oidToCurve(oid asn1.ObjectIdentifier) elliptic.Curve { switch { case oid.Equal(asn1secp256r1): return elliptic.P256() case oid.Equal(asn1secp384r1): return elliptic.P384() case oid.Equal(asn1secp521r1): return elliptic.P521() default: return nil } }
func getSignatureAlgorithmFromOID(oid asn1.ObjectIdentifier) SignatureAlgorithm { switch { case oid.Equal(oidSignatureMD2WithRSA): return MD2WithRSA case oid.Equal(oidSignatureMD5WithRSA): return MD5WithRSA case oid.Equal(oidSignatureSHA1WithRSA): return SHA1WithRSA case oid.Equal(oidSignatureSHA256WithRSA): return SHA256WithRSA case oid.Equal(oidSignatureSHA384WithRSA): return SHA384WithRSA case oid.Equal(oidSignatureSHA512WithRSA): return SHA512WithRSA case oid.Equal(oidSignatureDSAWithSHA1): return DSAWithSHA1 case oid.Equal(oidSignatureDSAWithSHA256): return DSAWithSHA256 } return UnknownSignatureAlgorithm }
func oidToHash(oid asn1.ObjectIdentifier) crypto.Hash { switch { case oid.Equal(asn1SHA1withRSA): return crypto.SHA1 case oid.Equal(asn1SHA224withRSA): return crypto.SHA224 case oid.Equal(asn1SHA256withRSA): return crypto.SHA256 case oid.Equal(asn1SHA384withRSA): return crypto.SHA384 case oid.Equal(asn1SHA512withRSA): return crypto.SHA512 case oid.Equal(asn1SHA1withECDSA): return crypto.SHA1 case oid.Equal(asn1SHA224withECDSA): return crypto.SHA224 case oid.Equal(asn1SHA256withECDSA): return crypto.SHA256 case oid.Equal(asn1SHA384withECDSA): return crypto.SHA384 case oid.Equal(asn1SHA512withECDSA): return crypto.SHA512 default: return 0 } }
func getSignatureAlgorithmFromOID(oid asn1.ObjectIdentifier) x509.SignatureAlgorithm { switch { case oid.Equal(oidSignatureMD2WithRSA): return x509.MD2WithRSA case oid.Equal(oidSignatureMD5WithRSA): return x509.MD5WithRSA case oid.Equal(oidSignatureSHA1WithRSA): return x509.SHA1WithRSA case oid.Equal(oidSignatureSHA256WithRSA): return x509.SHA256WithRSA case oid.Equal(oidSignatureSHA384WithRSA): return x509.SHA384WithRSA case oid.Equal(oidSignatureSHA512WithRSA): return x509.SHA512WithRSA case oid.Equal(oidSignatureDSAWithSHA1): return x509.DSAWithSHA1 case oid.Equal(oidSignatureDSAWithSHA256): return x509.DSAWithSHA256 case oid.Equal(oidSignatureECDSAWithSHA1): return x509.ECDSAWithSHA1 case oid.Equal(oidSignatureECDSAWithSHA256): return x509.ECDSAWithSHA256 case oid.Equal(oidSignatureECDSAWithSHA384): return x509.ECDSAWithSHA384 case oid.Equal(oidSignatureECDSAWithSHA512): return x509.ECDSAWithSHA512 } return x509.UnknownSignatureAlgorithm }
func getPublicKeyAlgorithmFromOID(oid asn1.ObjectIdentifier) x509.PublicKeyAlgorithm { if oid.Equal(oidPublicKeyRSA) { return x509.RSA } return x509.UnknownPublicKeyAlgorithm }