Hi Nick, > rand_num_gen.GenerateBlock(plainstring, size); > ... > s_globalRNG.GenerateBlock((byte *)plainstring, size); What is plainstring? if its a std::string, resize it first then get a pointer to byte[0]: plainstring.resize(size); s_globalRNG.GenerateBlock((byte *)plainstring.data(), plainstring.size());
Jeff On Thu, Nov 19, 2009 at 10:10 PM, nick aschberger <[email protected]> wrote: > Hi Folks, > > I have a C++ class that is generating a random number using cryptopp, using > either almost exactly the same code as per the FAQ. > > I also have a test harness that creates and destroys the class, as it > applies different testcases to it. > > The second time the class is created and the random number generation fn is > entered, cryptopp crashes. > > The code snippets I have are shown below: > > /* > // Autoseeded random pool object creates a pool of random numbers to > // read from, already seeded with a seed created from one of: > // - CryptGenRandom() by way of a Cryptographic Service Provider > // - /dev/random > // - /dev/urandom > */ > CryptoPP::AutoSeededRandomPool rand_num_gen; > rand_num_gen.GenerateBlock(plainstring, size); > > > Alternately: > > > // Alternate method: > // Declare a random number generator object. > OFB_Mode<AES>::Encryption s_globalRNG; > > // Init the random generator with a seed based on current time. > std::string seed = IntToString(time(NULL)); > seed.resize(16); > s_globalRNG.SetKeyWithIV((byte *)seed.data(), 16, (byte *)seed.data()); > // Use the random generator to generate a random string. > s_globalRNG.GenerateBlock((byte *)plainstring, size); > > > Either way, I get a crash. > > Has anyone seen this before, or have a suggestion? > > cheers > > Nick > > -- > 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. -- 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.
