Created By: Keith Acosta Instructor: Wei Zhong Courses: Senior Seminar Cryptography
1. Thread Summery 2. Thread creation 3. App Diagram and information flow 4. General flow of Diffie-Hellman 5. Steps of the Diffie-Hellman 6. DESede or Triple DES (Data Encryption Standard) Diagram 7. CFB (Cipher Feedback) Diagram 8. Manifest XML 9. Activity XML s 10.Screen Shots
Thread Handling Server Side 1. The Main Activity I. starts the Server Listen Thread II. Passes text to Server listen thread 2. Server listen Thread I. Creates the Cipher Streams II. Opens the socket then starts the Server Send Thread passing it the Cipher Out I. Server listen thread stays in an infinite loop listening for input from the socket II. When the thread receives data it passes the deciphered string back to the main Activity through the handler. III. Passes text through to the Server Send Threads sendtext method 3. Server Send Thread I. Wait in an infinite loop to send data out II. Send message through the Handler to update the Main Activity
Thread Handling Client Side 1. The Main Activity I. starts the Client Send Thread II. Passes text to Client Send thread 2. Client Send Thread I. Creates the Cipher Streams II. Opens the socket then starts the Client Listen Thread passing it the Cipher In III. Wait in an infinite loop to send data out Using Cipher out 3. Client Listen Thread I. Client listen thread stays in an infinite loop listening for input from the socket II. When the thread receives data it passes the deciphered string back to the main Activity through the handler.
Server Threads IP, Port, Handler Text to Send Main Activity Listen Thread UI Update Socket, Cipher Stream, Handler Send Thread
Client Threads IP, Port, Handler Text to Send Main Activity Send Thread UI Update Socket, Cipher Stream, Handler Listen Thread
1 Server Generate D-H Session Key Pair Client Generate D-H Session Key Pair 2 Listen For Client Connect to Open Server Port 3 Send Public Key To Client Receive Servers Public Key
4 Server Receive Client Public Key Client Send Client Public Key 5 Perform Key Agreement Perform Key Agreement 6 Create IV Waiting For Server IV
7 Server Send Server IV Client Receive Server IV 8 Generate DES Key Generate DES Key 9 Create Cipher Stream Create Cipher Stream Connection Established
Socket Creation // create client socket InetAddress serveraddr = InetAddress.getByName(serverIP); Socket s = new Socket(serverAddr, serverport); //creating the listener thread clthread = new ClientListenThread(s, mhandler, cipherin); clthread.start(); //creating server socket serversocket = new ServerSocket(serverPort); Socket client = serversocket.accept(); SocketAddress remoteip = client.getremotesocketaddress(); //creating the Sending Thread ssthread = new ServerSendThread(client, mhandler, cipherout); ssthread.start();
Step 1 & 2 //Generating a Diffie-Hellman KeyPair //creating input/output streams to send and receive //public key data
Step 3 & 4 //Receving public key //Sending public key
//Performing key Agreement Step 5
Step 6, 7 & 8 //Server --Sending IV bytes to client //Client Receiving IV Bytes //Generating DESede Key
Steps 8 & 9 //Creating the Encrypting Cipher Stream //Creating the Decrypting Cipher Stream
Infinite Loops //Loop to send encrypted text while (connected) { If (messagesend) { cipherout.write(texttosend.getbytes()); cipherout.flush(); messagesend = false; } } //loops to recieve and decipher text while (connected) { thechar = cipherin.read(); Char = (char) thechar; if (Char!= '~') msg += Char; if (Char == '~') { updateui("you: " + msg.substring(0, msg.length()), true); msg = ""; } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.crypt.cryptapp" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="14" android:targetsdkversion="16" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.crypt.cryptapp.mainactivityserver" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.internet" /> </manifest>
Client Collapsed XML <LinearLayout > <EditText/> <TextView/> <LinearLayout> <Button/> </LinearLayout> <TextView/> <EditText/> Server Collapsed XML <LinearLayout > <TextView/> <TextView/> <EditText> <requestfocus /> </EditText> <Button/> </LinearLayout> <LinearLayout> <Button/> </LinearLayout> </LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".cryptmain" > <EditText android:id="@+id/edittext1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="ip Address / File to transfer" android:inputtype="numberdecimal text" /> <TextView android:id="@+id/main_local_ip_status_tv" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="ip_status_message" />
<EditText android:id="@+id/chat_etb" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="enter message" > <requestfocus /> </EditText> <Button android:id="@+id/chat_btn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="send Text" /> </LinearLayout>
Main Screens Client Screen with server IP entered Server showing its IP
Matched Server Public Key Client s display of the Server s Public Key Server Displaying Its generated Public Key
Client s displaying generated Public Key Matched Client Public Key Server Display of the Client s Public Key
Matched Session Keys