Cryptography

instruction

 

 

Homework 1b: The Linear Congruence rand() Function in C

 

This homework is a practical cyber-security problem where you will attempt to break the code that has been implemented using a pseudo-random number generator. The LaTeX source of your homework has been encrypted using the following C program and (Attached ). Note that based on Kerckhoff’s Principle, the encryption algorithm is public.

The homework was generated using the following code:

 

/* The ISO/IEC 9899:1990 edition of the C standard */

#define RAND_MAX 32767

static unsigned long int next = 1;

int rand(void) // RAND_MAX assumed to be 32767

{

next = next * 1103515245 + 12345;

return (unsigned int)(next/65536) % 32768;

}

void srand(unsigned int seed)

{

next = seed;

}

 

#include <stdio.h>

#include <time.h>

 

//Return a byte at a time of the rand() keystream

char randchar() {

static int key;

static int i = 0;

 

i = i % 4;

if (i == 0) key = rand();

return ((char *)(&key))[i++];

}

 

int main(int argc, const char* argv[]) {

static char randstate[64];

 

srand(time(NULL));

FILE *input, *output;

input = fopen(“Homework1b.tex”, “r”);

output = fopen(“Homework1b.tex.enc”, “w”);

 

int c,rc;

while ((c = fgetc(input)) != EOF) {

rc=randchar();

printf(“c=%d (%c) and rc=%dn”,c,c,rc);

fputc(c^rc,output);

}

fclose(input);

fclose(output);

}

 

 

The encrypted file for Windows OS:

https://drive.google.com/file/d/1aLOs3swfp2O-j-WoJNTNIc4AeTgciFRo/view

The encrypted file for Mac OS :

https://drive.google.com/file/d/1gZCujDYmEL-FZ5o_xBUS-Ng5979HSsZ7/view

 

 

Hint: The original file was in LaTeX.

Notes:

  • You may use any programming language to produce the plaintext from the provided ciphertext.
  • Please submit a copy of your program and describe how you solved the problem in your homework submission.

 

        $10 per 275 words - Purchase Now