Path: blob/master/src/java.base/share/classes/sun/security/util/KnownOIDs.java
58327 views
/*1* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.security.util;2627import java.util.List;28import java.util.Locale;29import java.util.Objects;30import java.util.concurrent.ConcurrentHashMap;3132/**33* This utility class maps algorithm name to the corresponding oid strings.34* NOTE: for 100% backward compatibility, the standard name for the enum35* is determined by existing usage and may be in lowercase/uppercase in36* order to match existing output.37*/38public enum KnownOIDs {3940// X.500 Attributes 2.5.4.*41CommonName("2.5.4.3"),42Surname("2.5.4.4"),43SerialNumber("2.5.4.5"),44CountryName("2.5.4.6"),45LocalityName("2.5.4.7"),46StateName("2.5.4.8"),47StreetAddress("2.5.4.9"),48OrgName("2.5.4.10"),49OrgUnitName("2.5.4.11"),50Title("2.5.4.12"),51GivenName("2.5.4.42"),52Initials("2.5.4.43"),53GenerationQualifier("2.5.4.44"),54DNQualifier("2.5.4.46"),5556// Certificate Extension 2.5.29.*57SubjectDirectoryAttributes("2.5.29.9"),58SubjectKeyID("2.5.29.14"),59KeyUsage("2.5.29.15"),60PrivateKeyUsage("2.5.29.16"),61SubjectAlternativeName("2.5.29.17"),62IssuerAlternativeName("2.5.29.18"),63BasicConstraints("2.5.29.19"),64CRLNumber("2.5.29.20"),65ReasonCode("2.5.29.21"),66HoldInstructionCode("2.5.29.23"),67InvalidityDate("2.5.29.24"),68DeltaCRLIndicator("2.5.29.27"),69IssuingDistributionPoint("2.5.29.28"),70CertificateIssuer("2.5.29.29"),71NameConstraints("2.5.29.30"),72CRLDistributionPoints("2.5.29.31"),73CertificatePolicies("2.5.29.32"),74CE_CERT_POLICIES_ANY("2.5.29.32.0"),75PolicyMappings("2.5.29.33"),76AuthorityKeyID("2.5.29.35"),77PolicyConstraints("2.5.29.36"),78extendedKeyUsage("2.5.29.37"),79anyExtendedKeyUsage("2.5.29.37.0"),80FreshestCRL("2.5.29.46"),81InhibitAnyPolicy("2.5.29.54"),8283// PKIX 1.3.6.1.5.5.7.84AuthInfoAccess("1.3.6.1.5.5.7.1.1"),85SubjectInfoAccess("1.3.6.1.5.5.7.1.11"),86// key usage purposes - PKIX.3.*87serverAuth("1.3.6.1.5.5.7.3.1"),88clientAuth("1.3.6.1.5.5.7.3.2"),89codeSigning("1.3.6.1.5.5.7.3.3"),90emailProtection("1.3.6.1.5.5.7.3.4"),91ipsecEndSystem("1.3.6.1.5.5.7.3.5"),92ipsecTunnel("1.3.6.1.5.5.7.3.6"),93ipsecUser("1.3.6.1.5.5.7.3.7"),94KP_TimeStamping("1.3.6.1.5.5.7.3.8", "timeStamping") {95@Override96boolean registerNames() { return false; }97},98OCSPSigning("1.3.6.1.5.5.7.3.9"),99// access descriptors - PKIX.48.*100OCSP("1.3.6.1.5.5.7.48.1"),101OCSPBasicResponse("1.3.6.1.5.5.7.48.1.1"),102OCSPNonceExt("1.3.6.1.5.5.7.48.1.2"),103OCSPNoCheck("1.3.6.1.5.5.7.48.1.5"),104caIssuers("1.3.6.1.5.5.7.48.2"),105AD_TimeStamping("1.3.6.1.5.5.7.48.3", "timeStamping") {106@Override107boolean registerNames() { return false; }108},109caRepository("1.3.6.1.5.5.7.48.5", "caRepository"),110111// NIST --112// AES 2.16.840.1.101.3.4.1.*113AES("2.16.840.1.101.3.4.1"),114AES_128$ECB$NoPadding("2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding"),115AES_128$CBC$NoPadding("2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding"),116AES_128$OFB$NoPadding("2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding"),117AES_128$CFB$NoPadding("2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding"),118AES_128$KW$NoPadding("2.16.840.1.101.3.4.1.5", "AES_128/KW/NoPadding",119"AESWrap_128"),120AES_128$GCM$NoPadding("2.16.840.1.101.3.4.1.6", "AES_128/GCM/NoPadding"),121AES_128$KWP$NoPadding("2.16.840.1.101.3.4.1.8", "AES_128/KWP/NoPadding",122"AESWrapPad_128"),123124AES_192$ECB$NoPadding("2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding"),125AES_192$CBC$NoPadding("2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding"),126AES_192$OFB$NoPadding("2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding"),127AES_192$CFB$NoPadding("2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding"),128AES_192$KW$NoPadding("2.16.840.1.101.3.4.1.25", "AES_192/KW/NoPadding",129"AESWrap_192"),130AES_192$GCM$NoPadding("2.16.840.1.101.3.4.1.26", "AES_192/GCM/NoPadding"),131AES_192$KWP$NoPadding("2.16.840.1.101.3.4.1.28", "AES_192/KWP/NoPadding",132"AESWrapPad_192"),133134AES_256$ECB$NoPadding("2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding"),135AES_256$CBC$NoPadding("2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding"),136AES_256$OFB$NoPadding("2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding"),137AES_256$CFB$NoPadding("2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding"),138AES_256$KW$NoPadding("2.16.840.1.101.3.4.1.45", "AES_256/KW/NoPadding",139"AESWrap_256"),140AES_256$GCM$NoPadding("2.16.840.1.101.3.4.1.46", "AES_256/GCM/NoPadding"),141AES_256$KWP$NoPadding("2.16.840.1.101.3.4.1.48", "AES_256/KWP/NoPadding",142"AESWrapPad_256"),143144// hashAlgs 2.16.840.1.101.3.4.2.*145SHA_256("2.16.840.1.101.3.4.2.1", "SHA-256", "SHA256"),146SHA_384("2.16.840.1.101.3.4.2.2", "SHA-384", "SHA384"),147SHA_512("2.16.840.1.101.3.4.2.3", "SHA-512", "SHA512"),148SHA_224("2.16.840.1.101.3.4.2.4", "SHA-224", "SHA224"),149SHA_512$224("2.16.840.1.101.3.4.2.5", "SHA-512/224", "SHA512/224"),150SHA_512$256("2.16.840.1.101.3.4.2.6", "SHA-512/256", "SHA512/256"),151SHA3_224("2.16.840.1.101.3.4.2.7", "SHA3-224"),152SHA3_256("2.16.840.1.101.3.4.2.8", "SHA3-256"),153SHA3_384("2.16.840.1.101.3.4.2.9", "SHA3-384"),154SHA3_512("2.16.840.1.101.3.4.2.10", "SHA3-512"),155SHAKE128("2.16.840.1.101.3.4.2.11"),156SHAKE256("2.16.840.1.101.3.4.2.12"),157HmacSHA3_224("2.16.840.1.101.3.4.2.13", "HmacSHA3-224"),158HmacSHA3_256("2.16.840.1.101.3.4.2.14", "HmacSHA3-256"),159HmacSHA3_384("2.16.840.1.101.3.4.2.15", "HmacSHA3-384"),160HmacSHA3_512("2.16.840.1.101.3.4.2.16", "HmacSHA3-512"),161SHAKE128_LEN("2.16.840.1.101.3.4.2.17", "SHAKE128-LEN"),162SHAKE256_LEN("2.16.840.1.101.3.4.2.18", "SHAKE256-LEN"),163164// sigAlgs 2.16.840.1.101.3.4.3.*165SHA224withDSA("2.16.840.1.101.3.4.3.1"),166SHA256withDSA("2.16.840.1.101.3.4.3.2"),167SHA384withDSA("2.16.840.1.101.3.4.3.3"),168SHA512withDSA("2.16.840.1.101.3.4.3.4"),169SHA3_224withDSA("2.16.840.1.101.3.4.3.5", "SHA3-224withDSA"),170SHA3_256withDSA("2.16.840.1.101.3.4.3.6", "SHA3-256withDSA"),171SHA3_384withDSA("2.16.840.1.101.3.4.3.7", "SHA3-384withDSA"),172SHA3_512withDSA("2.16.840.1.101.3.4.3.8", "SHA3-512withDSA"),173SHA3_224withECDSA("2.16.840.1.101.3.4.3.9", "SHA3-224withECDSA"),174SHA3_256withECDSA("2.16.840.1.101.3.4.3.10", "SHA3-256withECDSA"),175SHA3_384withECDSA("2.16.840.1.101.3.4.3.11", "SHA3-384withECDSA"),176SHA3_512withECDSA("2.16.840.1.101.3.4.3.12", "SHA3-512withECDSA"),177SHA3_224withRSA("2.16.840.1.101.3.4.3.13", "SHA3-224withRSA"),178SHA3_256withRSA("2.16.840.1.101.3.4.3.14", "SHA3-256withRSA"),179SHA3_384withRSA("2.16.840.1.101.3.4.3.15", "SHA3-384withRSA"),180SHA3_512withRSA("2.16.840.1.101.3.4.3.16", "SHA3-512withRSA"),181182// RSASecurity183// PKCS1 1.2.840.113549.1.1.*184PKCS1("1.2.840.113549.1.1", "RSA") { // RSA KeyPairGenerator and KeyFactory185@Override186boolean registerNames() { return false; }187},188RSA("1.2.840.113549.1.1.1"), // RSA encryption189190MD2withRSA("1.2.840.113549.1.1.2"),191MD5withRSA("1.2.840.113549.1.1.4"),192SHA1withRSA("1.2.840.113549.1.1.5"),193OAEP("1.2.840.113549.1.1.7"),194MGF1("1.2.840.113549.1.1.8"),195PSpecified("1.2.840.113549.1.1.9"),196RSASSA_PSS("1.2.840.113549.1.1.10", "RSASSA-PSS", "PSS"),197SHA256withRSA("1.2.840.113549.1.1.11"),198SHA384withRSA("1.2.840.113549.1.1.12"),199SHA512withRSA("1.2.840.113549.1.1.13"),200SHA224withRSA("1.2.840.113549.1.1.14"),201SHA512$224withRSA("1.2.840.113549.1.1.15", "SHA512/224withRSA"),202SHA512$256withRSA("1.2.840.113549.1.1.16", "SHA512/256withRSA"),203204// PKCS3 1.2.840.113549.1.3.*205DiffieHellman("1.2.840.113549.1.3.1", "DiffieHellman", "DH"),206207// PKCS5 1.2.840.113549.1.5.*208PBEWithMD5AndDES("1.2.840.113549.1.5.3"),209PBEWithMD5AndRC2("1.2.840.113549.1.5.6"),210PBEWithSHA1AndDES("1.2.840.113549.1.5.10"),211PBEWithSHA1AndRC2("1.2.840.113549.1.5.11"),212PBKDF2WithHmacSHA1("1.2.840.113549.1.5.12"),213PBES2("1.2.840.113549.1.5.13"),214215// PKCS7 1.2.840.113549.1.7.*216PKCS7("1.2.840.113549.1.7"),217Data("1.2.840.113549.1.7.1"),218SignedData("1.2.840.113549.1.7.2"),219JDK_OLD_Data("1.2.840.1113549.1.7.1"), // extra 1 in 4th component220JDK_OLD_SignedData("1.2.840.1113549.1.7.2"),221EnvelopedData("1.2.840.113549.1.7.3"),222SignedAndEnvelopedData("1.2.840.113549.1.7.4"),223DigestedData("1.2.840.113549.1.7.5"),224EncryptedData("1.2.840.113549.1.7.6"),225226// PKCS9 1.2.840.113549.1.9.*227EmailAddress("1.2.840.113549.1.9.1"),228UnstructuredName("1.2.840.113549.1.9.2"),229ContentType("1.2.840.113549.1.9.3"),230MessageDigest("1.2.840.113549.1.9.4"),231SigningTime("1.2.840.113549.1.9.5"),232CounterSignature("1.2.840.113549.1.9.6"),233ChallengePassword("1.2.840.113549.1.9.7"),234UnstructuredAddress("1.2.840.113549.1.9.8"),235ExtendedCertificateAttributes("1.2.840.113549.1.9.9"),236IssuerAndSerialNumber("1.2.840.113549.1.9.10"),237ExtensionRequest("1.2.840.113549.1.9.14"),238SMIMECapability("1.2.840.113549.1.9.15"),239TimeStampTokenInfo("1.2.840.113549.1.9.16.1.4"),240SigningCertificate("1.2.840.113549.1.9.16.2.12"),241SignatureTimestampToken("1.2.840.113549.1.9.16.2.14"),242CHACHA20_POLY1305("1.2.840.113549.1.9.16.3.18", "CHACHA20-POLY1305"),243FriendlyName("1.2.840.113549.1.9.20"),244LocalKeyID("1.2.840.113549.1.9.21"),245CertTypeX509("1.2.840.113549.1.9.22.1"),246CMSAlgorithmProtection("1.2.840.113549.1.9.52"),247248// PKCS12 1.2.840.113549.1.12.*249PBEWithSHA1AndRC4_128("1.2.840.113549.1.12.1.1"),250PBEWithSHA1AndRC4_40("1.2.840.113549.1.12.1.2"),251PBEWithSHA1AndDESede("1.2.840.113549.1.12.1.3"),252PBEWithSHA1AndRC2_128("1.2.840.113549.1.12.1.5"),253PBEWithSHA1AndRC2_40("1.2.840.113549.1.12.1.6"),254PKCS8ShroudedKeyBag("1.2.840.113549.1.12.10.1.2"),255CertBag("1.2.840.113549.1.12.10.1.3"),256SecretBag("1.2.840.113549.1.12.10.1.5"),257258// digestAlgs 1.2.840.113549.2.*259MD2("1.2.840.113549.2.2"),260MD5("1.2.840.113549.2.5"),261HmacSHA1("1.2.840.113549.2.7"),262HmacSHA224("1.2.840.113549.2.8"),263HmacSHA256("1.2.840.113549.2.9"),264HmacSHA384("1.2.840.113549.2.10"),265HmacSHA512("1.2.840.113549.2.11"),266HmacSHA512$224("1.2.840.113549.2.12", "HmacSHA512/224"),267HmacSHA512$256("1.2.840.113549.2.13", "HmacSHA512/256"),268269// encryptionAlgs 1.2.840.113549.3.*270RC2$CBC$PKCS5Padding("1.2.840.113549.3.2", "RC2/CBC/PKCS5Padding"),271ARCFOUR("1.2.840.113549.3.4", "ARCFOUR", "RC4"),272DESede$CBC$NoPadding("1.2.840.113549.3.7", "DESede/CBC/NoPadding"),273RC5$CBC$PKCS5Padding("1.2.840.113549.3.9", "RC5/CBC/PKCS5Padding"),274275// ANSI --276// X9 1.2.840.10040.4.*277DSA("1.2.840.10040.4.1"),278SHA1withDSA("1.2.840.10040.4.3", "SHA1withDSA", "DSS"),279// X9.62 1.2.840.10045.*280EC("1.2.840.10045.2.1"),281282//c2pnb163v1("1.2.840.10045.3.0.1", "X9.62 c2pnb163v1"),283//c2pnb163v2("1.2.840.10045.3.0.2", "X9.62 c2pnb163v2"),284//c2pnb163v3("1.2.840.10045.3.0.3", "X9.62 c2pnb163v3"),285//c2pnb176w1("1.2.840.10045.3.0.4", "X9.62 c2pnb176w1"),286c2tnb191v1("1.2.840.10045.3.0.5", "X9.62 c2tnb191v1"),287c2tnb191v2("1.2.840.10045.3.0.6", "X9.62 c2tnb191v2"),288c2tnb191v3("1.2.840.10045.3.0.7", "X9.62 c2tnb191v3"),289//c2pnb208w1("1.2.840.10045.3.0.10", "X9.62 c2pnb208w1"),290c2tnb239v1("1.2.840.10045.3.0.11", "X9.62 c2tnb239v1"),291c2tnb239v2("1.2.840.10045.3.0.12", "X9.62 c2tnb239v2"),292c2tnb239v3("1.2.840.10045.3.0.13", "X9.62 c2tnb239v3"),293//c2pnb272w1("1.2.840.10045.3.0.16", "X9.62 c2pnb272w1"),294//c2pnb304w1("1.2.840.10045.3.0.17", "X9.62 c2pnb304w1"),295c2tnb359v1("1.2.840.10045.3.0.18", "X9.62 c2tnb359v1"),296//c2pnb368w1("1.2.840.10045.3.0.19", "X9.62 c2pnb368w1"),297c2tnb431r1("1.2.840.10045.3.0.20", "X9.62 c2tnb431r1"),298299secp192r1("1.2.840.10045.3.1.1",300"secp192r1", "NIST P-192", "X9.62 prime192v1"),301prime192v2("1.2.840.10045.3.1.2", "X9.62 prime192v2"),302prime192v3("1.2.840.10045.3.1.3", "X9.62 prime192v3"),303prime239v1("1.2.840.10045.3.1.4", "X9.62 prime239v1"),304prime239v2("1.2.840.10045.3.1.5", "X9.62 prime239v2"),305prime239v3("1.2.840.10045.3.1.6", "X9.62 prime239v3"),306secp256r1("1.2.840.10045.3.1.7",307"secp256r1", "NIST P-256", "X9.62 prime256v1"),308SHA1withECDSA("1.2.840.10045.4.1"),309SHA224withECDSA("1.2.840.10045.4.3.1"),310SHA256withECDSA("1.2.840.10045.4.3.2"),311SHA384withECDSA("1.2.840.10045.4.3.3"),312SHA512withECDSA("1.2.840.10045.4.3.4"),313SpecifiedSHA2withECDSA("1.2.840.10045.4.3"),314315// X9.42 1.2.840.10046.2.*316X942_DH("1.2.840.10046.2.1", "DiffieHellman") { // unused by JDK providers317@Override318boolean registerNames() { return false; }319},320321// Teletrust 1.3.36.*322brainpoolP160r1("1.3.36.3.3.2.8.1.1.1"),323brainpoolP192r1("1.3.36.3.3.2.8.1.1.3"),324brainpoolP224r1("1.3.36.3.3.2.8.1.1.5"),325brainpoolP256r1("1.3.36.3.3.2.8.1.1.7"),326brainpoolP320r1("1.3.36.3.3.2.8.1.1.9"),327brainpoolP384r1("1.3.36.3.3.2.8.1.1.11"),328brainpoolP512r1("1.3.36.3.3.2.8.1.1.13"),329330// Certicom 1.3.132.*331sect163k1("1.3.132.0.1", "sect163k1", "NIST K-163"),332sect163r1("1.3.132.0.2"),333sect239k1("1.3.132.0.3"),334sect113r1("1.3.132.0.4"),335sect113r2("1.3.132.0.5"),336secp112r1("1.3.132.0.6"),337secp112r2("1.3.132.0.7"),338secp160r1("1.3.132.0.8"),339secp160k1("1.3.132.0.9"),340secp256k1("1.3.132.0.10"),341sect163r2("1.3.132.0.15", "sect163r2", "NIST B-163"),342sect283k1("1.3.132.0.16", "sect283k1", "NIST K-283"),343sect283r1("1.3.132.0.17", "sect283r1", "NIST B-283"),344345sect131r1("1.3.132.0.22"),346sect131r2("1.3.132.0.23"),347sect193r1("1.3.132.0.24"),348sect193r2("1.3.132.0.25"),349sect233k1("1.3.132.0.26", "sect233k1", "NIST K-233"),350sect233r1("1.3.132.0.27", "sect233r1", "NIST B-233"),351secp128r1("1.3.132.0.28"),352secp128r2("1.3.132.0.29"),353secp160r2("1.3.132.0.30"),354secp192k1("1.3.132.0.31"),355secp224k1("1.3.132.0.32"),356secp224r1("1.3.132.0.33", "secp224r1", "NIST P-224"),357secp384r1("1.3.132.0.34", "secp384r1", "NIST P-384"),358secp521r1("1.3.132.0.35", "secp521r1", "NIST P-521"),359sect409k1("1.3.132.0.36", "sect409k1", "NIST K-409"),360sect409r1("1.3.132.0.37", "sect409r1", "NIST B-409"),361sect571k1("1.3.132.0.38", "sect571k1", "NIST K-571"),362sect571r1("1.3.132.0.39", "sect571r1", "NIST B-571"),363364ECDH("1.3.132.1.12"),365366// OIW secsig 1.3.14.3.*367OIW_DES_CBC("1.3.14.3.2.7", "DES/CBC", "DES"),368369OIW_DSA("1.3.14.3.2.12", "DSA") {370@Override371boolean registerNames() { return false; }372},373374OIW_JDK_SHA1withDSA("1.3.14.3.2.13", "SHA1withDSA") {375@Override376boolean registerNames() { return false; }377},378379OIW_SHA1withRSA_Odd("1.3.14.3.2.15", "SHA1withRSA") {380@Override381boolean registerNames() { return false; }382},383384DESede("1.3.14.3.2.17", "DESede"),385386SHA_1("1.3.14.3.2.26", "SHA-1", "SHA", "SHA1"),387388OIW_SHA1withDSA("1.3.14.3.2.27", "SHA1withDSA") {389@Override390boolean registerNames() { return false; }391},392393OIW_SHA1withRSA("1.3.14.3.2.29", "SHA1withRSA") {394@Override395boolean registerNames() { return false; }396},397398// Thawte 1.3.101.*399X25519("1.3.101.110"),400X448("1.3.101.111"),401Ed25519("1.3.101.112"),402Ed448("1.3.101.113"),403404// University College London (UCL) 0.9.2342.19200300.*405UCL_UserID("0.9.2342.19200300.100.1.1"),406UCL_DomainComponent("0.9.2342.19200300.100.1.25"),407408// Netscape 2.16.840.1.113730.*409NETSCAPE_CertType("2.16.840.1.113730.1.1"),410NETSCAPE_CertSequence("2.16.840.1.113730.2.5"),411NETSCAPE_ExportApproved("2.16.840.1.113730.4.1"),412413// Oracle 2.16.840.1.113894.*414ORACLE_TrustedKeyUsage("2.16.840.1.113894.746875.1.1"),415416// Miscellaneous oids below which are legacy, and not well known417// Consider removing them in future releases when their usage418// have died out419420ITUX509_RSA("2.5.8.1.1", "RSA") { // unused by JDK providers421// defined in X.509 for RSA keys422@Override // with modulus length as its parameter423boolean registerNames() { return false; }424},425426SkipIPAddress("1.3.6.1.4.1.42.2.11.2.1"),427JAVASOFT_JDKKeyProtector("1.3.6.1.4.1.42.2.17.1.1"),428JAVASOFT_JCEKeyProtector("1.3.6.1.4.1.42.2.19.1"),429MICROSOFT_ExportApproved("1.3.6.1.4.1.311.10.3.3");430431private String stdName;432private String oid;433private String[] aliases;434435// find the matching enum using either name or oid string436// return null if no match found437public static KnownOIDs findMatch(String s) {438s = s.toUpperCase(Locale.ENGLISH);439KnownOIDs res = name2enum.get(s);440if (res == null && debug != null) {441debug.println("No KnownOIDs enum found for " + s);442}443return res;444}445446private static final Debug debug = Debug.getInstance("jca");447//private static final java.io.PrintStream debug = System.out;448private static final ConcurrentHashMap<String, KnownOIDs> name2enum =449new ConcurrentHashMap<>();450451static {452if (debug != null) {453debug.println("Setting up name2enum:");454}455for (KnownOIDs o : KnownOIDs.values()) {456register(o);457};458}459460private static void register(KnownOIDs o) {461KnownOIDs ov = name2enum.put(o.oid, o);462if (ov != null) {463throw new RuntimeException("ERROR: Duplicate " + o.oid +464" between " + o + " and " + ov);465} else if (debug != null) {466debug.println(o.oid + " => " + o.name());467}468// only register the stdName and aliases if o.registerNames()469// returns true470if (o.registerNames()) {471String stdNameUpper = o.stdName.toUpperCase(Locale.ENGLISH);472if (Objects.nonNull(name2enum.put(stdNameUpper, o))) {473throw new RuntimeException("ERROR: Duplicate " +474stdNameUpper + " exists already");475}476if (debug != null) {477debug.println(stdNameUpper + " => " + o.name());478}479480for (String a : o.aliases) {481String aliasUpper = a.toUpperCase(Locale.ENGLISH);482if (Objects.nonNull(name2enum.put(aliasUpper, o))) {483throw new RuntimeException("ERROR: Duplicate " +484aliasUpper + " exists already");485}486if (debug != null) {487debug.println(aliasUpper + " => " + o.name());488}489}490}491}492493private KnownOIDs(String oid) {494this.oid = oid;495this.stdName = name(); // defaults to enum name496this.aliases = new String[0];497}498499private KnownOIDs(String oid, String stdName, String ... aliases) {500this.oid = oid;501this.stdName = stdName;502this.aliases = aliases;503}504505// returns the oid string associated with this enum506public String value() {507return oid;508}509510// returns the user-friendly standard algorithm name511public String stdName() {512return stdName;513}514515// return the internal aliases516public String[] aliases() {517return aliases;518}519520boolean registerNames() {521return true;522}523}524525526