Beispiel #1
0
func extKeyUsageFromOID(oid asn1.ObjectIdentifier) (eku ExtKeyUsage, ok bool) {
	for _, pair := range extKeyUsageOIDs {
		if oid.Equal(pair.oid) {
			return pair.extKeyUsage, true
		}
	}
	return
}
Beispiel #2
0
func curveOidToString(oid asn1.ObjectIdentifier) (t string, bitlen int) {
	switch {
	case oid.Equal(OidNamedCurveP224):
		return "secp224r1", 224
	case oid.Equal(OidNamedCurveP256):
		return "prime256v1", 256
	case oid.Equal(OidNamedCurveP384):
		return "secp384r1", 384
	case oid.Equal(OidNamedCurveP521):
		return "secp521r1", 521
	}
	return fmt.Sprintf("%v", oid), -1
}
Beispiel #3
0
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
}
Beispiel #4
0
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
}
Beispiel #5
0
// OidForStandardExtension indicates whether oid identifies a standard extension.
// Standard extensions are listed in RFC 5280 (and other RFCs).
func OidForStandardExtension(oid asn1.ObjectIdentifier) bool {
	if oid.Equal(OidExtensionSubjectKeyId) ||
		oid.Equal(OidExtensionKeyUsage) ||
		oid.Equal(OidExtensionExtendedKeyUsage) ||
		oid.Equal(OidExtensionAuthorityKeyId) ||
		oid.Equal(OidExtensionBasicConstraints) ||
		oid.Equal(OidExtensionSubjectAltName) ||
		oid.Equal(OidExtensionCertificatePolicies) ||
		oid.Equal(OidExtensionNameConstraints) ||
		oid.Equal(OidExtensionCRLDistributionPoints) ||
		oid.Equal(OidExtensionIssuerAltName) ||
		oid.Equal(OidExtensionSubjectDirectoryAttributes) ||
		oid.Equal(OidExtensionInhibitAnyPolicy) ||
		oid.Equal(OidExtensionPolicyConstraints) ||
		oid.Equal(OidExtensionPolicyMappings) ||
		oid.Equal(OidExtensionFreshestCRL) ||
		oid.Equal(OidExtensionSubjectInfoAccess) ||
		oid.Equal(OidExtensionAuthorityInfoAccess) ||
		oid.Equal(OidExtensionCTPoison) ||
		oid.Equal(OidExtensionCTSCT) {
		return true
	}
	return false
}
Beispiel #6
0
func attributeOidToString(oid asn1.ObjectIdentifier) string {
	switch {
	case oid.Equal(OidCountry):
		return "Country"
	case oid.Equal(OidOrganization):
		return "Organization"
	case oid.Equal(OidOrganizationalUnit):
		return "OrganizationalUnit"
	case oid.Equal(OidCommonName):
		return "CommonName"
	case oid.Equal(OidSerialNumber):
		return "SerialNumber"
	case oid.Equal(OidLocality):
		return "Locality"
	case oid.Equal(OidProvince):
		return "Province"
	case oid.Equal(OidStreetAddress):
		return "StreetAddress"
	case oid.Equal(OidPostalCode):
		return "PostalCode"
	case oid.Equal(OidPseudonym):
		return "Pseudonym"
	case oid.Equal(OidTitle):
		return "Title"
	case oid.Equal(OidDnQualifier):
		return "DnQualifier"
	case oid.Equal(OidName):
		return "Name"
	case oid.Equal(OidSurname):
		return "Surname"
	case oid.Equal(OidGivenName):
		return "GivenName"
	case oid.Equal(OidInitials):
		return "Initials"
	case oid.Equal(OidGenerationQualifier):
		return "GenerationQualifier"
	default:
		return oid.String()
	}
}
Beispiel #7
0
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
	case oid.Equal(oidSignatureECDSAWithSHA1):
		return ECDSAWithSHA1
	case oid.Equal(oidSignatureECDSAWithSHA256):
		return ECDSAWithSHA256
	case oid.Equal(oidSignatureECDSAWithSHA384):
		return ECDSAWithSHA384
	case oid.Equal(oidSignatureECDSAWithSHA512):
		return ECDSAWithSHA512
	}
	return UnknownSignatureAlgorithm
}