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 1113003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:47:31+00:00 2026-05-17T02:47:31+00:00

I am trying to decrypt data that has been encrypted previously in RSA (don’t

  • 0

I am trying to decrypt data that has been encrypted previously in RSA (don’t worry, I’m supposed to be able to, I have the keys. Nothing illegal :).

However, I get a “Bad Key.” error at the decryption line. I am sure this key is right, as I took it from vectors. The vectors are provided in the following code. Theoretically, I have all the information to decrypt, although it won’t work. I’m thinking it might be a .NET way of decrypting that I didn’t understand yet.

Here is the code:

    static void Main(string[] args)
    {
        byte[] N = // Modulus
        {
            0x00, 0x8C, 0x35, 0x04, 0xC8, 0x40, 0xB3, 0x67, 0xD8, 0x42, 0x35, 0x78, 0xF6, 0x2A, 0x02, 0xBE,
            0xF7, 0x1C, 0xCD, 0x9D, 0x98, 0x55, 0x16, 0x3F, 0x81, 0xA4, 0xE5, 0x3E, 0x3D, 0x38, 0x27, 0xEE,
            0x0D, 0x8B, 0xAF, 0xB0, 0xBB, 0xBA, 0xA4, 0xE1, 0xF2, 0xB6, 0x79, 0x92, 0x5B, 0x72, 0xBA, 0xC8,
            0xD7, 0x63, 0xA9, 0x60, 0x17, 0xB1, 0x34, 0xF1, 0xA9, 0xE3, 0x46, 0x67, 0xB8, 0x06, 0x9A, 0xCD,
            0x59, 0x95, 0x10, 0x32, 0x74, 0x15, 0x73, 0xB1, 0x09, 0x43, 0x56, 0xA3, 0x0B, 0xE5, 0x6D, 0x2F,
            0x29, 0xF2, 0xB6, 0x6F, 0x5D, 0xA9, 0x55, 0x19, 0x6A, 0x2E, 0xB0, 0x30, 0x6A, 0x3F, 0xAB, 0x9F,
            0x4F, 0xCE, 0x12, 0x66, 0x28, 0xDE, 0xEB, 0x4C, 0x07, 0x9E, 0x5F, 0x24, 0x47, 0x50, 0x39, 0xB8,
            0x8F, 0x0F, 0xB8, 0x8C, 0x62, 0x8C, 0xC7, 0xA8, 0x30, 0x8C, 0xB3, 0x27, 0xA3, 0x13, 0xBC, 0xB0,
            0xA5
        };

        byte[] E = // Public exponent
        {
            0x01, 0x00, 0x01
        };          

        byte[] D = // Private key
        {
            0x0D, 0x55, 0xA9, 0x8B, 0xC6, 0x23, 0x89, 0xF7, 0xD6, 0x6C, 0x31, 0x81, 0xF0, 0x02, 0xEC, 0xD8,
            0xA1, 0xC3, 0xA8, 0x7E, 0x69, 0x71, 0x41, 0x3E, 0xFA, 0x48, 0xD7, 0x3F, 0x89, 0x4C, 0xBA, 0xE6,
            0x4C, 0xE7, 0xBB, 0xBE, 0x4F, 0x05, 0x09, 0x7C, 0x45, 0x00, 0x90, 0xFB, 0xE3, 0x90, 0x82, 0x33,
            0x82, 0x06, 0x04, 0xDE, 0x9B, 0xFA, 0xF6, 0x14, 0xFB, 0x49, 0xA1, 0xE9, 0xAD, 0xAF, 0x21, 0x62,
            0x84, 0x45, 0x3F, 0xB4, 0x6C, 0x8A, 0xFF, 0xE1, 0x8C, 0x5B, 0xC9, 0xBA, 0xD5, 0xB3, 0x48, 0x57,
            0x5A, 0xA8, 0x3F, 0x11, 0x28, 0xD3, 0xB3, 0x2F, 0xAF, 0x32, 0x29, 0xC3, 0xA4, 0x20, 0xC4, 0x03,
            0x89, 0xD4, 0x42, 0x0D, 0xAB, 0x5F, 0x06, 0x7F, 0x57, 0xBE, 0xD1, 0x90, 0x0E, 0x5E, 0x47, 0xE8,
            0xC8, 0xFF, 0xF3, 0x0F, 0xC2, 0xD1, 0x58, 0x9A, 0xEC, 0x66, 0x0B, 0x46, 0x9B, 0x79, 0x33, 0xC1
        };

        byte[] C = // Ciphertext - to be decrypted
        {
            0x70, 0x72, 0xD9, 0xAD, 0x1C, 0x7D, 0x0D, 0xDF, 0x3F, 0xC7, 0xE7, 0xF5, 0x82, 0x2D, 0x64, 0x7A,
            0xC8, 0x60, 0xC9, 0x93, 0x24, 0x14, 0x1A, 0xC3, 0xA4, 0x98, 0xB4, 0x63, 0x29, 0x5C, 0xEA, 0x41,
            0x0A, 0xC4, 0x28, 0x0D, 0xED, 0x8C, 0x53, 0x20, 0xFC, 0x6B, 0x3A, 0x13, 0xBD, 0x0C, 0x2E, 0xB6,
            0xA0, 0x19, 0xD4, 0xB5, 0xF3, 0x66, 0x1B, 0x70, 0x81, 0x3E, 0xB1, 0x68, 0x0A, 0x54, 0x23, 0x8E,
            0x65, 0xD8, 0x8E, 0xE6, 0x70, 0x56, 0xB4, 0x3A, 0x0D, 0xD6, 0xC7, 0x12, 0x3F, 0x18, 0xCD, 0x3F,
            0xE3, 0x63, 0x32, 0x6E, 0x4D, 0x7E, 0x2F, 0x4E, 0x5C, 0x6B, 0x77, 0x03, 0x37, 0x32, 0xD2, 0xF7,
            0x27, 0x2D, 0x4B, 0xD8, 0x89, 0x89, 0x23, 0xA3, 0x9A, 0xD0, 0x95, 0x38, 0xD5, 0x00, 0x4B, 0x86,
            0x46, 0x0C, 0x54, 0x4E, 0x1F, 0xAA, 0x34, 0x0D, 0x00, 0x1B, 0x38, 0x56, 0x83, 0x4F, 0x07, 0x68
        };

        byte[] M = // Cleartext - reference
        {
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        };

        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
        RSAParameters param = new RSAParameters();
        param.Exponent = E;
        param.D = D;
        param.Modulus = N; // I don't know why the modulus (public key) is needed here. we're decrypting!
        // But I get an error at importparameters if it's not there.
        rsa.ImportParameters(param);

        byte[] R = rsa.Decrypt(C, false); // Result. This decryption errors out with "Bad Key."

        Console.WriteLine(R == M); // Should be true.

        Console.Read();
    }

Any insight is greatly appreciated. I have been trying to debug this for weeks. Literally.

  • 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-05-17T02:47:32+00:00Added an answer on May 17, 2026 at 2:47 am

    I had the same problem with the “Bad Key” exception, turned out that the problem was how I was generating my certificate.

    I was using the switch:

    -sky signature
    

    and when I changed it to:

    -sky exchange
    

    it worked fine.

    Here is the full command I used for makecert:

    makecert -r -pe -n "CN=MyName" -ss my -sr CurrentUser -sky exchange
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.