Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C2F7A18DED for ; Thu, 6 Aug 2015 12:14:16 +0000 (UTC) Received: (qmail 72621 invoked by uid 500); 6 Aug 2015 12:14:16 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 72585 invoked by uid 500); 6 Aug 2015 12:14:16 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 72573 invoked by uid 99); 6 Aug 2015 12:14:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2015 12:14:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 28DC6E683D; Thu, 6 Aug 2015 12:14:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jasobrown@apache.org To: commits@cassandra.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cassandra git commit: ninja-fix an assert in CipherFactory, and added tests for it Date: Thu, 6 Aug 2015 12:14:16 +0000 (UTC) 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 Authored: Thu Aug 6 05:14:15 2015 -0700 Committer: Jason Brown 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]); + } }