I’m attempting to analyze a short encryption program and figure out which mechanism it’s using.
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char * argv[] ) {
long int key;
char * endptr;
key = strtol( argv[1], &endptr, 10 );
srandom( key );
{ /* now copy input to output through crypt transformation */
char ch;
while (!feof( stdin )) {
putc( (getc(stdin) ^ random())&0xFF, stdout );
}
fclose( stdout );
}
}
I can follow this simply, but I’m having trouble trying to weed out which mechanism it’s using..
I’m looking at the following:
http://en.wikipedia.org/wiki/Public-key_cryptography
http://en.wikipedia.org/wiki/Block_cipher
http://en.wikipedia.org/wiki/Stream_cipher
http://en.wikipedia.org/wiki/Diffie-Hellman
I’m leaning towards iterated block cyphers but I really have no idea at this point.
You need to clearly distinguish in your mind the ciphers in categories. There are:
The above only distinguishes ciphers by the size of the input they accept; it has nothing to do with the mechanism they use to produce the encrypted text.
Regarding this mechanism, we have:
So try to answer this question first:
Is your example a stream cipher or a block cipher? Remember, this has nothing to do with how it encrypts!