accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/3] git commit: ACCUMULO-3220 Fail fast if the provided cipher isn't a block cipher.
Date Fri, 10 Oct 2014 17:25:48 GMT
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 <elserj@apache.org>
Authored: Fri Oct 10 12:29:55 2014 -0400
Committer: Josh Elser <elserj@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()) {


Mime
View raw message