I didn’t get a chance to blog the last couple of days because a lot has been going on here with the project.
Monday Morning- We had our typical “Progress Report” session, in which we go around and share what we have accomplished, and what we need to accomplish. We then spent some time talking about cryptography. It’s super interesting how it is a cat and mouse game, where the math is essentially made more difficult once computers catch up in their processing capabilities. This worksheet was a blast to complete. and you can encode/decode a message: https://www.cs.drexel.edu/~introcs/Fa14/labs/LB-EndOfTerm/RSAWorksheetv4e.html
Monday Afternoon- Between Kathy, me, and Google, we got my program working! It can now classify cell parts based on HSV. This will allow me to look at the 40 images that I have to be able to look at the color space of the prepared H&E slides. I also made the GUI more Drexel (Blue & Gold)
Tuesday- I worked on classifying pictures all day. There’s not much to report. I did send the images to Mark to analyze to make sure everything was being output correctly, and received the green light.
Wednesday- We spent the morning with Bill, talking about all kinds of computer science processes. We first signed up for Bitbucket accounts, and Bill showed us how to use the service. It’s like Github or even dropbox. My repository wouldn’t upload as my image files are huge, and even though I have the academic version, it was still too big.
We then did some socket programming. Bill’s Instructions:
Part 0 – Downloading the Required Files
- Download http://www.pages.drexel.edu/~wmm24/rsa/RSALibrary.zip and http://www.pages.drexel.edu/~wmm24/rsa/SecureChat.zip.
- The objective of the following lesson is to give students experience in:
- Protocol design, implementation
- Modification or augmentation of protocol layers
- Algorithm implementation
- The RSA Cryptosystem
- Importing and using Java libraries
- Optionally: Key exchange algorithms, Threading, and Message signatures
- Optionally, if running on a wireless network or a wired hub, use Wireshark to “intercept” messages across the wire.
Part 1 – Create Eclipse Project for MiniRSA
- Under Eclipse – go to File -> Import, and select “Existing Projects into Workspace” as below.
- Unzip the project code, and in Eclipse, select “Select Root Directory” and browse to the “RSA Java with Library” directory as the root.
- Select the RSA Project and click Finish
Part 2 – Including the RSAMath Library jar
- Right click on the project and click Properties
- Click on the “Java Build Path” setting to import the jar, and bring up the Libraries tab across the top.
- Click “Add External JARs” and select the rsamath.jar file inside the “RSA Java Library” directory, unzipped as part of your archive.
Part 3 – Checking out the MiniRSA Algorithm
As discussed, students will implement (and you are given!) the RSA algorithm. There are 5 files included in the cs4hs11.rsa package, and they are described here in the order in which you should write and run them:
- java – this file contains the entire RSA algorithm, from start to finish, and is suitable for describing the algorithm in general terms.
- java – this class prompts the user for primes (users can enter 2 and 3 to compute the 2nd and 3rd prime number, so they don’t have to come up with their own primes! Note that large numbers are clearly stronger, but are also slower to compute here and crack, so numbers > 10 and < 100 are generally appropriate).
- java – this class prompts the user for a friend’s encryption key (E, C), and a string, and returns the encrypted values to share with a friend.
- java – this class is run by a student after receiving an encrypted message from a friend, and prompts the user for the decryption key (D, C), and each encrypted value before decrypting them to the original message.
- java – this class prompts the user for a friend’s encryption key (E, C), and brute-force determines the decryption key (D, C) associated with it. This is good for discussing how encryption is hiding in plain sight, protecting information with keys, not algorithms.
Within the RSA Java Library directory, you are given a jar file and a javadoc directory, both of which are suitable for giving to students. The nice thing here is that they can get some practice importing external jar files and using simple interfaces as published in the JavaDoc. If you want to trade this for more programming practice and algorithm implementation, by all means feel free to have students implement the functions inside the library. They are:
Part 4 – Running MiniRSA
- To run MiniRSA, first generate a public/private key pair by running GenKey.java (right click on the file, and select Run As -> Java Application).
- Write your Public Key on the board or Google Doc, and privately save your Private Key. Here, my public key is (451, 2623) and the private key is (1531, 2623).
- Have a friend encrypt a message to you by running Encrypt.java with your public key, and store the encrypted numbers into the Google Doc (or on the board).
- Once you have received a message, decrypt it in similar fashion by running Decrypt.java with your private key.
- Now, let’s crack our friend’s key by running RSACracker.java with the public key found in the Google Doc:
Part 5 – Encrypted Chat Application
- You are given, as before, the full solution to work with. However, students versions may vary widely here depending on the “protocol” that they choose with you in the classroom. The important thing is that they:
- Decide on a protocol
- Implement a simple chat client and server based on that protocol
- Optionally add threads to the sending and receiving behaviors so that they can chat “in parallel” and not have to wait for a message to arrive before sending. (this can be provided for students as well so they can appreciate a more fully functional chat app!).
- Implement the RSA algorithm as above
- Generate keys and incorporate encryption into the sending and receiving of their messages
- Optionally pass the keys to one another at startup – but then, this would be insecure! This could create discussion about key exchange algorithms for more advanced students (i.e., perhaps they could research this and do a short presentation).
- As before, unzip the contents of SecureChat.zip and import this project directory into your workspace. You will find several files:
- java – The chat server creates a server socket, listens for a friend to connect via a chat client, spawns threads to send and receive encrypted messages. It takes in 6 parameters: the port number to listen on, the friend’s public key E, the friend’s public key modulus C, your private key D, your private key modulus C, and a 1 or 0 to enable or disable verbose debugging messages.
- java – Similarly, the chat client takes in 7 parameters, and differs only in the first, which is the IP address of the server peer to connect to. Otherwise, it also takes the port to connect to, public and private key information, and a 1 or 0 for debug messages.
- java – This class serves double-duty: it takes in a DataStream (either in or out) and, depending on which one it was given, reads from the socket or writes to the socket. So it is a threaded chat sender OR a threaded chat receiver (the main program will create two of these). This one already includes encryption and decryption support.
- java – This is the key generator class from the MiniRSA package
- java – This contains the RSAMath library functionality formerly provided as a jar package.
- Create a run configuration for the server by right clicking on ChatServer.java, and selecting Run As->Run Configurations.
- Click the Arguments tab and provide the arguments as described above, using the public and private key information determined from the MiniRSA activity:
- A friend can do the same for RSAClient; give your friend your IP address and port number by running ipconfig from a command prompt (but don’t exchange private keys!):
- Set the debug flag to 1 to show that it really is sending encrypted traffic across the network:
Part 6 – Interception with Wireshark
This part can be tricky because most wired networks are on switches or routers, as opposed to hubs, so traffic is generally not repeated to all hosts. Therefore, it may be hard to capture traffic from all students. Wireless cards that support it can be configured in Promiscuous mode, and Wireshark can be set up to capture the traffic by going to Capture -> Interfaces, and clicking Start next to your interface (here, mine was Microsoft).
And filtering on tcp.port == your_port_number (for the chat application). Mine was 12345
Note also that, if using the localhost interface, you should actually type in your local IP address and not localhost in the Chat program. This is because Wireshark does not capture localhost traffic generally. One can bypass this by forcing a route for local IP traffic, by opening a command line as Administrator and entering the following Route command:
(note the corresponding route delete afterwards which should be run after the lesson). The command only needs to be run once. You will notice TCP traffic generated when you send or receive a message. Here is mine (click on the packet, then expand the Data part in the middle of the screen).
Notice the last bytes are 98, 97, 10684, which are the encrypted bytes that were sent. This can be fed to the RSACracker from earlier, along with the friend’s public key, to decrypt other messages that the friend receives.
Socket programming was pretty interesting. I spent the afternoon going through and classifying my MATLAB (or I guess, Imagescope) H&E slides.