aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-01-05 18:59:44 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-01-05 18:59:44 +0000
commit2f52a567e236541eae716c29d7ef8b4d65b6d7f7 (patch)
tree232a5f0e95409fa19d1238d515090459d22c794b
parent2588213a46f8887cae6a18752b06f08f29390605 (diff)
parentf21d34928a714fcf5556d99b91f2aaca59e69964 (diff)
downloadlibcore-oreo-m2-release.tar.gz
Snap for 4527419 from f21d34928a714fcf5556d99b91f2aaca59e69964 to oc-m2-releaseandroid-8.1.0_r20oreo-m2-release
Change-Id: I90f53384d125980c66d5a592a50baf280207080a
-rw-r--r--luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java b/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java
index d287b972ada..56df2bbe040 100644
--- a/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java
+++ b/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java
@@ -15,10 +15,16 @@
*/
package libcore.javax.crypto.spec;
+import java.security.KeyFactory;
import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
+import java.security.spec.X509EncodedKeySpec;
import tests.security.CipherAsymmetricCryptHelper;
+import tests.security.DefaultKeys;
import tests.security.KeyFactoryTest;
public class KeyFactoryTestRSA extends
@@ -33,4 +39,18 @@ public class KeyFactoryTestRSA extends
protected void check(KeyPair keyPair) throws Exception {
new CipherAsymmetricCryptHelper("RSA").test(keyPair);
}
+
+ public void testExtraBufferSpace() throws Exception {
+ PrivateKey privateKey = DefaultKeys.getPrivateKey("RSA");
+ byte[] encoded = privateKey.getEncoded();
+ byte[] longBuffer = new byte[encoded.length + 147];
+ System.arraycopy(encoded, 0, longBuffer, 0, encoded.length);
+ KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(longBuffer));
+
+ PublicKey publicKey = DefaultKeys.getPublicKey("RSA");
+ encoded = publicKey.getEncoded();
+ longBuffer = new byte[encoded.length + 147];
+ System.arraycopy(encoded, 0, longBuffer, 0, encoded.length);
+ KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(longBuffer));
+ }
}