Update OfficeCryptCodecHandler encodingKey comments
Brought to you by:
jahlborn
As discussed at https://sourceforge.net/p/jackcessencrypt/discussion/general/thread/833fd8bfea/
This patch updates the comment in OfficeCryptCodecHandler to note that the value of the encoding key is used in encryption. This patch also updates the comment in AgileEncryptionProvider to note that this behaviour is different to what is described in the official Microsoft docs.
Index: src/main/java/com/healthmarketscience/jackcess/crypt/impl/OfficeCryptCodecHandler.java
===================================================================
--- src/main/java/com/healthmarketscience/jackcess/crypt/impl/OfficeCryptCodecHandler.java (revision 199)
+++ src/main/java/com/healthmarketscience/jackcess/crypt/impl/OfficeCryptCodecHandler.java (working copy)
@@ -65,8 +65,8 @@
ByteBuffer buffer = readHeaderPage(channel);
JetFormat format = channel.getFormat();
- // the encoding key indicates whether or not the db is encoded (but is
- // otherwise meaningless?)
+ // a non-zero encoding key indicates the db is encoded - will be passed to
+ // BaseCryptCodecHandler constructor for use in encryption
byte[] encodingKey = ByteUtil.getBytes(
buffer, format.OFFSET_ENCODING_KEY,
JetCryptCodecHandler.ENCODING_KEY_LENGTH);
Index: src/main/java/com/healthmarketscience/jackcess/crypt/impl/office/AgileEncryptionProvider.java
===================================================================
--- src/main/java/com/healthmarketscience/jackcess/crypt/impl/office/AgileEncryptionProvider.java (revision 199)
+++ src/main/java/com/healthmarketscience/jackcess/crypt/impl/office/AgileEncryptionProvider.java (working copy)
@@ -132,7 +132,9 @@
@Override
protected ParametersWithIV computeCipherParams(int pageNumber) {
- // when actually decrypting pages, we incorporate the "encoding key"
+ // OC: 2.3.4.15 says to use the zero-based segment number alone as block
+ // key, but this is incorrect for MS Access - when actually decrypting
+ // pages, we also incorporate the "encoding key"
byte[] blockBytes = getEncodingKey(pageNumber);
CTKeyData keyData = _encryptDesc.getKeyData();
thanks for the updates