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 parameters #8

Closed
wants to merge 15 commits into from

Conversation

israpps
Copy link
Member

@israpps israpps commented Apr 3, 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)

Features:

  • make the keystore file an ini file, allowing for sections, also, comments now will be supported (instead of triggering error)
  • flags can now be passed to encrypt command, these are:
    • --keys=KEY: searches for the mg keys on the section provided, defaults to default
    • --systemtype=TYPE: manually sets the system type, supported values are PS2, PSX or a hex number .
    • --kflags=FLAGS: Custom KELF flags, supported values are KELF, KIRX or a hex number.
    • --mgzone=VALUE: custom MagicGate region zones, expects a hex number.
    • --apptype=VALUE: custom KELF application type, expects a hex number.

new keystore format

[default]
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_KBIT_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_MASTER_KEY=...
MG_KC_IV=...
MG_ROOTSIG_MASTER_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_CONTENT_TABLE_IV=...
MG_CONTENT_IV=...
[arcade]
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_KBIT_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_MASTER_KEY=...
MG_KC_IV=...
MG_ROOTSIG_MASTER_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_CONTENT_TABLE_IV=...
MG_CONTENT_IV=...
[dev]
MG_SIG_MASTER_KEY=...
MG_SIG_HASH_KEY=...
MG_KBIT_MASTER_KEY=...
MG_KBIT_IV=...
MG_KC_MASTER_KEY=...
MG_KC_IV=...
MG_ROOTSIG_MASTER_KEY=...
MG_ROOTSIG_HASH_KEY=...
MG_CONTENT_TABLE_IV=...
MG_CONTENT_IV=...

In addition, ARCADE_KBIT & ARCADE_KC have been renamed to OVERRIDE_KBIT & OVERRIDE_KC for readability
And when these values are found and valid, program will explicitly inform they're being used by the following message:

-- kbit and Kc overridden by keystore!

keystore search:

Now the keystore file from CWD will have priority over the one on $HOME.

Decrypt command.

The decrypt command will also be capable of using the --keys flag. and it will now Identify namco arcade dongle boot.bin user header (not sure if we want to support it on the encrypt cmd??)

@israpps israpps force-pushed the ext-keys-and-params branch from 6275cbb to 67171df Compare April 3, 2024 19:23
@israpps
Copy link
Member Author

israpps commented Apr 3, 2024

The new ini parsing lib I added seems to be capable of dealing with keystores on the old format as long as we don't pass a custom keyset to look for

New look for decrypt command
IMG-20240403-WA0006

@israpps
Copy link
Member Author

israpps commented Apr 3, 2024

@AKuHAK btw, since balika is not quite active, what do you think about enabling discussions tab on this repo, creating a new one, and use that link to replace the report link of the program

Copy link
Member

@AKuHAK AKuHAK left a comment

Choose a reason for hiding this comment

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

As always commit history is dirty. It is ok when you change one thing, but here you changed a lot more:

  • added shell formatting
  • added new functionality
  • added new library
  • added cmake
  • fixed some bugs

It can be in one pr, but then it requires clean commits, one commit per change. If it is not an option, then, please split this pr in pr series, so I can squash each one. Also, shell formatting is very questionable change, will require some testing.

@@ -0,0 +1,8 @@
#define REDBOLD "\033[1;31m"
Copy link
Member

Choose a reason for hiding this comment

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

Does this work in CMD? I think only powrshell supports that nice formatting. Actually, I was forced to remove it from hfl-dump due to many reports about this characters in cmd. Can you remove formatting for now, and add it later as separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Does this work in CMD? I think only powrshell supports that nice formatting. Actually, I was forced to remove it from hfl-dump due to many reports about this characters in cmd. Can you remove formatting for now, and add it later as separate PR?

or disable on windows. althoug, WSL and windows terminal do support it

src/kelftool.cpp
src/keystore.cpp
)
target_link_libraries(kelftool OpenSSL::SSL)
Copy link
Member

Choose a reason for hiding this comment

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

So then adding this in GitHub action?

Copy link
Member Author

Choose a reason for hiding this comment

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

or delete it. decide what you see fit

@@ -97,142 +98,149 @@ int Kelf::LoadKelf(const std::string &filename)

if (header.Flags & 1 || header.Flags & 0xf0000 || header.BitCount != 0) {
// TODO: check more unknown bit flags
printf("This file is not supported yet and looked after.\n");
printf(REDBOLD "This file is not supported yet and looked after.\n");
Copy link
Member

Choose a reason for hiding this comment

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

Its now super hard to check where you applied formatting, and where you actually changed the code.

Copy link
Member

@AKuHAK AKuHAK left a comment

Choose a reason for hiding this comment

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

.

@israpps
Copy link
Member Author

israpps commented Apr 4, 2024

As always commit history is dirty. It is ok when you change one thing, but here you changed a lot more:

  • added shell formatting
  • added new functionality
  • added new library
  • added cmake
  • fixed some bugs

It can be in one pr, but then it requires clean commits, one commit per change. If it is not an option, then, please split this pr in pr series, so I can squash each one. Also, shell formatting is very questionable change, will require some testing.

I forgot the cmake there

It was for quicker compiling.

I can remove it. Or leave it, since it's not hooked to CI in any form

@israpps
Copy link
Member Author

israpps commented Apr 4, 2024

i'll squash the commits then

@israpps israpps closed this Apr 4, 2024
@israpps israpps reopened this Apr 4, 2024
@israpps
Copy link
Member Author

israpps commented Apr 8, 2024

closed in favor of #9

@israpps israpps closed this Apr 8, 2024
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