change jarfile name
[rsa2client.git] / src / mcsClient / SecureDatagramSocket.java
1 // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.kpdus.com/jad.html
3 // Decompiler options: packimports(3) fieldsfirst nonlb space 
4
5 package mcsClient;
6
7 import Acme.Crypto.DesCipher;
8 import java.io.IOException;
9 import java.net.*;
10
11 public final class SecureDatagramSocket extends DatagramSocket {
12
13     private DesCipher cipher1;
14     private DesCipher cipher2;
15     private static final boolean debug = false;
16
17     public SecureDatagramSocket(DesCipher descipher, DesCipher descipher1, int i) throws SocketException {
18         super(i);
19         cipher1 = descipher;
20         cipher2 = descipher1;
21     }
22
23     public SecureDatagramSocket(DesCipher descipher, DesCipher descipher1, int i, InetAddress inetaddress) throws SocketException {
24         super(i, inetaddress);
25         cipher1 = descipher;
26         cipher2 = descipher1;
27     }
28
29     public synchronized void receive(DatagramPacket datagrampacket) throws IOException {
30         super.receive(datagrampacket);
31         decrypt(datagrampacket.getData(), datagrampacket.getLength(), datagrampacket.getOffset());
32     }
33
34     private byte[] decrypt(byte abyte0[]) {
35         for (int i = 0; i < abyte0.length; i += 8) {
36             cipher1.decrypt(abyte0, i, abyte0, i);
37             cipher2.encrypt(abyte0, i, abyte0, i);
38             cipher1.decrypt(abyte0, i, abyte0, i);
39         }
40
41         return abyte0;
42     }
43
44     private byte[] decrypt(byte abyte0[], int i, int j) {
45         for (int k = j; k < i + j; k += 8) {
46             cipher1.decrypt(abyte0, k, abyte0, k);
47             cipher2.encrypt(abyte0, k, abyte0, k);
48             cipher1.decrypt(abyte0, k, abyte0, k);
49         }
50
51         return abyte0;
52     }
53 }