-
April 28th, 2010, 09:39 AM
#1
RSA Encryption
I am not very comfortable with using C++ but am very familiar with Java. I am trying to construct an RSA encryption. The issue I am running into is when numbers get large. I am currently using uint64_t for all of my numbers, but at one point the numbers get too big and my final answer is different than what it should be.
Another issue is converting text into ascii. I want it so that if I type 'a', it would convert to 97.
Thank you very much for the help
Dennis
-
April 28th, 2010, 09:45 AM
#2
Re: RSA Encryption
You'll have to get yourself a BigInt library of some kind. They're less efficient than built-in types, but have a larger dynamic range. There are several available, Google it.
As far as converting to ASCII----simply recognize that char is an integer type. If you read in the character 'a' to a char (or as part of a string made up of chars), then that char will have the value 97, and you can see this if you cast it to int on output.
This only gets slightly tricky when dealing with digits, since then the type you're reading it to determines the value you get. If you enter "5", for instance, then if you were doing cin >> intval you'd get inval with the value 5; but if you did cin >> charval, you'd get charval with the value 53 ('5').
-
April 28th, 2010, 10:01 AM
#3
Re: RSA Encryption
There're probably dozens of C++ RSA implementations already "turn-key" and MS VC++ has the CryptoAPI which supports RSA, so, unless this is purely academic, why re-invent the wheel?
-
April 28th, 2010, 11:46 AM
#4
Re: RSA Encryption
This is for a class project so yeah, I'm stuck doing it.
I am having issues with the bigint class. I'm not 100% how to set it up and then how to declare a variable as a BigInt.
Thanks,
Dennis
-
April 28th, 2010, 12:21 PM
#5
Re: RSA Encryption
Originally Posted by gberg927
This is for a class project so yeah, I'm stuck doing it.
I am having issues with the bigint class. I'm not 100% how to set it up and then how to declare a variable as a BigInt.
Thanks,
Dennis
Just because it is for class doesn't mean you have to reinvent each and every line of code. I'm sure your teacher would rather have you concentrate on the RSA part than the BigInt part.
2 things though:
1 - Are the numbers you are manipulating so big as to need BigInts? With RSA, the answer is usually yes, but since this is also a class project, you can get away with using little keys. See with your professor if he expects you to actually use bigints, and if the answer is yes, do you have to code it yourself.
2 - Also, by reordering operations in a smart way, you can get the same result, but use smaller bounds in your intermediate operations. A typical example is when calculating a combination.
-
April 28th, 2010, 12:29 PM
#6
Re: RSA Encryption
Yeah, I have already asked my teacher if we can do a "mini RSA" project. She said that she would consider our project weaker even though some kids in my class projects are jokes. She said it is fine to use BigInt classes and that it is mot likely needed. My issue comes because I have no idea how the BigInt class works. The one I acquired gave me bigint.h, bigint.cpp and main.cpp. I'm not sure what to do with these files and how to use them in my function.
I appreciate any help because I cannot seem to find information anywhere,
Thanks,
Dennis
-
April 28th, 2010, 12:39 PM
#7
Re: RSA Encryption
Originally Posted by gberg927
My issue comes because I have no idea how the BigInt class works. The one I acquired gave me bigint.h, bigint.cpp and main.cpp. I'm not sure what to do with these files and how to use them in my function.
You might want to look into using the GMP; the documentation is not bad, and a not-so-naive C++ wrapper is provided.
-
April 28th, 2010, 12:44 PM
#8
Re: RSA Encryption
Ask your professor, I'm sure that he/she wouldn't assign a beginner C++ course something that requires ints larger than 64 bit.
Is this the bigint library that you're using? http://mattmccutchen.net/bigint/
That's the one that I always used, its much easier to use than GMP, but also much slower.
-
April 28th, 2010, 06:27 PM
#9
Re: RSA Encryption
Unfortunatly this isn't a C++ course. It is a network security class so my knowledge of C++ does not matter. My group members believed programming in C++ would be a good idea. I have gotten that Big Integer Library but am not sure how to actually utilize it. I am using Eclipse IDE and MINIGW compiler. How can I use this library with these two?
Thanks again,
Dennis
-
April 28th, 2010, 08:47 PM
#10
Re: RSA Encryption
There are usually two steps to using a library:
1) #include the relevant header files from it
2) Link against the relevant lib files from it, building the library first if necessary (it will come with a Makefile or VS project if that's the case)
For some "header-only" libraries, you don't need to do #2.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|