Importing Binary Private Key To RSA_KEY #71

Closed
opened 2015-07-23 16:58:26 -05:00 by ghost · 3 comments
ghost commented 2015-07-23 16:58:26 -05:00 (Migrated from github.com)

I currently have all the parameters to an RSA key, but find it impossible to import them to the rsa_key parameter. For instance, in C# I simply do this:

        RSACryptoServiceProvider Key = new RSACryptoServiceProvider();
        RSAParameters parameters = new RSAParameters();
        reader.Seek(0x28C);
        parameters.Exponent = reader.ReadBytes(0x4);
        reader.Seek(0x8, SeekOrigin.Current);
        parameters.Modulus = Conversions.FlipBytesBy8(reader.ReadBytes(0x80));
        parameters.P = Conversions.FlipBytesBy8(reader.ReadBytes(0x40));
        parameters.Q = Conversions.FlipBytesBy8(reader.ReadBytes(0x40));
        parameters.DP = Conversions.FlipBytesBy8(reader.ReadBytes(0x40));
        parameters.DQ = Conversions.FlipBytesBy8(reader.ReadBytes(0x40));
        parameters.InverseQ = Conversions.FlipBytesBy8(reader.ReadBytes(0x40));
        parameters.D = new byte[0x80];
        Key.ImportParameters(parameters);

But in C, it's not possible to just set the void* parameters, since I'm assuming they use some sort of big integer type that I cannot find. I would like to some how change the data to whatever type of format rsa_import uses.

I currently have all the parameters to an RSA key, but find it impossible to import them to the rsa_key parameter. For instance, in C# I simply do this: ``` RSACryptoServiceProvider Key = new RSACryptoServiceProvider(); RSAParameters parameters = new RSAParameters(); reader.Seek(0x28C); parameters.Exponent = reader.ReadBytes(0x4); reader.Seek(0x8, SeekOrigin.Current); parameters.Modulus = Conversions.FlipBytesBy8(reader.ReadBytes(0x80)); parameters.P = Conversions.FlipBytesBy8(reader.ReadBytes(0x40)); parameters.Q = Conversions.FlipBytesBy8(reader.ReadBytes(0x40)); parameters.DP = Conversions.FlipBytesBy8(reader.ReadBytes(0x40)); parameters.DQ = Conversions.FlipBytesBy8(reader.ReadBytes(0x40)); parameters.InverseQ = Conversions.FlipBytesBy8(reader.ReadBytes(0x40)); parameters.D = new byte[0x80]; Key.ImportParameters(parameters); ``` But in C, it's not possible to just set the void\* parameters, since I'm assuming they use some sort of big integer type that I cannot find. I would like to some how change the data to whatever type of format rsa_import uses.
sjaeckel commented 2015-07-25 14:05:29 -05:00 (Migrated from github.com)

Well if you implemented your own math provider you can set the void* parameters to whatever your provider likes.

Well if you implemented your own math provider you can set the void\* parameters to whatever your provider likes.
ghost commented 2015-07-27 19:37:00 -05:00 (Migrated from github.com)

I'm using LibTomMath. I'm not sure how I'd set up their big integers to use from mere bytes (unsigned char *).

I'm using LibTomMath. I'm not sure how I'd set up their big integers to use from mere bytes (unsigned char *).
sjaeckel commented 2015-07-28 04:09:28 -05:00 (Migrated from github.com)

Hint: I'd have a look at mp_read_unsigned_bin()

Hint: I'd have a look at `mp_read_unsigned_bin()`
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libtom/libtomcrypt#71
No description provided.