Java Cryptography & Java Cryptography & Internet Internet Security Security 1 Goals of Network Security 2 Basic Cryptographic Concepts 3 Java Security Concepts & Applets 4 Java Cryptographic Architecture (JCE) & Java Cryptographic Extension (JCE) 5 An example: what students have to do ...
44
Embed
Java Cryptography & Internet Security 1Goals of Network Security 2Basic Cryptographic Concepts 3Java Security Concepts & Applets 4Java Cryptographic Architecture.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Java Cryptography &Java Cryptography & Internet Security Internet Security
1 give applet rights to write a file belegis.dat on client
2 generate a keypair and a self signed certificate (X.509) ; store the keypair in a keystore file and export certificate to a file
3 write a Java-application that produces a MD5-Message Digest of file belegis.dat
4 write another Java-application that reads and signs the Java source code of step 3, concatenate the source with the signature and encrypt the result (symmetric cryptography). Deserialize a session key for this purpose.
// Sitzungsschlüssel deserialisieren ------------------------ FileInputStream kfis = new FileInputStream(
"i:/Prakt/fritzsch/Sicherheit/chiffkey.dat"); ObjectInputStream keyin = new ObjectInputStream(kfis); SecretKey desKey=(SecretKey)keyin.readObject(); System.out.println("-- Sitzungsschluessel deserialisiert");
// Datei chiffretext.dat dechiffrieren und ----------------- // in belegis_zwi.dat ablegen FileInputStream fis = new FileInputStream("chiffretext.dat"); FileOutputStream fos =
new FileOutputStream("belegis_zwi.dat"); CipherInputStream cis; Cipher desciph = Cipher.getInstance("DES/ECB/PKCS5Padding"); cis = new CipherInputStream(fis,desciph); desciph.init(Cipher.DECRYPT_MODE,desKey); byte [] ba = new byte [1]; int iii = cis.read(ba); while (iii != -1){
// Zwischendatei belegis_zwi.dat lesen ----------------------- File gesamtFile = new File("belegis_zwi.dat"); int sizef = (int)gesamtFile.length(); fis = new FileInputStream(gesamtFile); byte b = (byte)fis.read(); sizef--; byte c = (byte)fis.read(); sizef--; byte d = (byte)fis.read(); while ((d != -1)&&((b !='S')||(c != 'I')||(d !='G'))){
sizef--;dsa.update(b);b=c;c=d;d=(byte)fis.read();
} sizef--;
// Signatur lesen ------------------------------------------ System.out.println("Laenge der Signatur: "+sizef); byte [] sig = new byte[sizef]; int ii = 0; byte s = (byte)fis.read(); while (ii < sizef){
public class HanoiVisual extends JApplet implements ActionListener{ JPanel jPanel0= new JPanel(); JPanel jPanel1= new JPanel(); JPanel jPanel2 = new JPanel(); JPanel jPanel3 = new JPanel(); JPanel jPanel4 = new JPanel(); JButton popbutton = new JButton("pop"); JButton pushbutton = new JButton("push"); JButton emptybutton = new JButton("emptyStack"); JButton runbutton = new JButton("run"); JButton stopbutton = new JButton("stop"); JPanel buttonPanel = new JPanel();
VisObject vo1 = new VisObject(0, jPanel1); VisObject vo2 = new VisObject(0, jPanel2); VisObject vo3 = new VisObject(0, jPanel3);
public void init(){try{UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName());
public void actionPerformed(ActionEvent evt){if(evt.getActionCommand().equals("pop")){ MyJPanel y = popvis(vo1);}if(evt.getActionCommand().equals("push")){ pushvis(vo1,new MyJPanel(vo1.i+1));}if(evt.getActionCommand().equals("emptyStack")){ vo1.i=0; jPanel1.removeAll(); for (int j=0;j<10;j++){
jPanel4= (JPanel)jPanel1.add(new MyJPanelInit(),j); } vo2.i=0; jPanel2.removeAll(); for (int j=0;j<10;j++){
jPanel4= (JPanel)jPanel2.add(new MyJPanelInit(),j); } vo3.i=0; jPanel3.removeAll(); for (int j=0;j<10;j++){
public void pushvis(VisObject p,MyJPanel x){p.i++;p.jP.remove(10-p.i);jPanel4= (JPanel)p.jP.add(x,10-p.i);validate();paint(getGraphics());
} public MyJPanel popvis(VisObject p){
MyJPanel x = (MyJPanel)p.jP.getComponent(10-p.i);p.jP.remove(10-p.i);jPanel4= (JPanel)p.jP.add(new MyJPanelInit(),10-p.i);validate();paint(getGraphics());p.i--;return x;
}
public void hanoiinit(){List a = new List();a = a.cons(vo1);for (int j=0;j<vo1.i;j++) a= a.cons(new Integer(vo1.i-j));a=a.reverse();a.princ();List b = new List();b = b.cons(vo2);b.princ();List c = new List();c = c.cons(vo3);c.princ();hanoi(a,b,c);
public void move(List a, List b){MyJPanel x = popvis((VisObject)a.car());validate();pushvis((VisObject)b.car(),x);validate();try{Thread.currentThread().sleep(1200);validate();}catch(InterruptedException e){}
}
public void paint(Graphics g){getContentPane().paintAll(g);
}}
class MyJPanel extends JPanel{ public MyJPanel(int i){