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

  • Home
  • SEARCH
  • 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 9115071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:20:38+00:00 2026-06-17T04:20:38+00:00

I need to implement RSA encryption/decryption using C# I have a private key with

  • 0

I need to implement RSA encryption/decryption using C#

I have a private key with following parameters:

mod n, exponent, p, q, dP, dQ, and (p-1mod q)

Above parameters are explained in Chinese remainder algorithm

However C#.NET implementation of the RSA has different parameter set as following:

Modulus, Exponent, P, Q, DP, DQ, D, InverseQ

When I’m trying to map the data from CRT to DOTNET, I get error Bad Data

For p,q, dP and dQ the mapping is obvious but about the rest of parameters I’m not sure.

It would be great if I can get help mapping these paramters

  • 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-17T04:20:39+00:00Added an answer on June 17, 2026 at 4:20 am

    mod n maps to Modulus, p-1mod q maps to InverseQ, the encryption exponent maps to Exponent and the decryption exponent maps to D.

    The encryption exponent e and the decryption exponent d are related by e*d = 1 mod (p-1)(q-1). Thus if you have one them you can easily derive the other use a few methods from the System.Numerics.BigInteger class.

    var Pminus1 = BigInteger.Subtract(P, BigInteger.One);
    var Qminus1 = BigInteger.Subtract(Q, BigInteger.One);
    var Phi = BigInteger.Multiply(Pminus1, Qminus1);
    var PhiMinus1 = BigInteger.Subtract(Phi, BigInteger.One);
    // var D = BigInteger.ModPow(E, PhiMinus1, Phi);
    

    Note that care must be taken when constructing a .NET BigInteger, especially if you are used to Java’s BigInteger class. See this question for more information.

    EDIT :

    As CodeInChaos points out that last line is WRONG!

    WRONG! WRONG! WRONG!

    I am embarrassed. In a bow to the forces of evil the BigInteger class does not have a modular inverse method nor an extended euclidean algorithm method. You can nevertheless google for ‘c # extended euclidean algorithm’ you can find many implementations. The extended euclidean algorithm will give you integers x and y such that 1 = e*x + phi * y. x is the inverse of e mod phi, so setting D = x mod phi is what is needed.

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

Sidebar

Related Questions

I have a private key and exponent, i need to implement RSA encryption of
I need to implement RSA algorithm in Java. I've found the best solution using
I need to implement RSA algorithm using ECB (Electronic Code Book) as a school
I'm using a private RSA key to encrypt a random AES key with the
I need to implement the following: There is a table A which is supposed
I need to implement simple file watcher utility. I have decided to implement this
I need to implemented security for client-server communication. I have implemented the following hybrid
Hi I need implement context help inside my .NET application. I have .chm file
i have big decision tree with many Yes/No questions. i need implement some code
I have a customer supplied RSA signature verification API description that takes the parameters

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.