Really this comes down to three issues: 1) How do I generate a DH prime and generator (primitive root modulo the prime)? I see how to generate a prime with the Integer class, but that has no way of setting a generator or getting the generator for the generated prime. I'm beginning to think that the dat file has the prime and generator and is not just a seed value for the PRNG. (Also, I'm not talking about how to simply access the modulus that is there, as that is easy. I want to be able to set my own and not use the example).
2) How do I save this prime/generator pair out? I'm guessing once I have step 1, it is as simple as calling SetModulusAndSubgroupGenerator on my GroupParameters, then saying groupParameters->Save( FileSink ); >From what I can tell, I need to write out a prime, a q (??) and a generator. Not sure what the second integer being read in during the BERDecode is though (I think maybe the subgroup order? I guess I'll need to set that as well). 3) Ideally, it would be nice to be able to create the prime/generator pair and save them without going through the GroupParameters. I'm somewhat confused that it looks like there is a BERDecoder, but you can only encode with DEREncode...I would think there would be corrolary functions (BEREncode, for instance). The search continues... On May 28, 11:19 am, SpaceCowboy850 <[email protected]> wrote: > I've taken a look at both of those thoroughly, > (http://www.cryptopp.com/wiki/Diffie-Hellmanand the source code in the > examples), and they were very instrumental in getting me a working > version. I got DH working before I posted the first time using those > two resources. Now, what I want to do is make my own dat file, but > I'm having trouble locating what generates a dat file and the > requisites for generating this dat file. From what I can tell, the > dat files are part of the download and not generated by the code. > > On May 27, 7:14 pm, Jeffrey Walton <[email protected]> wrote: > > > > It appears the first byte is not the asnTag. I know this is simple, > > > but what am I doing wrong? > > > You're writing random data, and then trying to read it as an ASN.1 > > encoded object. Take a look at the wiki's DH example, or Crypto++'s > > examples in validate1.cpp, validate2.cpp, etc. > > > Jeff > > > On 5/27/09, SpaceCowboy850 <[email protected]> wrote: > > > > I'm using the Deffie-Hellman algorithm in Crypto 5.60 under Visual > > > Studio 2005. I'm trying to create my own seed file instead of using > > > the ones provided in the example. > > > > This is the way I create my file: > > > > const size_t seedBufSize = 1024; > > > unsigned char seedBuf[seedBufSize]; > > > g_autoRNG.GenerateBlock( reinterpret_cast<byte*>(seedBuf), > > > seedBufSize ); > > > CryptoPP::FileSink fileSink( "seed.dat" ); > > > fileSink.GetStream()->write( (const char*)seedBuf, seedBufSize ); > > > fileSink.IsolatedFlush( true, true ); > > > > I then try to load it like this: > > > > CryptoPP::FileSource fileSource( "seed.dat", true ); > > > g_pKeyAgreementAlg = new CryptoPP::DH(fileSource); > > > > I keep getting a BERDecodeError. I've tried using a HexDecoder like > > > this: > > > > CryptoPP::FileSource fileSource( "seed.dat", true, new > > > CryptoPP::HexDecoder() ); > > > > It appears the first byte is not the asnTag. I know this is simple, > > > but what am I doing wrong? --~--~---------~--~----~------------~-------~--~----~ 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. -~----------~----~----~----~------~----~------~--~---
