You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ja...@apache.org on 2015/08/06 14:14:16 UTC

cassandra git commit: ninja-fix an assert in CipherFactory, and added tests for it

Repository: cassandra
Updated Branches:
  refs/heads/trunk 313d9c9b5 -> f512995e0


ninja-fix an assert in CipherFactory, and added tests for it


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f512995e
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f512995e
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f512995e

Branch: refs/heads/trunk
Commit: f512995e09bf2364c0a9d7c22e34e30c231a5836
Parents: 313d9c9
Author: Jason Brown <ja...@gmail.com>
Authored: Thu Aug 6 05:14:15 2015 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Thu Aug 6 05:14:15 2015 -0700

----------------------------------------------------------------------
 .../org/apache/cassandra/security/CipherFactory.java    |  2 +-
 .../apache/cassandra/security/CipherFactoryTest.java    | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f512995e/src/java/org/apache/cassandra/security/CipherFactory.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/security/CipherFactory.java b/src/java/org/apache/cassandra/security/CipherFactory.java
index 0ff9867..7c1495a 100644
--- a/src/java/org/apache/cassandra/security/CipherFactory.java
+++ b/src/java/org/apache/cassandra/security/CipherFactory.java
@@ -109,7 +109,7 @@ public class CipherFactory
 
     public Cipher getDecryptor(String transformation, String keyAlias, byte[] iv) throws IOException
     {
-        assert iv != null || iv.length > 0 : "trying to decrypt, but the initialization vector is empty";
+        assert iv != null && iv.length > 0 : "trying to decrypt, but the initialization vector is empty";
         return buildCipher(transformation, keyAlias, iv, Cipher.DECRYPT_MODE);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f512995e/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/security/CipherFactoryTest.java b/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
index 4239973..bb6f7ce 100644
--- a/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
+++ b/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
@@ -84,4 +84,16 @@ public class CipherFactoryTest
         Cipher c2 = cipherFactory.buildCipher(encryptionOptions.cipher, EncryptionContextGenerator.KEY_ALIAS_2, nextIV(), Cipher.DECRYPT_MODE);
         Assert.assertFalse(c1 == c2);
     }
+
+    @Test(expected = AssertionError.class)
+    public void getDecryptor_NullIv() throws IOException
+    {
+        cipherFactory.getDecryptor(encryptionOptions.cipher, encryptionOptions.key_alias, null);
+    }
+
+    @Test(expected = AssertionError.class)
+    public void getDecryptor_EmptyIv() throws IOException
+    {
+        cipherFactory.getDecryptor(encryptionOptions.cipher, encryptionOptions.key_alias, new byte[0]);
+    }
 }