You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2014/07/10 18:58:11 UTC

[1/2] git commit: [CXF-5869] Temporary file caching using encryption may get corrupted data

Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes d5621a999 -> c651e2671


[CXF-5869] Temporary file caching using encryption may get corrupted data


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

Branch: refs/heads/2.7.x-fixes
Commit: 141e88e6072fe8a85c4d6204719eca1b9d7eb04a
Parents: d5621a9
Author: Akitoshi Yoshida <ay...@apache.org>
Authored: Thu Jul 10 17:45:43 2014 +0200
Committer: Akitoshi Yoshida <ay...@apache.org>
Committed: Thu Jul 10 18:56:50 2014 +0200

----------------------------------------------------------------------
 api/src/main/java/org/apache/cxf/io/CipherPair.java | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/141e88e6/api/src/main/java/org/apache/cxf/io/CipherPair.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/io/CipherPair.java b/api/src/main/java/org/apache/cxf/io/CipherPair.java
index 0a4b856..8237221 100644
--- a/api/src/main/java/org/apache/cxf/io/CipherPair.java
+++ b/api/src/main/java/org/apache/cxf/io/CipherPair.java
@@ -32,6 +32,7 @@ import javax.crypto.spec.IvParameterSpec;
  */
 public class CipherPair {
     private String transformation;
+    private Cipher enccipher;
     private Key key;
     private byte[] ivp;
     
@@ -45,7 +46,6 @@ public class CipherPair {
         } else {
             a = transformation;
         }
-        Cipher enccipher = null;
         try {
             KeyGenerator keygen = KeyGenerator.getInstance(a);
             keygen.init(new SecureRandom());
@@ -64,13 +64,6 @@ public class CipherPair {
     }
     
     public Cipher getEncryptor() {
-        Cipher enccipher = null;
-        try {
-            enccipher = Cipher.getInstance(transformation);
-            enccipher.init(Cipher.ENCRYPT_MODE, key);
-        } catch (GeneralSecurityException e) {
-            // ignore
-        }
         return enccipher;
     }
     


[2/2] git commit: [CXF-5869] test using AES/CTR

Posted by ay...@apache.org.
[CXF-5869] test using AES/CTR


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

Branch: refs/heads/2.7.x-fixes
Commit: c651e2671edeace288e555316d136a7113f0127e
Parents: 141e88e
Author: Akitoshi Yoshida <ay...@apache.org>
Authored: Thu Jul 10 18:04:20 2014 +0200
Committer: Akitoshi Yoshida <ay...@apache.org>
Committed: Thu Jul 10 18:57:21 2014 +0200

----------------------------------------------------------------------
 .../org/apache/cxf/io/CachedStreamTestBase.java | 27 +++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c651e267/api/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java b/api/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
index ddd5fed..b88ba14 100755
--- a/api/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
+++ b/api/src/test/java/org/apache/cxf/io/CachedStreamTestBase.java
@@ -34,6 +34,9 @@ import org.junit.Assert;
 import org.junit.Test;
 
 public abstract class CachedStreamTestBase extends Assert {
+    // use two typical ciphers for testing
+    private static final String[] CIPHER_LIST = {"RC4", "AES/CTR/NoPadding"};
+
     protected abstract void reloadDefaultProperties();
     protected abstract Object createCache();
     protected abstract Object createCache(long threshold);
@@ -88,7 +91,13 @@ public abstract class CachedStreamTestBase extends Assert {
     @Test
     public void testEncryptAndDecryptWithDeleteOnClose() throws IOException {
         // need a 8-bit cipher so that all bytes are flushed when the stream is flushed.
-        Object cache = createCache(4, "RC4");
+        for (String cipher: CIPHER_LIST) {
+            verifyEncryptAndDecryptWithDeleteOnClose(cipher);
+        }
+    }
+    
+    private void verifyEncryptAndDecryptWithDeleteOnClose(String cipher) throws IOException {
+        Object cache = createCache(4, cipher);
         final String text = "Hello Secret World!";
         File tmpfile = getTmpFile(text, cache);
         assertNotNull(tmpfile);
@@ -111,8 +120,14 @@ public abstract class CachedStreamTestBase extends Assert {
 
     @Test
     public void testEncryptAndDecryptWithDeleteOnInClose() throws IOException {
+        for (String cipher: CIPHER_LIST) {
+            verifyEncryptAndDecryptWithDeleteOnInClose(cipher);
+        }
+    }
+
+    private void verifyEncryptAndDecryptWithDeleteOnInClose(String cipher) throws IOException {
         // need a 8-bit cipher so that all bytes are flushed when the stream is flushed.
-        Object cache = createCache(4, "RC4");
+        Object cache = createCache(4, cipher);
         final String text = "Hello Secret World!";
         File tmpfile = getTmpFile(text, cache);
         assertNotNull(tmpfile);
@@ -133,8 +148,14 @@ public abstract class CachedStreamTestBase extends Assert {
 
     @Test
     public void testEncryptAndDecryptPartially() throws IOException {
+        for (String cipher: CIPHER_LIST) {
+            verifyEncryptAndDecryptPartially(cipher);
+        }
+    }
+
+    private void verifyEncryptAndDecryptPartially(String cipher) throws IOException {
         // need a 8-bit cipher so that all bytes are flushed when the stream is flushed.
-        Object cache = createCache(4, "RC4");
+        Object cache = createCache(4, cipher);
         final String text = "Hello Secret World!";
         File tmpfile = getTmpFile(text, cache);
         assertNotNull(tmpfile);