Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended keystore and customizable KELF header data #9

Merged
merged 9 commits into from
Apr 11, 2024

Conversation

israpps
Copy link
Member

@israpps israpps commented Apr 8, 2024

Pull Request checklist

Note: these are not necessarily requirements

  • I reformatted the code with clang-format
  • I checked to make sure my submission worked
  • I am the author of submission or have permission from the original author
  • Requires update of the PS2SDK or other dependencies
  • Others (please specify below)

Pull Request description

@israpps
Copy link
Member Author

israpps commented Apr 8, 2024

HAVENT TESTED IF THIS REIMPLEMENTATION WORKS YET

@israpps israpps mentioned this pull request Apr 8, 2024
5 tasks
@israpps
Copy link
Member Author

israpps commented Apr 10, 2024

work examples:

> kelftool.exe decrypt boot.bin boot.elf --keys=arcade
header.UserDefined     = 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 (System 2x6 Dongle BootFile)
header.ContentSize     = 0X1C77C
header.HeaderSize      = 0X80
header.SystemType      = 0 (SYSTEM_TYPE_PS2)
header.ApplicationType = 7 (dvdplayer kelf)
header.Flags           = 0X22C - kelf:HDR_FLAG2|HDR_FLAG3|HDR_FLAG4_3DES|HDR_FLAG9|
header.BitCount        = 0
header.MGZones         = 0X3 |Japan|North America|
header.gap             = 00 00 00
HeaderSignature        = CA C5 4F 5D E6 0B AC 61
Kbit                   = D8 A0 2B 7E A8 0E A2 7B 18 96 83 C3 13 49 77 8E
Kc                     = A4 1D A6 98 B4 C5 65 EA A6 A6 A6 87 BA F9 11 50
BitTableSize           = 0X28
bitTable.HeaderSize    = 0X80
bitTable.BlockCount    = 2
bitTable.gap           = 00 00 00
                         Size        Signature           Flags
    bitTable.Blocks[0] = 0001C774    0000000000000000    0 (not encrypted, not signed)
    bitTable.Blocks[1] = 00000008    FFE158AB5902B4F0    2 (signed only)
BitTableSignature      = E3 A1 1A BD A2 0C 86 20
signature =  FF E1 58 AB 59 02 B4 F0
> kelftool.exe decrypt SYSTEM.XLF SYSTEM.ELF
header.UserDefined     = 01 00 00 04 00 06 00 4A 00 0E 01 00 00 00 00 02 (DNASLOAD)
header.ContentSize     = 0X14E44
header.HeaderSize      = 0X80
header.SystemType      = 0 (SYSTEM_TYPE_PS2)
header.ApplicationType = 1 (xosdmain)
header.Flags           = 0X22C - kelf:HDR_FLAG2|HDR_FLAG3|HDR_FLAG4_3DES|HDR_FLAG9|
header.BitCount        = 0
header.MGZones         = 0XFF |All regions allowed|
header.gap             = 00 00 00
HeaderSignature        = 29 A0 93 FA 2F 8D 36 E3
Kbit                   = D9 4A 2E 56 01 6E A7 31 00 00 00 00 00 00 00 00
Kc                     = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
BitTableSize           = 0X28
bitTable.HeaderSize    = 0X80
bitTable.BlockCount    = 2
bitTable.gap           = 00 00 00
                         Size        Signature           Flags
    bitTable.Blocks[0] = 00014E34    0000000000000000    0 (not encrypted, not signed)
    bitTable.Blocks[1] = 00000010    B70BC5F7CB01927F    3 (encrypted and signed)
BitTableSignature      = F4 09 35 19 92 F9 84 49
> kelftool.exe decrypt SYSTEM.XLF a.o
header.UserDefined     = 01 00 00 04 00 06 00 4A 00 0E 01 00 00 00 00 02 (DNASLOAD)
header.ContentSize     = 0X14E58
header.HeaderSize      = 0X80
header.SystemType      = 0 (SYSTEM_TYPE_PS2)
header.ApplicationType = 1 (xosdmain)
header.Flags           = 0X21C - kirx:HDR_FLAG2|HDR_FLAG3|HDR_FLAG4_1DES|HDR_FLAG9|
header.BitCount        = 0
header.MGZones         = 0XFF |All regions allowed|
header.gap             = 00 00 00
HeaderSignature        = C9 9C CD 35 C4 8F CD E9
Kbit                   = 24 25 1D 05 D1 5E 2D 7D 94 3F 4A 30 3F 28 24 DB
Kc                     = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
BitTableSize           = 0X28
bitTable.HeaderSize    = 0X80
bitTable.BlockCount    = 2
bitTable.gap           = 00 00 00
                         Size        Signature           Flags
    bitTable.Blocks[0] = 00014E48    0000000000000000    0 (not encrypted, not signed)
    bitTable.Blocks[1] = 00000010    003BEB0B63B32769    3 (encrypted and signed)
