From b76ea2456f3d7fd99fa3d42a3ef7e8b6f61f77c5 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 28 Apr 2015 15:18:18 -0700 Subject: CipherTest: make multiple doFinal calls for RSA/ECB The OpenSSLCipherRSA wasn't updating its buffer offset. The regular test_getInstance loop tests this, but since RSA/ECB is 'special' we have this extra test. Change-Id: I27819dad1b0bf59ddd1782b722757fe7526db2df --- luni/src/test/java/libcore/javax/crypto/CipherTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'luni') diff --git a/luni/src/test/java/libcore/javax/crypto/CipherTest.java b/luni/src/test/java/libcore/javax/crypto/CipherTest.java index 494d15e..65ddb3c 100644 --- a/luni/src/test/java/libcore/javax/crypto/CipherTest.java +++ b/luni/src/test/java/libcore/javax/crypto/CipherTest.java @@ -1361,11 +1361,22 @@ public final class CipherTest extends TestCase { Cipher encryptCipher = Cipher.getInstance("RSA/ECB/NoPadding", provider); encryptCipher.init(Cipher.ENCRYPT_MODE, encryptKey); byte[] cipherText = encryptCipher.doFinal(prePaddedPlainText); + encryptCipher.update(prePaddedPlainText); + encryptCipher.init(Cipher.ENCRYPT_MODE, encryptKey); + byte[] cipherText2 = encryptCipher.doFinal(prePaddedPlainText); + assertEquals(Arrays.toString(cipherText), + Arrays.toString(cipherText2)); + Cipher decryptCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding", provider); decryptCipher.init(Cipher.DECRYPT_MODE, decryptKey); byte[] plainText = decryptCipher.doFinal(cipherText); assertEquals(Arrays.toString(ORIGINAL_PLAIN_TEXT), Arrays.toString(plainText)); + decryptCipher.update(prePaddedPlainText); + decryptCipher.init(Cipher.DECRYPT_MODE, decryptKey); + byte[] plainText2 = decryptCipher.doFinal(cipherText); + assertEquals(Arrays.toString(plainText), + Arrays.toString(plainText2)); } public void testOutputPKCS1Padding() throws Exception { -- cgit v1.1