int value larger then unsigned long
For my number theory class we need to implement a public key encryption program which I have done, however I'm runing into some problems when I try to use larger key values.
Basically this is the problem code for(i = 1; i <= b; i++) { value = value * a; while(value >= n) { value = value - n; } } My problem is in the line value = value * a; Now as soon as I do that the number overflows and I get invalid results, before I can bring bring it down into range. So my question is basically is the a variable larger then an unsigned long? Some of my class mates used java which has something called bigint, which is only limited by your ram. Is there anything like this with c, or at least a 64bit int value? |
hmm, ill bet there is a better way to do it but heres my hack
start with a character array of whatever size, then parse it character by character |
some choices:
unsigned long long datatype gives you 2^64 -1 which is very small for cryptography. Or you can use one of the extended precision libraries like gmp from gnu. Most crypto apps use one of these. mpi is another extended precision library. |
If your right and unsigned long long is 2^64 -1 thats exactly what I need. I'm trying to search the web right now to confirm.
I know that 2^64 -1 is very small, but this project is not about making a secure public key encryption. What we are learning is how number theory is used for encrypion, and why its needed to do it, and why its so hard to crack. |
All times are GMT -5. The time now is 08:01 AM. |