Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:54:40+00:00 2026-06-03T00:54:40+00:00

I’m using someone else’s code to generate an RSA signature used for verification in

  • 0

I’m using someone else’s code to generate an RSA signature used for verification in xbox 360 save files. The code reads the needed values from a files and correctly generates the signature.

The code is:

    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’m trying to end up with what’s in xrsa, but using Python. I installed pycrypto, and I’m looking at the documentation, but I’m still missing something obvious. First, the RSA.construct from Crypto.PublicKey only takes six parameters, but not the exponents one and two (DP and DQ). Also, the inputs need to be longs. In the C# code, the values were 128 and 64 bytes long, as opposed to a 4 byte long.

I know this may seem painfully obvious, but I have no idea what I need to do.

I’m working with Python 2.7.3

edit: also, the “message” to be encrypted is a sha1 hash of 0x118 bytes of the file, which contains meta data and a hash of other parts of the file.

edit: Thank you so much mata, I feel I’m closer to getting it working. It still doesn’t match the C# signature. In C#, the signature format is being set as SHA1. What is this doing, and can it be done in Python?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:54:42+00:00Added an answer on June 3, 2026 at 12:54 am

    ok, first: long in python is not 4 byte. in python, long has no predefined size, so using a long to store a 128byte number is no problem.
    to convert a bytestring to long you can use:

    long_value = long(string_value.decode('hex'), 16)
    # maybe someone knows a better way?
    

    couldn’t it be that the file is in DER form? in that case you simply could simple read the file using:

    from Crypto.PublicKey import RSA
    with open("keyfile", "rb") as f:
        key = RSA.importKey(f.read())
    

    if not, it would probably be best to convert it to PEM or DER, so you don’t have to read in the parameters yourself.
    anyway, the last three parameters in RSA.construct are optional, specially u can be calculated as 1/p % q (where p > q).
    at least from what i’ve tried, it works even if you only specify the first three parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.