mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Update TestRecordFactoryInputStream.java
This commit is contained in:
parent
811eb4a4a8
commit
c7976440c3
@ -133,6 +133,22 @@ final class TestRecordFactoryInputStream {
|
|||||||
+ SAMPLE_WINDOW1_ENCR2
|
+ SAMPLE_WINDOW1_ENCR2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
RecordFactoryInputStream rfis = createRFIS(dataCorrectDefault, "passw0rd");
|
||||||
|
confirmReadInitialRecords(rfis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suppliedPasswordOKBiff8EncryptionKey() {
|
||||||
|
// This encoding depends on docId, password and stream position
|
||||||
|
final String SAMPLE_WINDOW1_ENCR2 = "3D 00 12 00"
|
||||||
|
+ "45, B9, 90, FE, B6, C6, EC, 73, EE, 3F, 52, 45, 97, DB, E3, C1, D6, FE";
|
||||||
|
|
||||||
|
byte[] dataCorrectDefault = HexRead.readFromString(""
|
||||||
|
+ COMMON_HEX_DATA
|
||||||
|
+ "C728659A C38E35E0 568A338F C3FC9D70" // correct saltHash for supplied password (and docId/saltHash)
|
||||||
|
+ SAMPLE_WINDOW1_ENCR2
|
||||||
|
);
|
||||||
|
|
||||||
Biff8EncryptionKey.setCurrentUserPassword("passw0rd");
|
Biff8EncryptionKey.setCurrentUserPassword("passw0rd");
|
||||||
try {
|
try {
|
||||||
RecordFactoryInputStream rfis = createRFIS(dataCorrectDefault);
|
RecordFactoryInputStream rfis = createRFIS(dataCorrectDefault);
|
||||||
@ -142,7 +158,6 @@ final class TestRecordFactoryInputStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* makes sure the record stream starts with {@link BOFRecord}, {@link FilePassRecord} and then {@link WindowOneRecord}
|
* makes sure the record stream starts with {@link BOFRecord}, {@link FilePassRecord} and then {@link WindowOneRecord}
|
||||||
* The third record is decrypted so this method also checks its content.
|
* The third record is decrypted so this method also checks its content.
|
||||||
@ -157,4 +172,11 @@ final class TestRecordFactoryInputStream {
|
|||||||
private static RecordFactoryInputStream createRFIS(byte[] data) {
|
private static RecordFactoryInputStream createRFIS(byte[] data) {
|
||||||
return new RecordFactoryInputStream(new ByteArrayInputStream(data), true);
|
return new RecordFactoryInputStream(new ByteArrayInputStream(data), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RecordFactoryInputStream createRFIS(byte[] data, String password) {
|
||||||
|
return new RecordFactoryInputStream(
|
||||||
|
new ByteArrayInputStream(data),
|
||||||
|
true,
|
||||||
|
password.toCharArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user