summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-05-07 20:22:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-05-07 20:22:03 +0000
commit4ffab68b792acd6c5374414858f9a845b0796ca1 (patch)
tree68483ed9e14cd77efd5d60a14d37673ce5e28ef2
parent30abb655066afb5eeaebb874efd7cb10ae4013ff (diff)
parent7e4ea6b406f5ae8456f719eff76991020fd37948 (diff)
downloadlibcore-4ffab68b792acd6c5374414858f9a845b0796ca1.zip
libcore-4ffab68b792acd6c5374414858f9a845b0796ca1.tar.gz
libcore-4ffab68b792acd6c5374414858f9a845b0796ca1.tar.bz2
Merge "NativeCrypto: use strings instead of loading class"
-rw-r--r--crypto/src/main/java/org/conscrypt/OpenSSLProvider.java128
1 files changed, 63 insertions, 65 deletions
diff --git a/crypto/src/main/java/org/conscrypt/OpenSSLProvider.java b/crypto/src/main/java/org/conscrypt/OpenSSLProvider.java
index dc20be5..e58381e 100644
--- a/crypto/src/main/java/org/conscrypt/OpenSSLProvider.java
+++ b/crypto/src/main/java/org/conscrypt/OpenSSLProvider.java
@@ -34,69 +34,67 @@ public final class OpenSSLProvider extends Provider {
public OpenSSLProvider() {
super(PROVIDER_NAME, 1.0, "Android's OpenSSL-backed security provider");
+ final String prefix = getClass().getPackage().getName() + ".";
+
/* === SSL Contexts === */
- put("SSLContext.SSL", OpenSSLContextImpl.class.getName());
- put("SSLContext.SSLv3", OpenSSLContextImpl.class.getName());
- put("SSLContext.TLS", OpenSSLContextImpl.class.getName());
- put("SSLContext.TLSv1", OpenSSLContextImpl.class.getName());
- put("SSLContext.TLSv1.1", OpenSSLContextImpl.class.getName());
- put("SSLContext.TLSv1.2", OpenSSLContextImpl.class.getName());
- put("SSLContext.Default", DefaultSSLContextImpl.class.getName());
+ final String classOpenSSLContextImpl = prefix + "OpenSSLContextImpl";
+ put("SSLContext.SSL", classOpenSSLContextImpl);
+ put("SSLContext.SSLv3", classOpenSSLContextImpl);
+ put("SSLContext.TLS", classOpenSSLContextImpl);
+ put("SSLContext.TLSv1", classOpenSSLContextImpl);
+ put("SSLContext.TLSv1.1", classOpenSSLContextImpl);
+ put("SSLContext.TLSv1.2", classOpenSSLContextImpl);
+ put("SSLContext.Default", prefix + "DefaultSSLContextImpl");
/* === Message Digests === */
- put("MessageDigest.SHA-1",
- "org.conscrypt.OpenSSLMessageDigestJDK$SHA1");
+ put("MessageDigest.SHA-1", prefix + "OpenSSLMessageDigestJDK$SHA1");
put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
put("Alg.Alias.MessageDigest.SHA", "SHA-1");
put("Alg.Alias.MessageDigest.1.3.14.3.2.26", "SHA-1");
- put("MessageDigest.SHA-256",
- "org.conscrypt.OpenSSLMessageDigestJDK$SHA256");
+ put("MessageDigest.SHA-256", prefix + "OpenSSLMessageDigestJDK$SHA256");
put("Alg.Alias.MessageDigest.SHA256", "SHA-256");
put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.1", "SHA-256");
- put("MessageDigest.SHA-384",
- "org.conscrypt.OpenSSLMessageDigestJDK$SHA384");
+ put("MessageDigest.SHA-384", prefix + "OpenSSLMessageDigestJDK$SHA384");
put("Alg.Alias.MessageDigest.SHA384", "SHA-384");
put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.2", "SHA-384");
- put("MessageDigest.SHA-512",
- "org.conscrypt.OpenSSLMessageDigestJDK$SHA512");
+ put("MessageDigest.SHA-512", prefix + "OpenSSLMessageDigestJDK$SHA512");
put("Alg.Alias.MessageDigest.SHA512", "SHA-512");
put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3", "SHA-512");
// iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) md5(5)
- put("MessageDigest.MD5",
- "org.conscrypt.OpenSSLMessageDigestJDK$MD5");
+ put("MessageDigest.MD5", prefix + "OpenSSLMessageDigestJDK$MD5");
put("Alg.Alias.MessageDigest.1.2.840.113549.2.5", "MD5");
/* == KeyPairGenerators == */
- put("KeyPairGenerator.RSA", OpenSSLRSAKeyPairGenerator.class.getName());
+ put("KeyPairGenerator.RSA", prefix + "OpenSSLRSAKeyPairGenerator");
put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.1", "RSA");
- put("KeyPairGenerator.DSA", OpenSSLDSAKeyPairGenerator.class.getName());
+ put("KeyPairGenerator.DSA", prefix + "OpenSSLDSAKeyPairGenerator");
- put("KeyPairGenerator.EC", OpenSSLECKeyPairGenerator.class.getName());
+ put("KeyPairGenerator.EC", prefix + "OpenSSLECKeyPairGenerator");
/* == KeyFactory == */
- put("KeyFactory.RSA", OpenSSLRSAKeyFactory.class.getName());
+ put("KeyFactory.RSA", prefix + "OpenSSLRSAKeyFactory");
put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.1", "RSA");
- put("KeyFactory.DSA", OpenSSLDSAKeyFactory.class.getName());
+ put("KeyFactory.DSA", prefix + "OpenSSLDSAKeyFactory");
- put("KeyFactory.EC", OpenSSLECKeyFactory.class.getName());
+ put("KeyFactory.EC", prefix + "OpenSSLECKeyFactory");
/* == KeyAgreement == */
- put("KeyAgreement.ECDH", OpenSSLECDHKeyAgreement.class.getName());
+ put("KeyAgreement.ECDH", prefix + "OpenSSLECDHKeyAgreement");
/* == Signatures == */
- put("Signature.MD5WithRSA", OpenSSLSignature.MD5RSA.class.getName());
+ put("Signature.MD5WithRSA", prefix + "OpenSSLSignature$MD5RSA");
put("Alg.Alias.Signature.MD5WithRSAEncryption", "MD5WithRSA");
put("Alg.Alias.Signature.MD5/RSA", "MD5WithRSA");
put("Alg.Alias.Signature.1.2.840.113549.1.1.4", "MD5WithRSA");
put("Alg.Alias.Signature.1.2.840.113549.2.5with1.2.840.113549.1.1.1", "MD5WithRSA");
- put("Signature.SHA1WithRSA", OpenSSLSignature.SHA1RSA.class.getName());
+ put("Signature.SHA1WithRSA", prefix + "OpenSSLSignature$SHA1RSA");
put("Alg.Alias.Signature.SHA1WithRSAEncryption", "SHA1WithRSA");
put("Alg.Alias.Signature.SHA1/RSA", "SHA1WithRSA");
put("Alg.Alias.Signature.SHA-1/RSA", "SHA1WithRSA");
@@ -105,7 +103,7 @@ public final class OpenSSLProvider extends Provider {
put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.5", "SHA1WithRSA");
put("Alg.Alias.Signature.1.3.14.3.2.29", "SHA1WithRSA");
- put("Signature.SHA256WithRSA", OpenSSLSignature.SHA256RSA.class.getName());
+ put("Signature.SHA256WithRSA", prefix + "OpenSSLSignature$SHA256RSA");
put("Alg.Alias.Signature.SHA256WithRSAEncryption", "SHA256WithRSA");
put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256WithRSA");
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.1with1.2.840.113549.1.1.1",
@@ -113,19 +111,19 @@ public final class OpenSSLProvider extends Provider {
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.1with1.2.840.113549.1.1.11",
"SHA256WithRSA");
- put("Signature.SHA384WithRSA", OpenSSLSignature.SHA384RSA.class.getName());
+ put("Signature.SHA384WithRSA", prefix + "OpenSSLSignature$SHA384RSA");
put("Alg.Alias.Signature.SHA384WithRSAEncryption", "SHA384WithRSA");
put("Alg.Alias.Signature.1.2.840.113549.1.1.12", "SHA384WithRSA");
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.2with1.2.840.113549.1.1.1",
"SHA384WithRSA");
- put("Signature.SHA512WithRSA", OpenSSLSignature.SHA512RSA.class.getName());
+ put("Signature.SHA512WithRSA", prefix + "OpenSSLSignature$SHA512RSA");
put("Alg.Alias.Signature.SHA512WithRSAEncryption", "SHA512WithRSA");
put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512WithRSA");
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.3with1.2.840.113549.1.1.1",
"SHA512WithRSA");
- put("Signature.SHA1withDSA", OpenSSLSignature.SHA1DSA.class.getName());
+ put("Signature.SHA1withDSA", prefix + "OpenSSLSignature$SHA1DSA");
put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
put("Alg.Alias.Signature.DSA", "SHA1withDSA");
put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "SHA1withDSA");
@@ -133,9 +131,9 @@ public final class OpenSSLProvider extends Provider {
put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
- put("Signature.NONEwithRSA", OpenSSLSignatureRawRSA.class.getName());
+ put("Signature.NONEwithRSA", prefix + "OpenSSLSignatureRawRSA");
- put("Signature.ECDSA", OpenSSLSignature.SHA1ECDSA.class.getName());
+ put("Signature.ECDSA", prefix + "OpenSSLSignature$SHA1ECDSA");
put("Alg.Alias.Signature.SHA1withECDSA", "ECDSA");
put("Alg.Alias.Signature.ECDSAwithSHA1", "ECDSA");
// iso(1) member-body(2) us(840) ansi-x962(10045) signatures(4) ecdsa-with-SHA1(1)
@@ -143,17 +141,17 @@ public final class OpenSSLProvider extends Provider {
put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10045.2.1", "ECDSA");
// iso(1) member-body(2) us(840) ansi-x962(10045) signatures(4) ecdsa-with-SHA2(3)
- put("Signature.SHA256withECDSA", OpenSSLSignature.SHA256ECDSA.class.getName());
+ put("Signature.SHA256withECDSA", prefix + "OpenSSLSignature$SHA256ECDSA");
// ecdsa-with-SHA256(2)
put("Alg.Alias.Signature.1.2.840.10045.4.3.2", "SHA256withECDSA");
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.1with1.2.840.10045.2.1", "SHA256withECDSA");
- put("Signature.SHA384withECDSA", OpenSSLSignature.SHA384ECDSA.class.getName());
+ put("Signature.SHA384withECDSA", prefix + "OpenSSLSignature$SHA384ECDSA");
// ecdsa-with-SHA384(3)
put("Alg.Alias.Signature.1.2.840.10045.4.3.3", "SHA384withECDSA");
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.2with1.2.840.10045.2.1", "SHA384withECDSA");
- put("Signature.SHA512withECDSA", OpenSSLSignature.SHA512ECDSA.class.getName());
+ put("Signature.SHA512withECDSA", prefix + "OpenSSLSignature$SHA512ECDSA");
// ecdsa-with-SHA512(4)
put("Alg.Alias.Signature.1.2.840.10045.4.3.4", "SHA512withECDSA");
put("Alg.Alias.Signature.2.16.840.1.101.3.4.2.3with1.2.840.10045.2.1", "SHA512withECDSA");
@@ -164,75 +162,75 @@ public final class OpenSSLProvider extends Provider {
* that algorithm by name instead of just recommending calling
* "new SecureRandom()"
*/
- put("SecureRandom.SHA1PRNG", OpenSSLRandom.class.getName());
+ put("SecureRandom.SHA1PRNG", prefix + "OpenSSLRandom");
put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
/* === Cipher === */
- put("Cipher.RSA/ECB/NoPadding", OpenSSLCipherRSA.Raw.class.getName());
+ put("Cipher.RSA/ECB/NoPadding", prefix + "OpenSSLCipherRSA$Raw");
put("Alg.Alias.Cipher.RSA/None/NoPadding", "RSA/ECB/NoPadding");
- put("Cipher.RSA/ECB/PKCS1Padding", OpenSSLCipherRSA.PKCS1.class.getName());
+ put("Cipher.RSA/ECB/PKCS1Padding", prefix + "OpenSSLCipherRSA$PKCS1");
put("Alg.Alias.Cipher.RSA/None/PKCS1Padding", "RSA/ECB/PKCS1Padding");
/*
* OpenSSL only supports a subset of modes, so we'll name them
* explicitly here.
*/
- put("Cipher.AES/ECB/NoPadding", OpenSSLCipher.AES.ECB.NoPadding.class.getName());
- put("Cipher.AES/ECB/PKCS5Padding", OpenSSLCipher.AES.ECB.PKCS5Padding.class.getName());
- put("Cipher.AES/CBC/NoPadding", OpenSSLCipher.AES.CBC.NoPadding.class.getName());
- put("Cipher.AES/CBC/PKCS5Padding", OpenSSLCipher.AES.CBC.PKCS5Padding.class.getName());
- put("Cipher.AES/CFB/NoPadding", OpenSSLCipher.AES.CFB.NoPadding.class.getName());
- put("Cipher.AES/CFB/PKCS5Padding", OpenSSLCipher.AES.CFB.PKCS5Padding.class.getName());
- put("Cipher.AES/CTR/NoPadding", OpenSSLCipher.AES.CTR.NoPadding.class.getName());
- put("Cipher.AES/CTR/PKCS5Padding", OpenSSLCipher.AES.CTR.PKCS5Padding.class.getName());
- put("Cipher.AES/OFB/NoPadding", OpenSSLCipher.AES.OFB.NoPadding.class.getName());
- put("Cipher.AES/OFB/PKCS5Padding", OpenSSLCipher.AES.OFB.PKCS5Padding.class.getName());
-
- put("Cipher.DESEDE/CBC/NoPadding", OpenSSLCipher.DESEDE.CBC.NoPadding.class.getName());
- put("Cipher.DESEDE/CBC/PKCS5Padding", OpenSSLCipher.DESEDE.CBC.PKCS5Padding.class.getName());
- put("Cipher.DESEDE/CFB/NoPadding", OpenSSLCipher.DESEDE.CFB.NoPadding.class.getName());
- put("Cipher.DESEDE/CFB/PKCS5Padding", OpenSSLCipher.DESEDE.CFB.PKCS5Padding.class.getName());
- put("Cipher.DESEDE/ECB/NoPadding", OpenSSLCipher.DESEDE.ECB.NoPadding.class.getName());
- put("Cipher.DESEDE/ECB/PKCS5Padding", OpenSSLCipher.DESEDE.ECB.PKCS5Padding.class.getName());
- put("Cipher.DESEDE/OFB/NoPadding", OpenSSLCipher.DESEDE.OFB.NoPadding.class.getName());
- put("Cipher.DESEDE/OFB/PKCS5Padding", OpenSSLCipher.DESEDE.OFB.PKCS5Padding.class.getName());
-
- put("Cipher.ARC4", OpenSSLCipher.ARC4.class.getName());
+ put("Cipher.AES/ECB/NoPadding", prefix + "OpenSSLCipher$AES$ECB$NoPadding");
+ put("Cipher.AES/ECB/PKCS5Padding", prefix + "OpenSSLCipher$AES$ECB$PKCS5Padding");
+ put("Cipher.AES/CBC/NoPadding", prefix + "OpenSSLCipher$AES$CBC$NoPadding");
+ put("Cipher.AES/CBC/PKCS5Padding", prefix + "OpenSSLCipher$AES$CBC$PKCS5Padding");
+ put("Cipher.AES/CFB/NoPadding", prefix + "OpenSSLCipher$AES$CFB$NoPadding");
+ put("Cipher.AES/CFB/PKCS5Padding", prefix + "OpenSSLCipher$AES$CFB$PKCS5Padding");
+ put("Cipher.AES/CTR/NoPadding", prefix + "OpenSSLCipher$AES$CTR$NoPadding");
+ put("Cipher.AES/CTR/PKCS5Padding", prefix + "OpenSSLCipher$AES$CTR$PKCS5Padding");
+ put("Cipher.AES/OFB/NoPadding", prefix + "OpenSSLCipher$AES$OFB$NoPadding");
+ put("Cipher.AES/OFB/PKCS5Padding", prefix + "OpenSSLCipher$AES$OFB$PKCS5Padding");
+
+ put("Cipher.DESEDE/CBC/NoPadding", prefix + "OpenSSLCipher$DESEDE$CBC$NoPadding");
+ put("Cipher.DESEDE/CBC/PKCS5Padding", prefix + "OpenSSLCipher$DESEDE$CBC$PKCS5Padding");
+ put("Cipher.DESEDE/CFB/NoPadding", prefix + "OpenSSLCipher$DESEDE$CFB$NoPadding");
+ put("Cipher.DESEDE/CFB/PKCS5Padding", prefix + "OpenSSLCipher$DESEDE$CFB$PKCS5Padding");
+ put("Cipher.DESEDE/ECB/NoPadding", prefix + "OpenSSLCipher$DESEDE$ECB$NoPadding");
+ put("Cipher.DESEDE/ECB/PKCS5Padding", prefix + "OpenSSLCipher$DESEDE$ECB$PKCS5Padding");
+ put("Cipher.DESEDE/OFB/NoPadding", prefix + "OpenSSLCipher$DESEDE$OFB$NoPadding");
+ put("Cipher.DESEDE/OFB/PKCS5Padding", prefix + "OpenSSLCipher$DESEDE$OFB$PKCS5Padding");
+
+ put("Cipher.ARC4", prefix + "OpenSSLCipher$ARC4");
/* === Mac === */
- put("Mac.HmacMD5", OpenSSLMac.HmacMD5.class.getName());
+ put("Mac.HmacMD5", prefix + "OpenSSLMac$HmacMD5");
// PKCS#2 - iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2)
// http://www.oid-info.com/get/1.2.840.113549.2
// HMAC-SHA-1 PRF (7)
- put("Mac.HmacSHA1", OpenSSLMac.HmacSHA1.class.getName());
+ put("Mac.HmacSHA1", prefix + "OpenSSLMac$HmacSHA1");
put("Alg.Alias.Mac.1.2.840.113549.2.7", "HmacSHA1");
put("Alg.Alias.Mac.HMAC-SHA1", "HmacSHA1");
put("Alg.Alias.Mac.HMAC/SHA1", "HmacSHA1");
// id-hmacWithSHA256 (9)
- put("Mac.HmacSHA256", OpenSSLMac.HmacSHA256.class.getName());
+ put("Mac.HmacSHA256", prefix + "OpenSSLMac$HmacSHA256");
put("Alg.Alias.Mac.1.2.840.113549.2.9", "HmacSHA256");
put("Alg.Alias.Mac.HMAC-SHA256", "HmacSHA256");
put("Alg.Alias.Mac.HMAC/SHA256", "HmacSHA256");
// id-hmacWithSHA384 (10)
- put("Mac.HmacSHA384", OpenSSLMac.HmacSHA384.class.getName());
+ put("Mac.HmacSHA384", prefix + "OpenSSLMac$HmacSHA384");
put("Alg.Alias.Mac.1.2.840.113549.2.10", "HmacSHA384");
put("Alg.Alias.Mac.HMAC-SHA384", "HmacSHA384");
put("Alg.Alias.Mac.HMAC/SHA384", "HmacSHA384");
// id-hmacWithSHA384 (11)
- put("Mac.HmacSHA512", OpenSSLMac.HmacSHA512.class.getName());
+ put("Mac.HmacSHA512", prefix + "OpenSSLMac$HmacSHA512");
put("Alg.Alias.Mac.1.2.840.113549.2.11", "HmacSHA512");
put("Alg.Alias.Mac.HMAC-SHA512", "HmacSHA512");
put("Alg.Alias.Mac.HMAC/SHA512", "HmacSHA512");
/* === Certificate === */
- put("CertificateFactory.X509", OpenSSLX509CertificateFactory.class.getName());
+ put("CertificateFactory.X509", prefix + "OpenSSLX509CertificateFactory");
put("Alg.Alias.CertificateFactory.X.509", "X509");
}
}