hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From y...@apache.org
Subject svn commit: r1604537 - in /hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common: ./ src/main/java/org/apache/hadoop/crypto/ src/test/java/org/apache/hadoop/crypto/
Date Sun, 22 Jun 2014 07:20:47 GMT
Author: yliu
Date: Sun Jun 22 07:20:47 2014
New Revision: 1604537

URL: http://svn.apache.org/r1604537
Log:
HADOOP-10713. Refactor CryptoCodec#generateSecureRandom to take a byte[]. (wang via yliu)

Modified:
    hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/CHANGES-fs-encryption.txt
    hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoCodec.java
    hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/JCEAESCTRCryptoCodec.java
    hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoCodec.java

Modified: hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/CHANGES-fs-encryption.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/CHANGES-fs-encryption.txt?rev=1604537&r1=1604536&r2=1604537&view=diff
==============================================================================
--- hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/CHANGES-fs-encryption.txt
(original)
+++ hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/CHANGES-fs-encryption.txt
Sun Jun 22 07:20:47 2014
@@ -25,6 +25,9 @@ fs-encryption (Unreleased)
     HADOOP-10662. NullPointerException in CryptoInputStream while wrapped
     stream is not ByteBufferReadable. Add tests using normal stream. (Yi Liu)
 
+    HADOOP-10713. Refactor CryptoCodec#generateSecureRandom to take a byte[]. 
+    (wang via yliu)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoCodec.java?rev=1604537&r1=1604536&r2=1604537&view=diff
==============================================================================
--- hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoCodec.java
(original)
+++ hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoCodec.java
Sun Jun 22 07:20:47 2014
@@ -81,9 +81,10 @@ public abstract class CryptoCodec implem
   public abstract void calculateIV(byte[] initIV, long counter, byte[] IV);
   
   /**
-   * Generate secure random.
-   * @param bytes length of the secure random
-   * @return byte[] the secure random
+   * Generate a number of secure, random bytes suitable for cryptographic use.
+   * This method needs to be thread-safe.
+   *
+   * @param bytes byte array to populate with random data
    */
-  public abstract byte[] generateSecureRandom(int bytes);
+  public abstract void generateSecureRandom(byte[] bytes);
 }

Modified: hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/JCEAESCTRCryptoCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/JCEAESCTRCryptoCodec.java?rev=1604537&r1=1604536&r2=1604537&view=diff
==============================================================================
--- hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/JCEAESCTRCryptoCodec.java
(original)
+++ hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/JCEAESCTRCryptoCodec.java
Sun Jun 22 07:20:47 2014
@@ -79,10 +79,8 @@ public class JCEAESCTRCryptoCodec extend
   }
   
   @Override
-  public byte[] generateSecureRandom(int bytes) {
-    final byte[] data = new byte[bytes];
-    random.nextBytes(data);
-    return data;
+  public void generateSecureRandom(byte[] bytes) {
+    random.nextBytes(bytes);
   }  
   
   private static class JCEAESCTRCipher implements Encryptor, Decryptor {

Modified: hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoCodec.java?rev=1604537&r1=1604536&r2=1604537&view=diff
==============================================================================
--- hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoCodec.java
(original)
+++ hadoop/common/branches/fs-encryption/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoCodec.java
Sun Jun 22 07:20:47 2014
@@ -49,8 +49,10 @@ public class TestCryptoCodec {
   }
   
   private void checkSecureRandom(int len) {
-    byte[] rand = codec.generateSecureRandom(len);
-    byte[] rand1 = codec.generateSecureRandom(len);
+    byte[] rand = new byte[len];
+    byte[] rand1 = new byte[len];
+    codec.generateSecureRandom(rand);
+    codec.generateSecureRandom(rand1);
     
     Assert.assertEquals(len, rand.length);
     Assert.assertEquals(len, rand1.length);



Mime
View raw message