Menu

#9 Update OfficeCryptCodecHandler encodingKey comments

Unassigned
closed
nobody
None
1
2025-11-20
2025-11-19
Yingtong Li
No

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();
2 Attachments

Discussion

  • James Ahlborn

    James Ahlborn - 2025-11-20
    • status: open --> closed
     
  • James Ahlborn

    James Ahlborn - 2025-11-20

    thanks for the updates

     

Log in to post a comment.