I am using another user's code to create the RSA signature used for verification in xbox 360 storage files. The code reads the necessary values from the files and generates the signature correctly.
The code:
byte[] xHash=null;
RSAParameters xParams = new RSAParameters();
br.BaseStream.Position = 0x1A8;
xParams.D = br.ReadBytes(0x80);
xParams.Exponent = br.ReadBytes(0x4);
xParams.Modulus = br.ReadBytes(0x80);
xParams.P = br.ReadBytes(0x40);
xParams.Q = br.ReadBytes(0x40);
xParams.DP = br.ReadBytes(0x40);
xParams.DQ = br.ReadBytes(0x40);
xParams.InverseQ = br.ReadBytes(0x40);
br.close();
br=new BinaryReader(File.OpenRead(f));
br.BaseStream.Position=0x22c;
xHash = new SHA1CryptoServiceProvider().ComputeHash(br.ReadBytes(0x118));
byte[] xrsa=SignatureGenerate(xParams, xHash);
public static byte[] SignatureGenerate(RSAParameters xParam, byte[] xHash)
{
RSACryptoServiceProvider xRSACrypto = new RSACryptoServiceProvider();
RSAPKCS1SignatureFormatter xRSASigFormat = new RSAPKCS1SignatureFormatter();
xRSACrypto.ImportParameters(xParam);
xRSASigFormat.SetHashAlgorithm("SHA1");
xRSASigFormat.SetKey(xRSACrypto);
return xRSASigFormat.CreateSignature(xHash);
}
I am trying to end up with what's in xrsa, but using Python. I installed pycrypto and I am looking at the documentation, but I still don't see anything obvious. Firstly, RSA.construct from Crypto.PublicKey accepts only six parameters, but not indicators 1 and 2 (DP and DQ). In addition, the entries must be long. In C # code, the values were 128 and 64 bytes in length, not 4 bytes.
I know this may seem painfully obvious, but I have no idea what I need to do.
I am working with Python 2.7.3
edit: "", , sha1 0x118 , .
edit: , , , . - #. # SHA1. , Python?