Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I'm writing an implementation of a block cipher in C++. I would like to study differential cryptanalysis of the cipher, so I'm generating random plaintexts and keys and then encrypt them.

Which is the best way to generate these random plaintexts and keys? Is the random function offered by C++ random enough? Should I use some hash functions or the same cipher as pseudorandom permuations to generate them?

share|improve this question
    
You are implementing a source code of a cipher... ?? Maybe you can be a little specific here? Random function offered by C++ is not 'random enough' for this purpose. Maybe you want something like PSRG- en.wikipedia.org/wiki/Pseudorandom_number_generator –  pnp Oct 18 '12 at 11:56
1  
@pnp technically c++ random is a PRNG. Just not a cryptographically secure one (probably fine for Monte Carlo simulations though). –  ewanm89 Oct 18 '12 at 11:58
    
@ewanm89 That's precisely my point. Thanks for making it clear. –  pnp Oct 18 '12 at 11:59
1  
Technically this question is probably better suited to crypto.stackexchange.com though it is borderline. –  ewanm89 Oct 18 '12 at 12:06
add comment

2 Answers

For the keys, they should be as random as you can get them, so either use a true random number generator (unlikely) or a cryptographically secure pseudo-random number generator.

The plain text can be just random from any generator, however don't you want the plain text to more accurately mirror real data where certain bit strings may be more common?

share|improve this answer
add comment

Differential cryptanalysis is a kind of attack which exploits some fine details in the structure of the attacked cipher; you look at pairs of plaintexts, encrypted with the same key, and the corresponding ciphertexts. The pairs must be carefully chosen so that the difference between the two plaintexts (usually, bitwise difference, i.e. a XOR) exercises with "high" probability the exact algorithm weakness that is targeted. There is no "generic" differential cryptanalysis in which you would just throw random plaintexts at the cipher, and hope that they will somehow combine into a Megazord-like attack.

In plain words, to do differential cryptanalysis, you have to understand what you are doing, down to the hairy mathematical details. And when you reach that point, you see that the base bits for differential cryptanalysis are not very important (what matters is the difference between the two plaintexts). Therefore, in the context of a lab experiment, most random generators will do -- but you will probably have to generate a lot of pairs of plaintexts, so you might encounter some bottleneck if the PRNG is too slow (but don't believe it yet; measure it).

If you want to get the gist of differential cryptanalysis, go read this book and try to implement it on a reduced version of DES (down to, say, 8 rounds instead of the standard 16).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.