Dougniel commented on code in PR #332:
URL: https://github.com/apache/commons-compress/pull/332#discussion_r1037684209


##########
src/main/java/org/apache/commons/compress/archivers/sevenz/AES256Options.java:
##########
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.commons.compress.archivers.sevenz;
+
+import java.util.Arrays;
+import java.util.Random;
+
+public class AES256Options {
+    byte[] password;
+    byte[] salt = new byte[0];
+    byte[] iv = new byte[16];
+    int numCyclesPower = 19;
+
+    public AES256Options(byte[] password) {
+        this.password = password;

Review Comment:
   I consider myself not enought skilled in security concerns, but I asked 
myself about that too when I saw this mechanism that [clears password as soon 
as 
possible](https://github.com/apache/commons-compress/blob/0cbe431fe13e40735ccba054bab8fe4a83062b37/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java#L386)
 🤔.
    
   But I have chosen to implement the encryption like decryption done
   in 
[`SevenZFile.java`](https://github.com/apache/commons-compress/blob/0cbe431fe13e40735ccba054bab8fe4a83062b37/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java#L102)
 (that stores password too) for homogeneous reasons 🤷.
   
   By the way, as the password is required to decrypt each file independently 
(the sevenZ archive is not entirely encrypted - we can access metadata like 
file names without password - only files are encrypted)_. I don't know how to 
manage that without storing it somewhere in memory - asking user to fulfill it 
for each file to compress/decompress ? Even in this way it will be stored 
inside the Input/OutputStream used by the library user.
   
   👉🏼 What I could try is to store it in less places (I stored it in 
`AES256Options` as in `SevenZOutputFile`)
   



##########
src/main/java/org/apache/commons/compress/archivers/sevenz/AES256Options.java:
##########
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.commons.compress.archivers.sevenz;
+
+import java.util.Arrays;
+import java.util.Random;
+
+public class AES256Options {
+    byte[] password;
+    byte[] salt = new byte[0];
+    byte[] iv = new byte[16];
+    int numCyclesPower = 19;
+
+    public AES256Options(byte[] password) {
+        this.password = password;

Review Comment:
   I consider myself not enought skilled in security concerns, but I asked 
myself about that too when I saw this mechanism that [clears password as soon 
as 
possible](https://github.com/apache/commons-compress/blob/0cbe431fe13e40735ccba054bab8fe4a83062b37/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java#L386)
 🤔.
    
   But I have chosen to implement the encryption like decryption done in 
[`SevenZFile.java`](https://github.com/apache/commons-compress/blob/0cbe431fe13e40735ccba054bab8fe4a83062b37/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java#L102)
 (that stores password too) for homogeneous reasons 🤷.
   
   By the way, as the password is required to decrypt each file independently 
(the sevenZ archive is not entirely encrypted - we can access metadata like 
file names without password - only files are encrypted)_. I don't know how to 
manage that without storing it somewhere in memory - asking user to fulfill it 
for each file to compress/decompress ? Even in this way it will be stored 
inside the Input/OutputStream used by the library user.
   
   👉🏼 What I could try is to store it in less places (I stored it in 
`AES256Options` as in `SevenZOutputFile`)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to