Testing against actual XeCrypt code
Need to test the functions against the actual XeCrypt ones, and make sure that all outputs & state variables are the same between them both.
The only way I can see to do this ATM is to create an XEX and run it on an actual 360, though I do wonder if maybe GFWL includes XeCrypt funcs, and if we could run them externally... (testing against actual 360 results is probably better than anything on x86/x64 though, since the outputs/states from 360 tests would definitely be in the correct endian order, etc)
The XEX concept would probably work fine assuming the tests don't change much, since you could just run it once then keep a copy saved of expected values.
A few other ideas if you're looking for some way to automate it / quickly iterate on tests in CI/CD or whatnot:
- The Unicorn emulator engine might be able to be used for this, however right now it seems it has a bug with executing PPC64-specific instructions
- Modifying Xenia to be headless and load XeCrypt functions from a real xboxkrnl.exe image
- Using a real ppc64 machine or qemu-ppc64 running Linux to run xboxkrnl.exe code, doing whatever ABI fixups necessary
I could try putting something together for the latter option if that's something you'd be willing to try out, although that'd still be wise to test against a 360 to make sure nothing is being mangled.
(Sadly GfWL doesn't seem to include any identical implementation to XeCrypt. Would've been easier...)
qemu is a nice idea, would think it could probably run most xecrypt funcs fine - I think we could probably get away with just generating test data once and then keep that data in repo (plus the source used to generate it), CI tests could then check against that.
Maybe easiest to just build XEX to generate that data though, but unfortunately I don't have any actual boxes setup on my end to try building/running it.
If you're able to get any test data I'm happy to add it to repo / build tests against it (also guess xenia could probably use the test data too since they use their own XeCrypt impl)