]> source.dussan.org Git - poi.git/commitdiff
FilePassRecord type of 4 is now documented as the same as 2 & 3, see bug #35897
authorNick Burch <nick@apache.org>
Tue, 4 Nov 2014 23:22:50 +0000 (23:22 +0000)
committerNick Burch <nick@apache.org>
Tue, 4 Nov 2014 23:22:50 +0000 (23:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1636776 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/FilePassRecord.java
src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
test-data/spreadsheet/35897-type4.xls [new file with mode: 0644]

index 32ad6787e2f3673c27165ed826bd5aae833fc17c..59d144f8cea9659b46b6f9aeba565f68ed2950d3 100644 (file)
@@ -45,6 +45,7 @@ public final class FilePassRecord extends StandardRecord {
            private static final int ENCRYPTION_OTHER_RC4 = 1;
            private static final int ENCRYPTION_OTHER_CAPI_2 = 2;
            private static final int ENCRYPTION_OTHER_CAPI_3 = 3;
+        private static final int ENCRYPTION_OTHER_CAPI_4 = 4;
            
            private byte[] _salt;
            private byte[] _encryptedVerifier;
@@ -60,6 +61,7 @@ public final class FilePassRecord extends StandardRecord {
                        break;
                    case ENCRYPTION_OTHER_CAPI_2:
                    case ENCRYPTION_OTHER_CAPI_3:
+                case ENCRYPTION_OTHER_CAPI_4:
                        throw new EncryptedDocumentException(
                                "HSSF does not currently support CryptoAPI encryption");
                    default:
index 9083fbdf756f6074301496b94c77e10914efe9c1..ff8e18937e3c6c02960784b2219414b2958aa948 100644 (file)
@@ -36,6 +36,7 @@ public class TestBiffViewer extends BaseXLSIteratingTest {
                SILENT_EXCLUDED.add("43493.xls");       // HSSFWorkbook cannot open it as well
                SILENT_EXCLUDED.add("password.xls"); 
                SILENT_EXCLUDED.add("46904.xls");
+        SILENT_EXCLUDED.add("35897-type4.xls"); // unsupported crypto api header 
                SILENT_EXCLUDED.add("xor-encryption-abc.xls"); // unsupported XOR-encryption
        }
 
index 575e3b4850f1ed4248967b3cec1a9d12791b5cb6..015c8c59501c646d55e9819c115c5a4eea81fed7 100644 (file)
@@ -2460,6 +2460,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
         } finally {
             Biff8EncryptionKey.setCurrentUserPassword(null);
         }
+        
+        // One using the only-recently-documented encryption header type 4,
+        //  and the RC4 CryptoAPI encryption header structure
+        try {
+            openSample("35897-type4.xls");
+            fail("POI doesn't currently support the RC4 CryptoAPI encryption header structure");
+        } catch (EncryptedDocumentException e) {}
     }
 
     @Test
diff --git a/test-data/spreadsheet/35897-type4.xls b/test-data/spreadsheet/35897-type4.xls
new file mode 100644 (file)
index 0000000..c3eadbb
Binary files /dev/null and b/test-data/spreadsheet/35897-type4.xls differ