cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobr...@apache.org
Subject cassandra git commit: ninja-fix an assert in CipherFactory, and added tests for it
Date Thu, 06 Aug 2015 12:14:16 GMT
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 <jasedbrown@gmail.com>
Authored: Thu Aug 6 05:14:15 2015 -0700
Committer: Jason Brown <jasedbrown@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]);
+    }
 }


Mime
View raw message