Repository: accumulo Updated Branches: refs/heads/1.6 ccd4897e1 -> e7dc5364d refs/heads/master eed30078a -> 300f7941c
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/1.6 Commit: e7dc5364dbfbfd4f7db35e9f189d6cadd399b399 Parents: ccd4897 Author: Josh Elser <els...@apache.org> Authored: Fri Oct 10 12:29:55 2014 -0400 Committer: Josh Elser <els...@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()) {