I am learning Cryptography and using OPENSSL to implement whatever I am learning. Recently, I found one of the assignment questions and am trying to solve it. I don't have problem understanding most of the questions but this one.
4 Task 2: One-Way Property versus Collision-Free Property In this task, we will investigate the difference between two properties of common hash functions: one-way property versus collision-free property. We will use the brute-force method to see how long it takes to break each of these properties. Instead of using openssl’s command-line tools, you are required to write your own C program to invoke the message digest functions in openssl’s crypto library. Docs can be found at http://www.openssl.org/docs/crypto/EVP_DigestInit.html. Laboratory for Computer Security Education, CMSC 414, Spring 2013 2 Since most of the hash functions are quite strong against the brute-force attack on those two properties, it will take us years to break them using the brute-force method. To make the task feasible, in all of this project we reduce the length of the hash value to 24 bits. We can use any one-way hash function, but we only use the first 24 bits of the hash value. Write a program that, given a 24-bit hash value, finds a matching text (only lower-case ASCII charac- ters). Your program will have to repeatedly 1) generate a random text, 2) hash it, 3) compare lower 24 bits to the input. Your program (source must be called task2.c) will be called as follows:
./task2 <digest name> <hash value>
e.g,
./task2 sha256 2612c7. . .
and your program must write the winning text to task2.out. Please ensure the output is readable and writable, i.e.:
open("task2.out", O`enter code here` WRONLY | O CREAT, 0644);
We will verify with command line tools, e.g.,
openssl dgst -sha256 task2.out
. Question: How many texts did you have to hash to find a specific hash? (give average of three trials)
I am not able to understand how to start writing my program. Any inputs are greatly appreciated. As I am not solving it for a home work. I am looking for some pointers and not the code.