Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

RSA: Do I need to use a big int package for this?

  • 27-04-2008 3:41am
    #1
    Closed Accounts Posts: 12,382 ✭✭✭✭


    Hello

    I am teaching myself encryption using C.

    At the moment I'm implementing RSA. I'm only using prime numbers smaller than 1000.

    When it comes to encrypting, and especially decrypting, I'm getting some pretty massive numbers.

    For example:

    If I encrypt the number 6 using the key pair (79, 1121):

    (6 ^ 79) mod 1121 = 693

    I then decrypt using the key pair (859, 1121):

    (693 ^ 859) mod 1121... Error. My compiler doesn't like 693 ^ 859. The number is too big.

    Is there a smart way around this, or do I need to install a big int package?

    Note I am already using long doubles.

    Any help greatly appreciated.

    Thank you.


Comments

  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    for a number that size, you'd need big int library, unless you want to write your own.
    miracl is good.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    dublindude wrote: »
    Note I am already using long doubles.

    Surely it would have to be an integer (big int or what ever) rather than a floating point value for it to work correctly?

    I can't see how it would work with the loss in precision introduced by using floating point values.


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    Thanks for your replies.

    I've found the answer, Modular Exponentiation

    DublinDilbert: I was just using long doubles because they're huge.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    dublindude wrote: »

    DublinDilbert: I was just using long doubles because they're huge.


    Ahh ok... if your just interested in the theory of operation, and not a practical implementation, just reduce the number of bits used and use unsigned long's


  • Registered Users, Registered Users 2 Posts: 17,706 ✭✭✭✭Mr. CooL ICE


    Probably not much use to you, but when I did encryption in Java, I converted every number to a binary reprentation as a boolean array. This let me scale the algorithm I was coding to practically any size I wanted (as long as the algorithm rules allowed the key size).

    There are a few downsides though - the class package I made to perform the needed arithmetic operations on the boolean arrays took a long time to code properly. Also, I'm no expert on coding performance, but I reckon my method was highly inefficient


  • Advertisement
Advertisement