792 oid(1, 2, 840, 10045, 4, 3, 2); 793 public static final ObjectIdentifier sha384WithECDSA_oid = 794 oid(1, 2, 840, 10045, 4, 3, 3); 795 public static final ObjectIdentifier sha512WithECDSA_oid = 796 oid(1, 2, 840, 10045, 4, 3, 4); 797 public static final ObjectIdentifier specifiedWithECDSA_oid = 798 oid(1, 2, 840, 10045, 4, 3); 799 800 /** 801 * Algorithm ID for the PBE encryption algorithms from PKCS#5 and 802 * PKCS#12. 803 */ 804 public static final ObjectIdentifier pbeWithMD5AndDES_oid = 805 ObjectIdentifier.newInternal(new int[]{1, 2, 840, 113549, 1, 5, 3}); 806 public static final ObjectIdentifier pbeWithMD5AndRC2_oid = 807 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 6}); 808 public static final ObjectIdentifier pbeWithSHA1AndDES_oid = 809 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 10}); 810 public static final ObjectIdentifier pbeWithSHA1AndRC2_oid = 811 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 11}); 812 public static ObjectIdentifier pbeWithSHA1AndDESede_oid = 813 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 3}); 814 public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid = 815 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 6}); 816 817 static { 818 /* 819 * Note the preferred OIDs are named simply with no "OIW" or 820 * "PKIX" in them, even though they may point to data from these 821 * specs; e.g. SHA_oid, DH_oid, DSA_oid, SHA1WithDSA_oid... 822 */ 823 /** 824 * Algorithm ID for Diffie Hellman Key agreement, from PKCS #3. 825 * Parameters include public values P and G, and may optionally specify 826 * the length of the private key X. Alternatively, algorithm parameters 827 * may be derived from another source such as a Certificate Authority's 828 * certificate. 829 * OID = 1.2.840.113549.1.3.1 830 */ 831 DH_oid = ObjectIdentifier.newInternal(DH_data); 832 833 /** 982 nameTable.put(sha1WithDSA_oid, "SHA1withDSA"); 983 nameTable.put(sha1WithDSA_OIW_oid, "SHA1withDSA"); 984 nameTable.put(shaWithDSA_OIW_oid, "SHA1withDSA"); 985 nameTable.put(sha224WithDSA_oid, "SHA224withDSA"); 986 nameTable.put(sha256WithDSA_oid, "SHA256withDSA"); 987 nameTable.put(sha1WithRSAEncryption_oid, "SHA1withRSA"); 988 nameTable.put(sha1WithRSAEncryption_OIW_oid, "SHA1withRSA"); 989 nameTable.put(sha224WithRSAEncryption_oid, "SHA224withRSA"); 990 nameTable.put(sha256WithRSAEncryption_oid, "SHA256withRSA"); 991 nameTable.put(sha384WithRSAEncryption_oid, "SHA384withRSA"); 992 nameTable.put(sha512WithRSAEncryption_oid, "SHA512withRSA"); 993 nameTable.put(sha512_224WithRSAEncryption_oid, "SHA512/224withRSA"); 994 nameTable.put(sha512_256WithRSAEncryption_oid, "SHA512/256withRSA"); 995 nameTable.put(RSASSA_PSS_oid, "RSASSA-PSS"); 996 nameTable.put(RSAES_OAEP_oid, "RSAES-OAEP"); 997 998 nameTable.put(pbeWithMD5AndDES_oid, "PBEWithMD5AndDES"); 999 nameTable.put(pbeWithMD5AndRC2_oid, "PBEWithMD5AndRC2"); 1000 nameTable.put(pbeWithSHA1AndDES_oid, "PBEWithSHA1AndDES"); 1001 nameTable.put(pbeWithSHA1AndRC2_oid, "PBEWithSHA1AndRC2"); 1002 nameTable.put(pbeWithSHA1AndDESede_oid, "PBEWithSHA1AndDESede"); 1003 nameTable.put(pbeWithSHA1AndRC2_40_oid, "PBEWithSHA1AndRC2_40"); 1004 } 1005 1006 /** 1007 * Creates a signature algorithm name from a digest algorithm 1008 * name and a encryption algorithm name. 1009 */ 1010 public static String makeSigAlg(String digAlg, String encAlg) { 1011 digAlg = digAlg.replace("-", ""); 1012 if (encAlg.equalsIgnoreCase("EC")) encAlg = "ECDSA"; 1013 1014 return digAlg + "with" + encAlg; 1015 } 1016 1017 /** 1018 * Extracts the encryption algorithm name from a signature 1019 * algorithm name. 1020 */ 1021 public static String getEncAlgFromSigAlg(String signatureAlgorithm) { 1022 signatureAlgorithm = signatureAlgorithm.toUpperCase(Locale.ENGLISH); | 792 oid(1, 2, 840, 10045, 4, 3, 2); 793 public static final ObjectIdentifier sha384WithECDSA_oid = 794 oid(1, 2, 840, 10045, 4, 3, 3); 795 public static final ObjectIdentifier sha512WithECDSA_oid = 796 oid(1, 2, 840, 10045, 4, 3, 4); 797 public static final ObjectIdentifier specifiedWithECDSA_oid = 798 oid(1, 2, 840, 10045, 4, 3); 799 800 /** 801 * Algorithm ID for the PBE encryption algorithms from PKCS#5 and 802 * PKCS#12. 803 */ 804 public static final ObjectIdentifier pbeWithMD5AndDES_oid = 805 ObjectIdentifier.newInternal(new int[]{1, 2, 840, 113549, 1, 5, 3}); 806 public static final ObjectIdentifier pbeWithMD5AndRC2_oid = 807 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 6}); 808 public static final ObjectIdentifier pbeWithSHA1AndDES_oid = 809 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 10}); 810 public static final ObjectIdentifier pbeWithSHA1AndRC2_oid = 811 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 11}); 812 public static ObjectIdentifier pbeWithSHA1AndRC4_128_oid = 813 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 1}); 814 public static ObjectIdentifier pbeWithSHA1AndRC4_40_oid = 815 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 2}); 816 public static ObjectIdentifier pbeWithSHA1AndDESede_oid = 817 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 3}); 818 public static ObjectIdentifier pbeWithSHA1AndRC2_128_oid = 819 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 5}); 820 public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid = 821 ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 6}); 822 823 static { 824 /* 825 * Note the preferred OIDs are named simply with no "OIW" or 826 * "PKIX" in them, even though they may point to data from these 827 * specs; e.g. SHA_oid, DH_oid, DSA_oid, SHA1WithDSA_oid... 828 */ 829 /** 830 * Algorithm ID for Diffie Hellman Key agreement, from PKCS #3. 831 * Parameters include public values P and G, and may optionally specify 832 * the length of the private key X. Alternatively, algorithm parameters 833 * may be derived from another source such as a Certificate Authority's 834 * certificate. 835 * OID = 1.2.840.113549.1.3.1 836 */ 837 DH_oid = ObjectIdentifier.newInternal(DH_data); 838 839 /** 988 nameTable.put(sha1WithDSA_oid, "SHA1withDSA"); 989 nameTable.put(sha1WithDSA_OIW_oid, "SHA1withDSA"); 990 nameTable.put(shaWithDSA_OIW_oid, "SHA1withDSA"); 991 nameTable.put(sha224WithDSA_oid, "SHA224withDSA"); 992 nameTable.put(sha256WithDSA_oid, "SHA256withDSA"); 993 nameTable.put(sha1WithRSAEncryption_oid, "SHA1withRSA"); 994 nameTable.put(sha1WithRSAEncryption_OIW_oid, "SHA1withRSA"); 995 nameTable.put(sha224WithRSAEncryption_oid, "SHA224withRSA"); 996 nameTable.put(sha256WithRSAEncryption_oid, "SHA256withRSA"); 997 nameTable.put(sha384WithRSAEncryption_oid, "SHA384withRSA"); 998 nameTable.put(sha512WithRSAEncryption_oid, "SHA512withRSA"); 999 nameTable.put(sha512_224WithRSAEncryption_oid, "SHA512/224withRSA"); 1000 nameTable.put(sha512_256WithRSAEncryption_oid, "SHA512/256withRSA"); 1001 nameTable.put(RSASSA_PSS_oid, "RSASSA-PSS"); 1002 nameTable.put(RSAES_OAEP_oid, "RSAES-OAEP"); 1003 1004 nameTable.put(pbeWithMD5AndDES_oid, "PBEWithMD5AndDES"); 1005 nameTable.put(pbeWithMD5AndRC2_oid, "PBEWithMD5AndRC2"); 1006 nameTable.put(pbeWithSHA1AndDES_oid, "PBEWithSHA1AndDES"); 1007 nameTable.put(pbeWithSHA1AndRC2_oid, "PBEWithSHA1AndRC2"); 1008 nameTable.put(pbeWithSHA1AndRC4_128_oid, "PBEWithSHA1AndRC4_128"); 1009 nameTable.put(pbeWithSHA1AndRC4_40_oid, "PBEWithSHA1AndRC4_40"); 1010 nameTable.put(pbeWithSHA1AndDESede_oid, "PBEWithSHA1AndDESede"); 1011 nameTable.put(pbeWithSHA1AndRC2_128_oid, "PBEWithSHA1AndRC2_128"); 1012 nameTable.put(pbeWithSHA1AndRC2_40_oid, "PBEWithSHA1AndRC2_40"); 1013 } 1014 1015 /** 1016 * Creates a signature algorithm name from a digest algorithm 1017 * name and a encryption algorithm name. 1018 */ 1019 public static String makeSigAlg(String digAlg, String encAlg) { 1020 digAlg = digAlg.replace("-", ""); 1021 if (encAlg.equalsIgnoreCase("EC")) encAlg = "ECDSA"; 1022 1023 return digAlg + "with" + encAlg; 1024 } 1025 1026 /** 1027 * Extracts the encryption algorithm name from a signature 1028 * algorithm name. 1029 */ 1030 public static String getEncAlgFromSigAlg(String signatureAlgorithm) { 1031 signatureAlgorithm = signatureAlgorithm.toUpperCase(Locale.ENGLISH); |