On Dec 5, 2007 5:22 PM, Robert Roessler <[EMAIL PROTECTED]> wrote: > > eric.frederich wrote: > > I'm trying to get an example working. > > I copied the GenerateRSAKey function from test.cpp and put it in my > > own file with a main. > > It keeps generating the same exact public key. > > I tried changing the const char *seed and even changed the RandomPool > > to an AutoSeededRandomPool but still no luck. > > > > Any help is appreciated. > > Without checking the code (or docs), I can mention that it is common to > use one of a few widely known default values for the PUBLIC key (e.g., > 3, 17 [I think], or 65537). > > Besides being able to refer to these as "default public key #2" (or some > such), they also share the property of allowing a relatively quick > attempted [in]validation. >
That's not accurate. Those are common values for the public exponent. The other component of the public key is the modulus. That's always distinct for a new keypair. For a nice clear explanation, look at Section 8.2.1 of the Handbook of Applied Cryptography, available for download here: http://www.cacr.math.uwaterloo.ca/hac/ To address the original question, when I run the code from the post multiple times, I do get a different keypair each time. Is it possible you're not looking carefully at the output? The only change I made was to eliminate the constant "entropy". One way to make it more obvious to yourself that things are working might be to eliminate the HexEncoder when you write your public key and feed the resulting file to dumpasn1. (Like I did here: http://cryptopp.pastebin.com/f1d682fcf ) Here's output from my first run: chimera:tmp gbeier$ ./rsatest Generating 1024-bit RSA keypair... Public key: 0 42: SEQUENCE { 2 13: SEQUENCE { 4 9: OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1) 15 0: NULL : } 17 25: BIT STRING, encapsulates { 20 22: SEQUENCE { 22 17: INTEGER : 00 90 CA C1 DD 4E 4C 5C F4 CC 69 FF E0 A6 95 48 : 2B 41 1: INTEGER 17 : } : } : } 0 warnings, 0 errors. Here's my second run: chimera:tmp gbeier$ ./rsatest Generating 1024-bit RSA keypair... Public key: 0 42: SEQUENCE { 2 13: SEQUENCE { 4 9: OBJECT IDENTIFIER rsaEncryption (1 2 840 113549 1 1 1) 15 0: NULL : } 17 25: BIT STRING, encapsulates { 20 22: SEQUENCE { 22 17: INTEGER : 00 9D B6 8F F0 95 18 A8 58 9B F7 23 94 31 17 77 : 25 41 1: INTEGER 17 : } : } : } 0 warnings, 0 errors. The keys are clearly different. HTH, Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [EMAIL PROTECTED] More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
