summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-07-19 14:40:40 +0100
committergitbuildkicker <android-build@google.com>2016-08-16 15:52:36 -0700
commit0cfcb79a5cf22eacd814b1c37b65a1b6398d90ab (patch)
tree2eaac2f6452d4401104e07e64a7bb4fc67c6bd73
parente565176fedcadcb6d1256a106bdb93d206d62043 (diff)
downloadlibcore-0cfcb79a5cf22eacd814b1c37b65a1b6398d90ab.zip
libcore-0cfcb79a5cf22eacd814b1c37b65a1b6398d90ab.tar.gz
libcore-0cfcb79a5cf22eacd814b1c37b65a1b6398d90ab.tar.bz2
CipherTest: in ASN1 encoding for GCM, no value for tag size means 12
Bug: 26231099 Bug: 26234568 Bug: 29876633 Change-Id: I44c0c68f1e92caf6547c9e3b494ec5b82b8cff5f
-rw-r--r--luni/src/test/java/libcore/javax/crypto/CipherTest.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/luni/src/test/java/libcore/javax/crypto/CipherTest.java b/luni/src/test/java/libcore/javax/crypto/CipherTest.java
index 0f642cf..398c688 100644
--- a/luni/src/test/java/libcore/javax/crypto/CipherTest.java
+++ b/luni/src/test/java/libcore/javax/crypto/CipherTest.java
@@ -3203,6 +3203,9 @@ public final class CipherTest extends TestCase {
}
}
+ // Test that when reading GCM parameters encoded using ASN1, a value for the tag size
+ // not present indicates a value of 12.
+ // https://b/29876633
public void test_DefaultGCMTagSizeAlgorithmParameterSpec() throws Exception {
final String AES = "AES";
final String AES_GCM = "AES/GCM/NoPadding";
@@ -3215,14 +3218,12 @@ public final class CipherTest extends TestCase {
(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);
+ assertEquals(12, tag.length);
}
public void testAES_ECB_PKCS5Padding_ShortBuffer_Failure() throws Exception {