summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@cyngn.com>2016-04-05 12:31:36 -0700
committerJessica Wagantall <jwagantall@cyngn.com>2016-04-05 12:31:36 -0700
commit67f458c83a7199a89db990700d4a5f168d02f18a (patch)
treefbbf1fdcf46a0c491a56f0bf6c721af335abbf85
parent72904992b3e2803487c0deda965dc510d6d84fb5 (diff)
parent9eba839041378d16c45906c233887df16209a5d7 (diff)
downloadlibcore-67f458c83a7199a89db990700d4a5f168d02f18a.tar.gz
libcore-67f458c83a7199a89db990700d4a5f168d02f18a.tar.bz2
libcore-67f458c83a7199a89db990700d4a5f168d02f18a.zip
Merge tag 'android-6.0.1_r24' into HEAD
Ticket: CYNGNOS-2213 Android 6.0.1 release 24
-rw-r--r--luni/src/test/java/libcore/javax/crypto/CipherTest.java22
1 files changed, 22 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 dd7d6e74f..38d6d8ddf 100644
--- a/luni/src/test/java/libcore/javax/crypto/CipherTest.java
+++ b/luni/src/test/java/libcore/javax/crypto/CipherTest.java
@@ -3203,6 +3203,28 @@ public final class CipherTest extends TestCase {
}
}
+ public void test_DefaultGCMTagSizeAlgorithmParameterSpec() throws Exception {
+ final String AES = "AES";
+ final String AES_GCM = "AES/GCM/NoPadding";
+ byte[] input = new byte[16];
+ byte[] key = new byte[16];
+ Cipher cipher = Cipher.getInstance(AES_GCM, "BC");
+ AlgorithmParameters param = AlgorithmParameters.getInstance("GCM");
+ param.init(new byte[] {
+ (byte) 48, // DER encoding : tag_Sequence
+ (byte) 14, // DER encoding : total length
+ (byte) 4, // DER encoding : tag_OctetString
+ (byte) 12, // DER encoding : counter length
+ // Note that IV's size 12 bytes is recommended, but authentication tag size should be 16
+ // bytes.
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 });
+ cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, AES), param);
+ byte[] ciphertext = cipher.update(input);
+ byte[] tag = cipher.doFinal();
+ assertEquals(16, tag.length);
+ }
+
public void testAES_ECB_PKCS5Padding_ShortBuffer_Failure() throws Exception {
for (String provider : AES_PROVIDERS) {
testAES_ECB_PKCS5Padding_ShortBuffer_Failure(provider);