programming encryption help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shyguy
    Confirmed User
    • May 2004
    • 123

    #1

    programming encryption help

    as a project i am adding security to a chat room application all in java...

    i already have the basic chat server and client, but i need to create a seperate java application to integrate with it to add security.

    so i basically need to set it up so that all communications are encrypted, so outside eavesdroppers cant understand them. i have to implement authentication so that only verified users can access the chat service. the method used was going to be a based on a simplified version of the Kerberos protocol. was going to omit the Kerberos ticket server from this for the time being.

    any help here would be muchly appreciated... source code of a working example would be great...
    Great MONEY making opportunity - Casino Cash
  • PowerCum
    CjOverkill
    • Apr 2003
    • 1328

    #2
    use ssl. a port of yassl (standalone ssl implementation) will do the work.
    CjOverkill Traffic Trading Script
    Free, secure and fast traffic trading script. Get your copy now

    Comment

    • shyguy
      Confirmed User
      • May 2004
      • 123

      #3
      hiya... i know a bit more about what i have to do for this now... its for an assignment and my programming isnt that great so i really need some example to checkout and get me started... need help PLEASE!!

      i basically have to use the JCE DES method which i already have the basic code for, but i have to make it so that i create a second dummy server which authenticates the user/client and then also lets the real server know... i can just hard code the user names and keys... ive pasted the code for the client and the server below: (sorry for the huge post)...

      client:
      import java.io.*;
      import java.net.*;
      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;


      public class ChatClient extends JFrame implements ActionListener
      {
      JTextField loginID = new JTextField(20);
      JTextField messageLine = new JTextField(60);
      JTextArea chatArea = new JTextArea("", 30,60);

      JPanel loginPanel = new JPanel();
      JPanel chatPanel = new JPanel();
      JPanel messagePanel = new JPanel();
      JScrollPane scp = new JScrollPane(chatArea);

      JLabel loginLabel = new JLabel(" Login ID:");
      JLabel messageLabel = new JLabel(" Message:");
      JButton loginButton = new JButton("Login");
      JButton sendButton = new JButton("Send");
      JButton quitButton = new JButton("Quit");

      ObjectInputStream dis;
      ObjectOutputStream dos;
      NetListener nl; // A thread that listens for incoming messages and passes them to the GUI, defined below

      public ChatClient ()
      {
      //hahahahahahahaha= Set up GUI hahahahahahahaha=
      Container f = getContentPane();
      f.setLayout(new BorderLayout());

      f.add(loginPanel,BorderLayout.NORTH);
      loginPanel.setLayout(new FlowLayout());
      loginPanel.add(loginLabel);
      loginPanel.add(loginID);
      loginPanel.add(loginButton);

      f.add(chatPanel,BorderLayout.CENTER);
      chatPanel.add(scp);

      f.add(messagePanel,BorderLayout.SOUTH);
      messagePanel.setLayout(new FlowLayout());
      messagePanel.add(messageLabel);
      messagePanel.add(messageLine);
      messagePanel.add(sendButton);

      loginButton.addActionListener(this);
      sendButton.addActionListener(this);
      quitButton.addActionListener(this);
      //hahahahahahahaha= Open data streams hahahahahahahahahahahaha
      try
      {
      Socket sk = new Socket("localhost",8000); //hahahaha= Server and Client on the same host hahahaha=
      dis = new ObjectInputStream(sk.getInputStream());
      dos = new ObjectOutputStream(sk.getOutputStream());
      }
      catch (Exception ex)
      {System.out.println(ex);}

      }

      public static void main(String [] args)
      {
      ChatClient cc = new ChatClient();
      cc.nl = new NetListener(cc.dis,cc); //hahahahahahahaha Create netListener object, pass InoutStream and GUI objects to it
      cc.nl.start(); //hahahaha= Start listening hahahahahahahahahahahaha
      cc.setDefaultCloseOperation(EXIT_ON_CLOSE);
      cc.pack();
      cc.setTitle("Insecure Chat Room, for Insecure people");
      cc.setVisible(true);
      }

      public void actionPerformed(ActionEvent ev)
      {
      try
      {
      if (ev.getSource()hahahaha loginButton)
      {
      String id = loginID.getText();;
      loginID.setText("");
      dos.writeObject("Login:"+id);
      dos.flush();
      }

      if (ev.getSource()hahahaha sendButton)
      {
      String line = messageLine.getText();
      messageLine.setText("");
      dos.writeObject(line);
      dos.flush();
      }
      }

      catch (Exception e)

      {System.out.println(e);}

      }
      }


      class NetListener extends Thread
      {
      ObjectInputStream ois;
      ChatClient cli;
      public NetListener(ObjectInputStream ois, ChatClient cli)
      {
      this.ois = ois;
      this.cli = cli;
      }
      public void run()
      {
      while (true)
      {
      try
      {
      String s = (String) ois.readObject();
      cli.chatArea.append("\n"+s);
      }

      catch (Exception ex)
      {
      System.out.println(ex);
      }

      }
      }

      }

      server:
      import java.io.*;
      import java.net.*;
      import java.util.*;
      //hahahahahahahahahahahahahahahahahahahaha= Multi-Threaded Server hahahahahahahahahahahahahahahaha=
      public class ChatServer
      {
      int client = 0;
      Vector oosVect = new Vector();//hahahaha A collection of data streams, one for each client. Used for broadcasting

      public static void main(String [] args)
      {
      ChatServer bs = new ChatServer();
      System.out.println("ChatServer is running.");
      try
      {
      ServerSocket ss = new ServerSocket(8000);

      while(true)
      {
      Socket sk = ss.accept();
      InetAddress ia = sk.getInetAddress();
      String ha = ia.getHostName();

      ChatThread bt = new ChatThread(sk, bs);
      bt.start();
      bs.client++;
      System.out.println("Client " + bs.client + " connected.");
      }
      }
      catch (Exception ed)
      {}
      }

      public void broadcast(String message)
      {
      try
      {
      for (int n=0; n<oosVect.size();n++)
      {
      ObjectOutputStream oStream = (ObjectOutputStream) oosVect.elementAt(n);
      oStream.writeObject(message);
      System.out.println("Broadcasting.." +message);
      oStream.flush();
      }
      }
      catch (IOException io)
      {
      System.out.println(io);
      }
      }
      }

      class ChatThread extends Thread //hahahahahahahahahahahahahahahaha= Thread to communicate with each client hahahaha=
      {
      Socket sok;
      ChatServer cs;
      public ChatThread(Socket sok, ChatServer cs)
      {
      this.sok=sok;
      this.cs = cs;
      }

      public void run()
      {
      String id="";
      try
      {

      ObjectOutputStream dos = new ObjectOutputStream(sok.getOutputStream());
      ObjectInputStream dis = new ObjectInputStream(sok.getInputStream());
      cs.oosVect.addElement(dos);
      while (true)
      {
      String message = (String)dis.readObject();
      if (message.startsWith("Login"))
      {
      StringTokenizer st = new StringTokenizer(message,":");
      id = st.nextToken();
      id = st.nextToken();
      message = id + " has joined.";
      }
      else
      {
      if (!id.equals("")) message = " "+id+"> " + message;
      }
      cs.broadcast(message);
      dos.flush();
      }

      }
      catch (Exception e)
      {}
      }
      }
      Great MONEY making opportunity - Casino Cash

      Comment

      • PowerCum
        CjOverkill
        • Apr 2003
        • 1328

        #4
        go to www.freshmeat.net and start searching. You will find lots of open source java stuff... included encryption stuff.
        CjOverkill Traffic Trading Script
        Free, secure and fast traffic trading script. Get your copy now

        Comment

        • shyguy
          Confirmed User
          • May 2004
          • 123

          #5
          i have had a good look through feshmeat but cant find anything that will help me with my situation...
          Great MONEY making opportunity - Casino Cash

          Comment

          Working...