You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/10/10 19:25:48 UTC

[2/3] git commit: ACCUMULO-3220 Fail fast if the provided cipher isn't a block cipher.

ACCUMULO-3220 Fail fast if the provided cipher isn't a block cipher.


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

Branch: refs/heads/master
Commit: e7dc5364dbfbfd4f7db35e9f189d6cadd399b399
Parents: ccd4897
Author: Josh Elser <el...@apache.org>
Authored: Fri Oct 10 12:29:55 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri Oct 10 12:29:55 2014 -0400

----------------------------------------------------------------------
 .../core/security/crypto/DefaultCryptoModule.java     | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/e7dc5364/core/src/main/java/org/apache/accumulo/core/security/crypto/DefaultCryptoModule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/DefaultCryptoModule.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/DefaultCryptoModule.java
index dfad05e..0ebbd5d 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/DefaultCryptoModule.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/DefaultCryptoModule.java
@@ -244,14 +244,18 @@ public class DefaultCryptoModule implements CryptoModule {
       params.setPlaintextOutputStream(new DiscardCloseOutputStream(params.getPlaintextOutputStream()));
     }
 
-    if (params.getCipher() == null) {
+    Cipher cipher = params.getCipher();
+    if (cipher == null) {
       initializeCipher(params);
     }
+
+    if (0 == cipher.getBlockSize()) {
+      throw new RuntimeException("Encryption cipher must be a block cipher");
+    }
     
-    CipherOutputStream cipherOutputStream = new CipherOutputStream(params.getPlaintextOutputStream(), params.getCipher());
-    BlockedOutputStream blockedOutputStream = new BlockedOutputStream(cipherOutputStream, params.getCipher().getBlockSize(), params.getBlockStreamSize());
-    
-    
+    CipherOutputStream cipherOutputStream = new CipherOutputStream(params.getPlaintextOutputStream(), cipher);
+    BlockedOutputStream blockedOutputStream = new BlockedOutputStream(cipherOutputStream, cipher.getBlockSize(), params.getBlockStreamSize());
+
     params.setEncryptedOutputStream(blockedOutputStream);
     
     if (params.getRecordParametersToStream()) {