dmg: support AES-encrypted v2 key blobs - #6029
Open
kholia wants to merge 1 commit into
Open
Conversation
Recent macOS releases can wrap v2 DMG key blobs with AES-192-CBC (CSSM_ALGID_AES) instead of 3DES. Teach both extractors to recognize this parameter set and emit a compact $dmg$3 hash, while rejecting unknown blob encryption combinations. Add CPU and OpenCL verification by decrypting the final key-blob block and checking the CKIE marker and PKCS#7 padding. Include a known-password test vector and retain existing v1/v2 behavior.
There was a problem hiding this comment.
Pull request overview
Adds support for modern macOS DMG v2 key blobs that are wrapped with AES-192-CBC (CSSM_ALGID_AES) by introducing a new compact $dmg$3 hash representation, updating both C and Python extractors to emit it (and reject unsupported parameter sets), and extending both CPU and OpenCL crackers with a verification step that decrypts the final key-blob block and checks for the CKIE marker plus PKCS#7 padding.
Changes:
- Add
$dmg$3parsing and verification to both CPU (dmg_fmt) and OpenCL (opencl_dmg) formats. - Update
dmg2john(C and Python) to detect AES-wrapped v2 key blobs, emit$dmg$3, and reject unknown blob-encryption combinations. - Add a known-password
$dmg$3test vector to prevent regressions.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/opencl_dmg_fmt_plug.c | Extends OpenCL DMG format to accept headerver=3 and run a new dmg_final_v3 kernel; expands stored encrypted keyblob and carries key-bits. |
| src/dmg2john.c | Detects AES-192-CBC-wrapped v2 blobs, emits $dmg$3, and errors out for unsupported blob-encryption parameter sets. |
| src/dmg_fmt_plug.c | Adds $dmg$3 parsing and CPU-side verification by decrypting the last keyblob block and checking CKIE + PKCS#7 padding. |
| src/dmg_common_plug.c | Adds a $dmg$3 test vector using the known password d3fc0n. |
| run/opencl/dmg_kernel.cl | Adds OpenCL check_v3hash() and a new dmg_final_v3 kernel implementing the same last-block verification logic. |
| run/dmg2john.py | Updates v2 header unpacking, detects AES-wrapped blobs, emits $dmg$3, and rejects unsupported blob-encryption parameter sets. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+11
to
+12
| // Version 2 header using an AES-192-CBC encrypted key blob | ||
| {"$dmg$3*20*dda90b3cadb0cfa4e6b17b935c7f415ecb3d4947*192*64*89669cb0994d0bba4d7bdd5fb8551ae0d641a9427cb6903b9546f38c0053c2456799d990a76007f6a7aa3c59fae69889d79df480230d21faaf7a65ab26e45151*400000", "d3fc0n"}, |
Comment on lines
+495
to
+497
| if (!memcmp(&last_block[4], "CKIE", 4) && !last_block[8] && | ||
| check_pkcs_pad(last_block, 16, 16) == 9) | ||
| cracked[index+j] = 1; |
Comment on lines
+153
to
+155
| return last_block[4] == 'C' && last_block[5] == 'K' && | ||
| last_block[6] == 'I' && last_block[7] == 'E' && | ||
| !last_block[8] && check_pkcs_pad(last_block, 16, 16) == 9; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recent macOS releases can wrap v2 DMG key blobs with AES-192-CBC (CSSM_ALGID_AES) instead of 3DES. Teach both extractors to recognize this parameter set and emit a compact $dmg$3 hash, while rejecting unknown blob encryption combinations.
Add CPU and OpenCL verification by decrypting the final key-blob block and checking the CKIE marker and PKCS#7 padding. Include a known-password test vector and retain existing v1/v2 behavior.
Fixes #6028