ctubbsii closed pull request #344: ACCUMULO-4767 Remove duplicate code in
DefaultCryptoModule
URL: https://github.com/apache/accumulo/pull/344
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
b/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
index c929cabe4c..dbbfd848f2 100644
---
a/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
+++
b/core/src/main/java/org/apache/accumulo/core/security/crypto/BlockedOutputStream.java
@@ -45,6 +45,9 @@ public BlockedOutputStream(OutputStream out, int blockSize,
int bufferSize) {
@Override
public synchronized void flush() throws IOException {
+ if (!bb.hasArray()) {
+ throw new RuntimeException("BlockedOutputStream has no backing array.");
+ }
int size = bb.position();
if (size == 0)
return;
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 f0d0a6050c..c8b3162cf5 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
@@ -211,13 +211,8 @@ public CryptoModuleParameters
getEncryptingOutputStream(CryptoModuleParameters p
}
// Get the secret key
-
- SecureRandom secureRandom =
DefaultCryptoModuleUtils.getSecureRandom(params.getRandomNumberGenerator(),
params.getRandomNumberGeneratorProvider());
-
if (params.getPlaintextKey() == null) {
- byte[] randomKey = new byte[params.getKeyLength() / 8];
- secureRandom.nextBytes(randomKey);
- params.setPlaintextKey(randomKey);
+ params = generateNewRandomSessionKey(params);
}
// Encrypt the secret key
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services