Skip to content

dmg: support AES-encrypted v2 key blobs - #6029

Open
kholia wants to merge 1 commit into
openwall:bleeding-jumbofrom
kholia:better-dmg-support
Open

dmg: support AES-encrypted v2 key blobs#6029
kholia wants to merge 1 commit into
openwall:bleeding-jumbofrom
kholia:better-dmg-support

Conversation

@kholia

@kholia kholia commented Aug 13, 2026

Copy link
Copy Markdown
Member

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

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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$3 parsing 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$3 test 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 thread src/dmg_common_plug.c
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 thread src/dmg_fmt_plug.c
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 thread run/opencl/dmg_kernel.cl
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dmg2john extracts uncrackable hashes from current DMG files

3 participants