commit | bc5800cc4ebcd5d778483851b73bdac6b1dc2f3c | [log] [tgz] |
---|---|---|
author | Alex Klyubin <klyubin@google.com> | Fri Mar 29 11:44:20 2013 -0700 |
committer | Kenny Root <kroot@google.com> | Fri Apr 05 14:48:49 2013 -0700 |
tree | 2dd14d6a1f351ec05f988cac01b451eaf0cd9044 | |
parent | 4556926f9dee32ac5b2a8ac0c442bc716d1303f3 [diff] |
Make KeyFactory.translateKey for OpenSSL keys a no-op. There's no need for the OpenSSL-backed KeyFactory.translateKey to create copies of Key instances which are already backed by OpenSSL. (cherry picked from commit 3fb32505a22a01c95ff82435ac7f4d6da001c11c) Change-Id: I49322aa2d29e44a06e6bd35aed3aebc0ea70a3f9
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLDSAKeyFactory.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLDSAKeyFactory.java index ca9f37c..efa4747 100644 --- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLDSAKeyFactory.java +++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLDSAKeyFactory.java
@@ -141,8 +141,9 @@ if (key == null) { throw new InvalidKeyException("key == null"); } - - if (key instanceof DSAPublicKey) { + if ((key instanceof OpenSSLDSAPublicKey) || (key instanceof OpenSSLDSAPrivateKey)) { + return key; + } else if (key instanceof DSAPublicKey) { DSAPublicKey dsaKey = (DSAPublicKey) key; BigInteger y = dsaKey.getY();
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLECKeyFactory.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLECKeyFactory.java index 16d4e64..e4673a5 100644 --- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLECKeyFactory.java +++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLECKeyFactory.java
@@ -133,8 +133,9 @@ if (key == null) { throw new InvalidKeyException("key == null"); } - - if (key instanceof ECPublicKey) { + if ((key instanceof OpenSSLECPublicKey) || (key instanceof OpenSSLECPrivateKey)) { + return key; + } else if (key instanceof ECPublicKey) { ECPublicKey ecKey = (ECPublicKey) key; ECPoint w = ecKey.getW();
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLRSAKeyFactory.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLRSAKeyFactory.java index c61223d..9c61abd 100644 --- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLRSAKeyFactory.java +++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLRSAKeyFactory.java
@@ -165,7 +165,9 @@ throw new InvalidKeyException("key == null"); } - if (key instanceof RSAPublicKey) { + if ((key instanceof OpenSSLRSAPublicKey) || (key instanceof OpenSSLRSAPrivateKey)) { + return key; + } else if (key instanceof RSAPublicKey) { RSAPublicKey rsaKey = (RSAPublicKey) key; try {