diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2016-08-08 00:10:44 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2016-08-08 00:10:44 +0000 |
commit | 075e2bfce2f6c881820c7ec2d069d5331a2b6c9b (patch) | |
tree | b1b775c4bd5c3930de0de69670a36fc5e88247b0 /src/testcases/org | |
parent | e84c6152dde07a48b2982f9e9ce016529548e11d (diff) | |
download | poi-075e2bfce2f6c881820c7ec2d069d5331a2b6c9b.tar.gz poi-075e2bfce2f6c881820c7ec2d069d5331a2b6c9b.zip |
HSSF CryptoAPI decryption support
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hssf_cryptoapi@1755461 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/AllRecordTests.java | 4 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8EncryptionKey.java | 102 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestCryptoAPI.java | 62 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/poifs/crypt/AllEncryptionTests.java (renamed from src/testcases/org/apache/poi/hssf/record/crypto/AllHSSFEncryptionTests.java) | 11 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java (renamed from src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8DecryptingStream.java) | 25 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java | 41 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java (renamed from src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java) | 3 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java | 106 |
8 files changed, 208 insertions, 146 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java index b7598fd124..e32816756c 100644 --- a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java +++ b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java @@ -21,8 +21,8 @@ import org.apache.poi.hssf.record.aggregates.AllRecordAggregateTests; import org.apache.poi.hssf.record.cf.TestCellRange; import org.apache.poi.hssf.record.chart.AllChartRecordTests; import org.apache.poi.hssf.record.common.TestUnicodeString; -import org.apache.poi.hssf.record.crypto.AllHSSFEncryptionTests; import org.apache.poi.hssf.record.pivot.AllPivotRecordTests; +import org.apache.poi.poifs.crypt.AllEncryptionTests; import org.apache.poi.ss.formula.constant.TestConstantValueParser; import org.apache.poi.ss.formula.ptg.AllFormulaTests; import org.junit.runner.RunWith; @@ -34,7 +34,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ AllChartRecordTests.class, - AllHSSFEncryptionTests.class, + AllEncryptionTests.class, AllFormulaTests.class, AllPivotRecordTests.class, AllRecordAggregateTests.class, diff --git a/src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8EncryptionKey.java b/src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8EncryptionKey.java deleted file mode 100644 index 294cb09e7c..0000000000 --- a/src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8EncryptionKey.java +++ /dev/null @@ -1,102 +0,0 @@ -/* ==================================================================== - 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.poi.hssf.record.crypto; - -import java.util.Arrays; - -import junit.framework.ComparisonFailure; -import junit.framework.TestCase; - -import org.apache.poi.util.HexDump; -import org.apache.poi.util.HexRead; - -/** - * Tests for {@link Biff8EncryptionKey} - * - * @author Josh Micich - */ -public final class TestBiff8EncryptionKey extends TestCase { - - private static byte[] fromHex(String hexString) { - return HexRead.readFromString(hexString); - } - public void testCreateKeyDigest() { - byte[] docIdData = fromHex("17 F6 D1 6B 09 B1 5F 7B 4C 9D 03 B4 81 B5 B4 4A"); - byte[] keyDigest = Biff8RC4Key.createKeyDigest("MoneyForNothing", docIdData); - byte[] expResult = fromHex("C2 D9 56 B2 6B"); - if (!Arrays.equals(expResult, keyDigest)) { - throw new ComparisonFailure("keyDigest mismatch", HexDump.toHex(expResult), HexDump.toHex(keyDigest)); - } - } - - - public void testValidateWithDefaultPassword() { - - String docIdSuffixA = "F 35 52 38 0D 75 4A E6 85 C2 FD 78 CE 3D D1 B6"; // valid prefix is 'D' - String saltHashA = "30 38 BE 5E 93 C5 7E B4 5F 52 CD A1 C6 8F B6 2A"; - String saltDataA = "D4 04 43 EC B7 A7 6F 6A D2 68 C7 DF CF A8 80 68"; - - String docIdB = "39 D7 80 41 DA E4 74 2C 8C 84 F9 4D 39 9A 19 2D"; - String saltDataSuffixB = "3 EA 8D 52 11 11 37 D2 BD 55 4C 01 0A 47 6E EB"; // valid prefix is 'C' - String saltHashB = "96 19 F5 D0 F1 63 08 F1 3E 09 40 1E 87 F0 4E 16"; - - confirmValid(true, "D" + docIdSuffixA, saltDataA, saltHashA); - confirmValid(true, docIdB, "C" + saltDataSuffixB, saltHashB); - confirmValid(false, "E" + docIdSuffixA, saltDataA, saltHashA); - confirmValid(false, docIdB, "B" + saltDataSuffixB, saltHashB); - } - - public void testValidateWithSuppliedPassword() { - - String docId = "DF 35 52 38 0D 75 4A E6 85 C2 FD 78 CE 3D D1 B6"; - String saltData = "D4 04 43 EC B7 A7 6F 6A D2 68 C7 DF CF A8 80 68"; - String saltHashA = "8D C2 63 CC E1 1D E0 05 20 16 96 AF 48 59 94 64"; // for password '5ecret' - String saltHashB = "31 0B 0D A4 69 55 8E 27 A1 03 AD C9 AE F8 09 04"; // for password '5ecret' - - confirmValid(true, docId, saltData, saltHashA, "5ecret"); - confirmValid(false, docId, saltData, saltHashA, "Secret"); - confirmValid(true, docId, saltData, saltHashB, "Secret"); - confirmValid(false, docId, saltData, saltHashB, "secret"); - } - - - private static void confirmValid(boolean expectedResult, - String docIdHex, String saltDataHex, String saltHashHex) { - confirmValid(expectedResult, docIdHex, saltDataHex, saltHashHex, null); - } - private static void confirmValid(boolean expectedResult, - String docIdHex, String saltDataHex, String saltHashHex, String password) { - byte[] docId = fromHex(docIdHex); - byte[] saltData = fromHex(saltDataHex); - byte[] saltHash = fromHex(saltHashHex); - - - Biff8EncryptionKey key; - if (password == null) { - key = Biff8EncryptionKey.create(docId); - } else { - key = Biff8EncryptionKey.create(password, docId); - } - boolean actResult = key.validate(saltData, saltHash); - if (expectedResult) { - assertTrue("validate failed", actResult); - } else { - assertFalse("validate succeeded unexpectedly", actResult); - } - } -} diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCryptoAPI.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCryptoAPI.java new file mode 100644 index 0000000000..e7618073b3 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCryptoAPI.java @@ -0,0 +1,62 @@ +/* ==================================================================== + 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.poi.hssf.usermodel; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.apache.poi.hssf.HSSFITestDataProvider; +import org.apache.poi.hssf.extractor.ExcelExtractor; +import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; +import org.junit.AfterClass; +import org.junit.Test; + +public class TestCryptoAPI { + final HSSFITestDataProvider ssTests = HSSFITestDataProvider.instance; + + @AfterClass + public static void resetPW() { + Biff8EncryptionKey.setCurrentUserPassword(null); + } + + @Test + public void bug59857() throws IOException { + Biff8EncryptionKey.setCurrentUserPassword("abc"); + HSSFWorkbook wb1 = ssTests.openSampleWorkbook("xor-encryption-abc.xls"); + String textExpected = "Sheet1\n1\n2\n3\n"; + String textActual = new ExcelExtractor(wb1).getText(); + assertEquals(textExpected, textActual); + wb1.close(); + + Biff8EncryptionKey.setCurrentUserPassword("password"); + HSSFWorkbook wb2 = ssTests.openSampleWorkbook("password.xls"); + textExpected = "A ZIP bomb is a variant of mail-bombing. After most commercial mail servers began checking mail with anti-virus software and filtering certain malicious file types, trojan horse viruses tried to send themselves compressed into archives, such as ZIP, RAR or 7-Zip. Mail server software was then configured to unpack archives and check their contents as well. That gave black hats the idea to compose a \"bomb\" consisting of an enormous text file, containing, for example, only the letter z repeated millions of times. Such a file compresses into a relatively small archive, but its unpacking (especially by early versions of mail servers) would use a high amount of processing power, RAM and swap space, which could result in denial of service. Modern mail server computers usually have sufficient intelligence to recognize such attacks as well as sufficient processing power and memory space to process malicious attachments without interruption of service, though some are still susceptible to this technique if the ZIP bomb is mass-mailed."; + textActual = new ExcelExtractor(wb2).getText(); + assertTrue(textActual.contains(textExpected)); + wb2.close(); + + Biff8EncryptionKey.setCurrentUserPassword("freedom"); + HSSFWorkbook wb3 = ssTests.openSampleWorkbook("35897-type4.xls"); + textExpected = "Sheet1\nhello there!\n"; + textActual = new ExcelExtractor(wb3).getText(); + assertEquals(textExpected, textActual); + wb3.close(); + } +} diff --git a/src/testcases/org/apache/poi/hssf/record/crypto/AllHSSFEncryptionTests.java b/src/testcases/org/apache/poi/poifs/crypt/AllEncryptionTests.java index c727008788..8bd67db91b 100644 --- a/src/testcases/org/apache/poi/hssf/record/crypto/AllHSSFEncryptionTests.java +++ b/src/testcases/org/apache/poi/poifs/crypt/AllEncryptionTests.java @@ -15,20 +15,19 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.record.crypto; +package org.apache.poi.poifs.crypt; import org.junit.runner.RunWith; import org.junit.runners.Suite; /** - * Collects all tests for package <tt>org.apache.poi.hssf.record.crypto</tt>. - * - * @author Josh Micich + * Collects all tests for package <tt>org.apache.poi.poifs.crypt</tt>. */ @RunWith(Suite.class) @Suite.SuiteClasses({ TestBiff8DecryptingStream.class, - TestBiff8EncryptionKey.class + TestCipherAlgorithm.class, + TestXorEncryption.class }) -public final class AllHSSFEncryptionTests { +public final class AllEncryptionTests { } diff --git a/src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8DecryptingStream.java b/src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java index 26eb16b2f7..43ee429417 100644 --- a/src/testcases/org/apache/poi/hssf/record/crypto/TestBiff8DecryptingStream.java +++ b/src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.record.crypto; +package org.apache.poi.poifs.crypt; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -23,17 +23,18 @@ import static org.junit.Assert.assertFalse; import java.io.InputStream; import java.util.Arrays; -import junit.framework.AssertionFailedError; -import junit.framework.ComparisonFailure; +import javax.crypto.spec.SecretKeySpec; +import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; import org.junit.Test; +import junit.framework.AssertionFailedError; +import junit.framework.ComparisonFailure; + /** * Tests for {@link Biff8DecryptingStream} - * - * @author Josh Micich */ public final class TestBiff8DecryptingStream { @@ -49,12 +50,10 @@ public final class TestBiff8DecryptingStream { public MockStream(int initialValue) { _initialValue = initialValue; } + public int read() { return (_initialValue+_position++) & 0xFF; } - public int getPosition() { - return _position; - } } private static final class StreamTester { @@ -70,7 +69,11 @@ public final class TestBiff8DecryptingStream { public StreamTester(MockStream ms, String keyDigestHex, int expectedFirstInt) { _ms = ms; byte[] keyDigest = HexRead.readFromString(keyDigestHex); - _bds = new Biff8DecryptingStream(_ms, 0, new Biff8RC4Key(keyDigest)); + EncryptionInfo ei = new EncryptionInfo(EncryptionMode.binaryRC4); + Decryptor dec = ei.getDecryptor(); + dec.setSecretKey(new SecretKeySpec(keyDigest, "RC4")); + + _bds = new Biff8DecryptingStream(_ms, 0, ei); assertEquals(expectedFirstInt, _bds.readInt()); _errorsOccurred = false; } @@ -84,11 +87,11 @@ public final class TestBiff8DecryptingStream { * Also confirms that read position of the underlying stream is aligned. */ public void rollForward(int fromPosition, int toPosition) { - assertEquals(fromPosition, _ms.getPosition()); + assertEquals(fromPosition, _bds.getPosition()); for (int i = fromPosition; i < toPosition; i++) { _bds.readByte(); } - assertEquals(toPosition, _ms.getPosition()); + assertEquals(toPosition, _bds.getPosition()); } public void confirmByte(int expVal) { diff --git a/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java b/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java index 1e0fc14d8d..68d6ab2901 100644 --- a/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java +++ b/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java @@ -17,14 +17,14 @@ package org.apache.poi.poifs.crypt; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.apache.poi.EncryptedDocumentException; import org.junit.Test; public class TestCipherAlgorithm { @Test - public void test() { + public void validInputs() { assertEquals(128, CipherAlgorithm.aes128.defaultKeySize); for(CipherAlgorithm alg : CipherAlgorithm.values()) { @@ -33,27 +33,20 @@ public class TestCipherAlgorithm { assertEquals(CipherAlgorithm.aes128, CipherAlgorithm.fromEcmaId(0x660E)); assertEquals(CipherAlgorithm.aes192, CipherAlgorithm.fromXmlId("AES", 192)); - - try { - CipherAlgorithm.fromEcmaId(0); - fail("Should throw exception"); - } catch (EncryptedDocumentException e) { - // expected - } - - try { - CipherAlgorithm.fromXmlId("AES", 1); - fail("Should throw exception"); - } catch (EncryptedDocumentException e) { - // expected - } - - try { - CipherAlgorithm.fromXmlId("RC1", 0x40); - fail("Should throw exception"); - } catch (EncryptedDocumentException e) { - // expected - } } - + + @Test(expected=EncryptedDocumentException.class) + public void invalidEcmaId() { + CipherAlgorithm.fromEcmaId(0); + } + + @Test(expected=EncryptedDocumentException.class) + public void invalidXmlId1() { + CipherAlgorithm.fromXmlId("AES", 1); + } + + @Test(expected=EncryptedDocumentException.class) + public void invalidXmlId2() { + CipherAlgorithm.fromXmlId("RC1", 0x40); + } } diff --git a/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java b/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java index e79f2fcc6e..cae6426f61 100644 --- a/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java +++ b/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java @@ -15,13 +15,14 @@ limitations under the License.
==================================================================== */
-package org.apache.poi.hssf.record.crypto;
+package org.apache.poi.poifs.crypt;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.crypt.CryptoFunctions;
diff --git a/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java b/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java new file mode 100644 index 0000000000..b1155c3f57 --- /dev/null +++ b/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java @@ -0,0 +1,106 @@ +/* ==================================================================== + 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.poi.poifs.crypt.binaryrc4; + +import static org.apache.poi.util.HexRead.readFromString; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.security.GeneralSecurityException; + +import javax.crypto.SecretKey; + +import org.apache.poi.poifs.crypt.Decryptor; +import org.apache.poi.poifs.crypt.EncryptionInfo; +import org.apache.poi.poifs.crypt.EncryptionMode; +import org.junit.Test; + +public class TestBinaryRC4 { + @Test + public void createKeyDigest() throws GeneralSecurityException { + byte[] docIdData = readFromString("17 F6 D1 6B 09 B1 5F 7B 4C 9D 03 B4 81 B5 B4 4A"); + byte[] expResult = readFromString("C2 D9 56 B2 6B"); + + EncryptionInfo ei = new EncryptionInfo(EncryptionMode.binaryRC4); + BinaryRC4EncryptionVerifier ver = (BinaryRC4EncryptionVerifier)ei.getVerifier(); + ver.setSalt(docIdData); + SecretKey sk = BinaryRC4Decryptor.generateSecretKey("MoneyForNothing", ver); + + assertArrayEquals("keyDigest mismatch", expResult, sk.getEncoded()); + } + + @Test + public void testValidateWithDefaultPassword() throws GeneralSecurityException { + + String docIdSuffixA = "F 35 52 38 0D 75 4A E6 85 C2 FD 78 CE 3D D1 B6"; // valid prefix is 'D' + String saltHashA = "30 38 BE 5E 93 C5 7E B4 5F 52 CD A1 C6 8F B6 2A"; + String saltDataA = "D4 04 43 EC B7 A7 6F 6A D2 68 C7 DF CF A8 80 68"; + + String docIdB = "39 D7 80 41 DA E4 74 2C 8C 84 F9 4D 39 9A 19 2D"; + String saltDataSuffixB = "3 EA 8D 52 11 11 37 D2 BD 55 4C 01 0A 47 6E EB"; // valid prefix is 'C' + String saltHashB = "96 19 F5 D0 F1 63 08 F1 3E 09 40 1E 87 F0 4E 16"; + + confirmValid(true, "D" + docIdSuffixA, saltDataA, saltHashA); + confirmValid(true, docIdB, "C" + saltDataSuffixB, saltHashB); + confirmValid(false, "E" + docIdSuffixA, saltDataA, saltHashA); + confirmValid(false, docIdB, "B" + saltDataSuffixB, saltHashB); + } + + @Test + public void testValidateWithSuppliedPassword() throws GeneralSecurityException { + + String docId = "DF 35 52 38 0D 75 4A E6 85 C2 FD 78 CE 3D D1 B6"; + String saltData = "D4 04 43 EC B7 A7 6F 6A D2 68 C7 DF CF A8 80 68"; + String saltHashA = "8D C2 63 CC E1 1D E0 05 20 16 96 AF 48 59 94 64"; // for password '5ecret' + String saltHashB = "31 0B 0D A4 69 55 8E 27 A1 03 AD C9 AE F8 09 04"; // for password '5ecret' + + confirmValid(true, docId, saltData, saltHashA, "5ecret"); + confirmValid(false, docId, saltData, saltHashA, "Secret"); + confirmValid(true, docId, saltData, saltHashB, "Secret"); + confirmValid(false, docId, saltData, saltHashB, "secret"); + } + + + private static void confirmValid(boolean expectedResult, + String docIdHex, String saltDataHex, String saltHashHex) throws GeneralSecurityException { + confirmValid(expectedResult, docIdHex, saltDataHex, saltHashHex, null); + } + + private static void confirmValid(boolean expectedResult, String docIdHex, + String saltDataHex, String saltHashHex, String password) throws GeneralSecurityException { + byte[] docId = readFromString(docIdHex); + byte[] saltData = readFromString(saltDataHex); + byte[] saltHash = readFromString(saltHashHex); + + EncryptionInfo ei = new EncryptionInfo(EncryptionMode.binaryRC4); + BinaryRC4EncryptionVerifier ver = (BinaryRC4EncryptionVerifier)ei.getVerifier(); + ver.setSalt(docId); + ver.setEncryptedVerifier(saltData); + ver.setEncryptedVerifierHash(saltHash); + + String pass = password == null ? Decryptor.DEFAULT_PASSWORD : password; + boolean actResult = ei.getDecryptor().verifyPassword(pass); + if (expectedResult) { + assertTrue("validate failed", actResult); + } else { + assertFalse("validate succeeded unexpectedly", actResult); + } + } + +} |