I have been reading the guide to MIX files at https://moddingwiki.shikadi.net/wiki/MIX_Format_(Westwood) and have been having a go at decoding some. My problem is dealing with the RSA encrypted header using Crypt:Openssl::RSA, specifically loading the key.
The aforementioned site lists the modulus as AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V and the private exponent as AigKVje8mROcR8QixnxUEF5b29Curkq01DNDWCdOG99XBqH79OaCiTCB (both as BASE64 / DER encoded integers) and the public exponent as 0x10001. This not being the most helpful format, I figured that the best way to get it into Crypt::Openssl::RSA was via the new_key_from_parameters() method.
I converted both the modulus and private exponent to hex via an online decoder for use with Crypt::OpenSSL::Bignum->new_from_hex.
The issue appears to be that after loading the key material, check_key returns false, triggering the die with "invalid key"
#!/usr/bin/perl use strict; use warnings; use Crypt::OpenSSL::Bignum; use Crypt::OpenSSL::RSA; my $pub = '51BCDA086D39FCE4565160D651713FA2E8AA54FA6682B04AABDD0E6AF8B +0C1E6D1FB4F3DAA437F15'; my $priv = '0A5637BC99139C47C422C67C54105E5BDBD0AEAE4AB4D4334358274E1B +DF5706A1FBF4E682893081'; my $expo = '10001'; my $n = Crypt::OpenSSL::Bignum->new_from_hex($pub); my $e = Crypt::OpenSSL::Bignum->new_from_hex($expo); my $d = Crypt::OpenSSL::Bignum->new_from_hex($priv); my $rsa = Crypt::OpenSSL::RSA->new_key_from_parameters($n, $e, $d); die "invalid key" unless $rsa->check_key;
There doesn't appear to be a lot to screw up, so I can't see where I've got it wrong, unless I've done something stupid decoding the BASE64/DER data. I've been over it several times. If anyone can offer any words of wisdom, I would be extremely grateful.
Thanks,In reply to Importing keys into Crypt::Openssl::RSA by BOfH
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |