diff options
author | Kenny Root <kroot@google.com> | 2015-04-28 15:18:18 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2015-04-28 15:46:10 -0700 |
commit | b76ea2456f3d7fd99fa3d42a3ef7e8b6f61f77c5 (patch) | |
tree | 4d0388ec0743157c58fa95b59e19d9e2ac24c285 /luni/src/test/java | |
parent | 824b1cd012662cfa16a8787bf908a0b5fb13e54b (diff) | |
download | libcore-b76ea2456f3d7fd99fa3d42a3ef7e8b6f61f77c5.zip libcore-b76ea2456f3d7fd99fa3d42a3ef7e8b6f61f77c5.tar.gz libcore-b76ea2456f3d7fd99fa3d42a3ef7e8b6f61f77c5.tar.bz2 |
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
Diffstat (limited to 'luni/src/test/java')
-rw-r--r-- | luni/src/test/java/libcore/javax/crypto/CipherTest.java | 11 |
1 files changed, 11 insertions, 0 deletions
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 { |