BitTableSignature      = 66 21 D6 C3 AE E5 CF E9
> kelftool.exe decrypt SYSTEM.XLF a.o
header.UserDefined     = 01 00 00 04 00 06 00 4A 00 0E 01 00 00 00 00 02 (DNASLOAD)
header.ContentSize     = 0X14E58
header.HeaderSize      = 0X80
header.SystemType      = 0 (SYSTEM_TYPE_PS2)
header.ApplicationType = 1 (xosdmain)
header.Flags           = 0X22C - kelf:HDR_FLAG2|HDR_FLAG3|HDR_FLAG4_3DES|HDR_FLAG9|
header.BitCount        = 0
header.MGZones         = 0XFF |All regions allowed|
header.gap             = 00 00 00
HeaderSignature        = 8D F2 2B 15 BA 53 98 72
Kbit                   = 24 25 1D 05 D1 5E 2D 7D 94 3F 4A 30 3F 28 24 DB
Kc                     = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
BitTableSize           = 0X28
bitTable.HeaderSize    = 0X80
bitTable.BlockCount    = 2
bitTable.gap           = 00 00 00
                         Size        Signature           Flags
    bitTable.Blocks[0] = 00014E48    0000000000000000    0 (not encrypted, not signed)
    bitTable.Blocks[1] = 00000010    003BEB0B63B32769    3 (encrypted and signed)
BitTableSignature      = 66 21 D6 C3 AE E5 CF E9

@israpps
Copy link
Member Author

israpps commented Apr 10, 2024

example of new keystore:

[default]
MG_CARDKEY_0=...
MG_CARDIV_0=...
MG_CARDKEY2_0=...
MG_CARDIV2_0=...
MG_CARDKEY_1=...
MG_CARDIV_1=...
MG_CARDKEY2_1=...
MG_CARDIV2_1=...
MG_CARDKEY_2=...
MG_CARDIV_2=...
MG_CARDKEY2_2=...
MG_CARDIV2_2=...
MG_KBIT_MASTER_KEY=...
MG_KC_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_IV=...
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_ROOTSIG_MASTER_KEY=...
MG_CONTENT_IV=...
MG_CONTENT_TABLE_IV=...
MG_CHALLENGE_IV=...

[retail]
MG_CARDKEY_0=...
MG_CARDIV_0=...
MG_CARDKEY2_0=...
MG_CARDIV2_0=...
MG_CARDKEY_1=...
MG_CARDIV_1=...
MG_CARDKEY2_1=...
MG_CARDIV2_1=...
MG_CARDKEY_2=...
MG_CARDIV_2=...
MG_CARDKEY2_2=...
MG_CARDIV2_2=...
MG_KBIT_MASTER_KEY=...
MG_KC_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_IV=...
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_ROOTSIG_MASTER_KEY=...
MG_CONTENT_IV=...
MG_CONTENT_TABLE_IV=...
MG_CHALLENGE_IV=...

[arcade]
MG_CARDKEY_0=...
MG_CARDIV_0=...
MG_CARDKEY2_0=...
MG_CARDIV2_0=...
MG_CARDKEY_1=...
MG_CARDIV_1=...
MG_CARDKEY2_1=...
MG_CARDIV2_1=...
MG_CARDKEY_2=...
MG_CARDIV_2=...
MG_CARDKEY2_2=...
MG_CARDIV2_2=...
MG_KBIT_MASTER_KEY=...
MG_KC_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_IV=...
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_ROOTSIG_MASTER_KEY=...
MG_CONTENT_IV=...
MG_CONTENT_TABLE_IV=...
MG_CHALLENGE_IV=...
OVERRIDE_KBIT=...
OVERRIDE_KC=...

[dev]
MG_CARDKEY_0=...
MG_CARDIV_0=...
MG_CARDKEY2_0=...
MG_CARDIV2_0=...
MG_CARDKEY_1=...
MG_CARDIV_1=...
MG_CARDKEY2_1=...
MG_CARDIV2_1=...
MG_CARDKEY_2=...
MG_CARDIV_2=...
MG_CARDKEY2_2=...
MG_CARDIV2_2=...
MG_KBIT_MASTER_KEY=...
MG_KC_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_IV=...
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_ROOTSIG_MASTER_KEY=...
MG_CONTENT_IV=...
MG_CONTENT_TABLE_IV=...
MG_CHALLENGE_IV=...

[prototype]
MG_CARDKEY_0=...
MG_CARDIV_0=...
MG_CARDKEY2_0=...
MG_CARDIV2_0=...
MG_CARDKEY_1=...
MG_CARDIV_1=...
MG_CARDKEY2_1=...
MG_CARDIV2_1=...
MG_CARDKEY_2=...
MG_CARDIV_2=...
MG_CARDKEY2_2=...
MG_CARDIV2_2=...
MG_KBIT_MASTER_KEY=...
MG_KC_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_IV=...
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_ROOTSIG_MASTER_KEY=...
MG_CONTENT_IV=...
MG_CONTENT_TABLE_IV=...
MG_CHALLENGE_IV=...

@israpps
Copy link
Member Author

israpps commented Apr 10, 2024

@AKuHAK pls check if you see anything out of place

@AKuHAK AKuHAK merged commit 2517da4 into ps2homebrew:master Apr 11, 2024
4 of 5 checks passed
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.

2 participants