annotate src/myVncProxy/DesCipher.java @ 145:8bdbed4c4505

add template.txt
author e085711
date Mon, 05 Sep 2011 06:03:14 +0900
parents 87b29d6039a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
87b29d6039a6 add package myVncProxy
e085711
parents: 0
diff changeset
1 package myVncProxy;
0
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
2 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
3 // This DES class has been extracted from package Acme.Crypto for use in VNC.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
4 // The bytebit[] array has been reversed so that the most significant bit
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
5 // in each byte of the key is ignored, not the least significant. Also the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
6 // unnecessary odd parity code has been removed.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
7 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
8 // These changes are:
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
9 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
10 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
11 // This software is distributed in the hope that it will be useful,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
14 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
15
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
16 // DesCipher - the DES encryption method
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
17 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
18 // The meat of this code is by Dave Zimmerman <dzimm@widget.com>, and is:
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
19 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
20 // Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
21 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
22 // Permission to use, copy, modify, and distribute this software
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
23 // and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24 // without fee is hereby granted, provided that this copyright notice is kept
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25 // intact.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27 // WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28 // OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29 // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30 // PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31 // FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32 // DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 // THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35 // CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36 // PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37 // NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38 // SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39 // SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40 // PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41 // SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42 // HIGH RISK ACTIVITIES.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45 // The rest is:
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 // Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 // Redistribution and use in source and binary forms, with or without
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 // modification, are permitted provided that the following conditions
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 // are met:
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52 // 1. Redistributions of source code must retain the above copyright
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 // notice, this list of conditions and the following disclaimer.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54 // 2. Redistributions in binary form must reproduce the above copyright
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 // notice, this list of conditions and the following disclaimer in the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56 // documentation and/or other materials provided with the distribution.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61 // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 // SUCH DAMAGE.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 // Visit the ACME Labs Java page for up-to-date versions of this and other
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71 // fine Java utilities: http://www.acme.com/java/
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74 import java.io.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 /// The DES encryption method.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
77 // <P>
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
78 // This is surprisingly fast, for pure Java. On a SPARC 20, wrapped
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
79 // in Acme.Crypto.EncryptedOutputStream or Acme.Crypto.EncryptedInputStream,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80 // it does around 7000 bytes/second.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81 // <P>
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82 // Most of this code is by Dave Zimmerman <dzimm@widget.com>, and is
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83 // Copyright (c) 1996 Widget Workshop, Inc. See the source file for details.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84 // <P>
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 // <A HREF="/resources/classes/Acme/Crypto/DesCipher.java">Fetch the software.</A><BR>
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 // <A HREF="/resources/classes/Acme.tar.Z">Fetch the entire Acme package.</A>
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87 // <P>
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
88 // @see Des3Cipher
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
89 // @see EncryptedOutputStream
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
90 // @see EncryptedInputStream
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
91
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
92 public class DesCipher
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95 // Constructor, byte-array key.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96 public DesCipher( byte[] key )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 setKey( key );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
101 // Key routines.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
102
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
103 private int[] encryptKeys = new int[32];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
104 private int[] decryptKeys = new int[32];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
105
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
106 /// Set the key.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
107 public void setKey( byte[] key )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
108 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
109 deskey( key, true, encryptKeys );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
110 deskey( key, false, decryptKeys );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
111 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
112
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
113 // Turn an 8-byte key into internal keys.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
114 private void deskey( byte[] keyBlock, boolean encrypting, int[] KnL )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
115 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
116 int i, j, l, m, n;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
117 int[] pc1m = new int[56];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
118 int[] pcr = new int[56];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
119 int[] kn = new int[32];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
120
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
121 for ( j = 0; j < 56; ++j )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
122 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
123 l = pc1[j];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
124 m = l & 07;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
125 pc1m[j] = ( (keyBlock[l >>> 3] & bytebit[m]) != 0 )? 1: 0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
126 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
127
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
128 for ( i = 0; i < 16; ++i )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
129 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
130 if ( encrypting )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
131 m = i << 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
132 else
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
133 m = (15-i) << 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
134 n = m+1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
135 kn[m] = kn[n] = 0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
136 for ( j = 0; j < 28; ++j )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
137 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
138 l = j+totrot[i];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
139 if ( l < 28 )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
140 pcr[j] = pc1m[l];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
141 else
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
142 pcr[j] = pc1m[l-28];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
143 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
144 for ( j=28; j < 56; ++j )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
145 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
146 l = j+totrot[i];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
147 if ( l < 56 )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
148 pcr[j] = pc1m[l];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
149 else
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
150 pcr[j] = pc1m[l-28];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
151 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
152 for ( j = 0; j < 24; ++j )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
153 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
154 if ( pcr[pc2[j]] != 0 )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
155 kn[m] |= bigbyte[j];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
156 if ( pcr[pc2[j+24]] != 0 )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
157 kn[n] |= bigbyte[j];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
158 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
159 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
160 cookey( kn, KnL );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
161 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
162
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
163 private void cookey( int[] raw, int KnL[] )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
164 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
165 int raw0, raw1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
166 int rawi, KnLi;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
167 int i;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
168
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
169 for ( i = 0, rawi = 0, KnLi = 0; i < 16; ++i )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
170 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
171 raw0 = raw[rawi++];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
172 raw1 = raw[rawi++];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
173 KnL[KnLi] = (raw0 & 0x00fc0000) << 6;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
174 KnL[KnLi] |= (raw0 & 0x00000fc0) << 10;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
175 KnL[KnLi] |= (raw1 & 0x00fc0000) >>> 10;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
176 KnL[KnLi] |= (raw1 & 0x00000fc0) >>> 6;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
177 ++KnLi;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
178 KnL[KnLi] = (raw0 & 0x0003f000) << 12;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
179 KnL[KnLi] |= (raw0 & 0x0000003f) << 16;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
180 KnL[KnLi] |= (raw1 & 0x0003f000) >>> 4;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
181 KnL[KnLi] |= (raw1 & 0x0000003f);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
182 ++KnLi;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
183 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
184 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
185
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
186
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
187 // Block encryption routines.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
188
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
189 private int[] tempInts = new int[2];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
190
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
191 /// Encrypt a block of eight bytes.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
192 public void encrypt( byte[] clearText, int clearOff, byte[] cipherText, int cipherOff )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
193 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
194 squashBytesToInts( clearText, clearOff, tempInts, 0, 2 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
195 des( tempInts, tempInts, encryptKeys );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
196 spreadIntsToBytes( tempInts, 0, cipherText, cipherOff, 2 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
197 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
198
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
199 /// Decrypt a block of eight bytes.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
200 public void decrypt( byte[] cipherText, int cipherOff, byte[] clearText, int clearOff )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
201 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
202 squashBytesToInts( cipherText, cipherOff, tempInts, 0, 2 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
203 des( tempInts, tempInts, decryptKeys );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
204 spreadIntsToBytes( tempInts, 0, clearText, clearOff, 2 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
205 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
206
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
207 // The DES function.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
208 private void des( int[] inInts, int[] outInts, int[] keys )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
209 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
210 int fval, work, right, leftt;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
211 int round;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
212 int keysi = 0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
213
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
214 leftt = inInts[0];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
215 right = inInts[1];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
216
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
217 work = ((leftt >>> 4) ^ right) & 0x0f0f0f0f;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
218 right ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
219 leftt ^= (work << 4);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
220
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
221 work = ((leftt >>> 16) ^ right) & 0x0000ffff;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
222 right ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
223 leftt ^= (work << 16);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
224
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
225 work = ((right >>> 2) ^ leftt) & 0x33333333;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
226 leftt ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
227 right ^= (work << 2);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
228
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
229 work = ((right >>> 8) ^ leftt) & 0x00ff00ff;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
230 leftt ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
231 right ^= (work << 8);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
232 right = (right << 1) | ((right >>> 31) & 1);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
233
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
234 work = (leftt ^ right) & 0xaaaaaaaa;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
235 leftt ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
236 right ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
237 leftt = (leftt << 1) | ((leftt >>> 31) & 1);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
238
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
239 for ( round = 0; round < 8; ++round )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
240 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
241 work = (right << 28) | (right >>> 4);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
242 work ^= keys[keysi++];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
243 fval = SP7[ work & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
244 fval |= SP5[(work >>> 8) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
245 fval |= SP3[(work >>> 16) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
246 fval |= SP1[(work >>> 24) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
247 work = right ^ keys[keysi++];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
248 fval |= SP8[ work & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
249 fval |= SP6[(work >>> 8) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
250 fval |= SP4[(work >>> 16) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
251 fval |= SP2[(work >>> 24) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
252 leftt ^= fval;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
253 work = (leftt << 28) | (leftt >>> 4);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
254 work ^= keys[keysi++];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
255 fval = SP7[ work & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
256 fval |= SP5[(work >>> 8) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
257 fval |= SP3[(work >>> 16) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
258 fval |= SP1[(work >>> 24) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
259 work = leftt ^ keys[keysi++];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
260 fval |= SP8[ work & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
261 fval |= SP6[(work >>> 8) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
262 fval |= SP4[(work >>> 16) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
263 fval |= SP2[(work >>> 24) & 0x0000003f ];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
264 right ^= fval;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
265 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
266
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
267 right = (right << 31) | (right >>> 1);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
268 work = (leftt ^ right) & 0xaaaaaaaa;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
269 leftt ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
270 right ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
271 leftt = (leftt << 31) | (leftt >>> 1);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
272 work = ((leftt >>> 8) ^ right) & 0x00ff00ff;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
273 right ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
274 leftt ^= (work << 8);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
275 work = ((leftt >>> 2) ^ right) & 0x33333333;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
276 right ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
277 leftt ^= (work << 2);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
278 work = ((right >>> 16) ^ leftt) & 0x0000ffff;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
279 leftt ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
280 right ^= (work << 16);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
281 work = ((right >>> 4) ^ leftt) & 0x0f0f0f0f;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
282 leftt ^= work;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
283 right ^= (work << 4);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
284 outInts[0] = right;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
285 outInts[1] = leftt;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
286 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
287
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
288
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
289 // Tables, permutations, S-boxes, etc.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
290
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
291 private static byte[] bytebit = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
292 (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x08,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
293 (byte)0x10, (byte)0x20, (byte)0x40, (byte)0x80
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
294 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
295 private static int[] bigbyte = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
296 0x800000, 0x400000, 0x200000, 0x100000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
297 0x080000, 0x040000, 0x020000, 0x010000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
298 0x008000, 0x004000, 0x002000, 0x001000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
299 0x000800, 0x000400, 0x000200, 0x000100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
300 0x000080, 0x000040, 0x000020, 0x000010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
301 0x000008, 0x000004, 0x000002, 0x000001
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
302 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
303 private static byte[] pc1 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
304 (byte)56, (byte)48, (byte)40, (byte)32, (byte)24, (byte)16, (byte) 8,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
305 (byte) 0, (byte)57, (byte)49, (byte)41, (byte)33, (byte)25, (byte)17,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
306 (byte) 9, (byte) 1, (byte)58, (byte)50, (byte)42, (byte)34, (byte)26,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
307 (byte)18, (byte)10, (byte) 2, (byte)59, (byte)51, (byte)43, (byte)35,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
308 (byte)62, (byte)54, (byte)46, (byte)38, (byte)30, (byte)22, (byte)14,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
309 (byte) 6, (byte)61, (byte)53, (byte)45, (byte)37, (byte)29, (byte)21,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
310 (byte)13, (byte) 5, (byte)60, (byte)52, (byte)44, (byte)36, (byte)28,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
311 (byte)20, (byte)12, (byte) 4, (byte)27, (byte)19, (byte)11, (byte)3
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
312 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
313 private static int[] totrot = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
314 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
315 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
316
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
317 private static byte[] pc2 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
318 (byte)13, (byte)16, (byte)10, (byte)23, (byte) 0, (byte) 4,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
319 (byte) 2, (byte)27, (byte)14, (byte) 5, (byte)20, (byte) 9,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
320 (byte)22, (byte)18, (byte)11, (byte)3 , (byte)25, (byte) 7,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
321 (byte)15, (byte) 6, (byte)26, (byte)19, (byte)12, (byte) 1,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
322 (byte)40, (byte)51, (byte)30, (byte)36, (byte)46, (byte)54,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
323 (byte)29, (byte)39, (byte)50, (byte)44, (byte)32, (byte)47,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
324 (byte)43, (byte)48, (byte)38, (byte)55, (byte)33, (byte)52,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
325 (byte)45, (byte)41, (byte)49, (byte)35, (byte)28, (byte)31,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
326 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
327
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
328 private static int[] SP1 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
329 0x01010400, 0x00000000, 0x00010000, 0x01010404,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
330 0x01010004, 0x00010404, 0x00000004, 0x00010000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
331 0x00000400, 0x01010400, 0x01010404, 0x00000400,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
332 0x01000404, 0x01010004, 0x01000000, 0x00000004,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
333 0x00000404, 0x01000400, 0x01000400, 0x00010400,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
334 0x00010400, 0x01010000, 0x01010000, 0x01000404,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
335 0x00010004, 0x01000004, 0x01000004, 0x00010004,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
336 0x00000000, 0x00000404, 0x00010404, 0x01000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
337 0x00010000, 0x01010404, 0x00000004, 0x01010000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
338 0x01010400, 0x01000000, 0x01000000, 0x00000400,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
339 0x01010004, 0x00010000, 0x00010400, 0x01000004,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
340 0x00000400, 0x00000004, 0x01000404, 0x00010404,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
341 0x01010404, 0x00010004, 0x01010000, 0x01000404,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
342 0x01000004, 0x00000404, 0x00010404, 0x01010400,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
343 0x00000404, 0x01000400, 0x01000400, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
344 0x00010004, 0x00010400, 0x00000000, 0x01010004
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
345 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
346 private static int[] SP2 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
347 0x80108020, 0x80008000, 0x00008000, 0x00108020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
348 0x00100000, 0x00000020, 0x80100020, 0x80008020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
349 0x80000020, 0x80108020, 0x80108000, 0x80000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
350 0x80008000, 0x00100000, 0x00000020, 0x80100020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
351 0x00108000, 0x00100020, 0x80008020, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
352 0x80000000, 0x00008000, 0x00108020, 0x80100000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
353 0x00100020, 0x80000020, 0x00000000, 0x00108000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
354 0x00008020, 0x80108000, 0x80100000, 0x00008020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
355 0x00000000, 0x00108020, 0x80100020, 0x00100000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
356 0x80008020, 0x80100000, 0x80108000, 0x00008000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
357 0x80100000, 0x80008000, 0x00000020, 0x80108020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
358 0x00108020, 0x00000020, 0x00008000, 0x80000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
359 0x00008020, 0x80108000, 0x00100000, 0x80000020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
360 0x00100020, 0x80008020, 0x80000020, 0x00100020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
361 0x00108000, 0x00000000, 0x80008000, 0x00008020,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
362 0x80000000, 0x80100020, 0x80108020, 0x00108000
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
363 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
364 private static int[] SP3 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
365 0x00000208, 0x08020200, 0x00000000, 0x08020008,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
366 0x08000200, 0x00000000, 0x00020208, 0x08000200,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
367 0x00020008, 0x08000008, 0x08000008, 0x00020000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
368 0x08020208, 0x00020008, 0x08020000, 0x00000208,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
369 0x08000000, 0x00000008, 0x08020200, 0x00000200,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
370 0x00020200, 0x08020000, 0x08020008, 0x00020208,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
371 0x08000208, 0x00020200, 0x00020000, 0x08000208,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
372 0x00000008, 0x08020208, 0x00000200, 0x08000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
373 0x08020200, 0x08000000, 0x00020008, 0x00000208,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
374 0x00020000, 0x08020200, 0x08000200, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
375 0x00000200, 0x00020008, 0x08020208, 0x08000200,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
376 0x08000008, 0x00000200, 0x00000000, 0x08020008,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
377 0x08000208, 0x00020000, 0x08000000, 0x08020208,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
378 0x00000008, 0x00020208, 0x00020200, 0x08000008,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
379 0x08020000, 0x08000208, 0x00000208, 0x08020000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
380 0x00020208, 0x00000008, 0x08020008, 0x00020200
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
381 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
382 private static int[] SP4 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
383 0x00802001, 0x00002081, 0x00002081, 0x00000080,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
384 0x00802080, 0x00800081, 0x00800001, 0x00002001,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
385 0x00000000, 0x00802000, 0x00802000, 0x00802081,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
386 0x00000081, 0x00000000, 0x00800080, 0x00800001,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
387 0x00000001, 0x00002000, 0x00800000, 0x00802001,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
388 0x00000080, 0x00800000, 0x00002001, 0x00002080,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
389 0x00800081, 0x00000001, 0x00002080, 0x00800080,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
390 0x00002000, 0x00802080, 0x00802081, 0x00000081,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
391 0x00800080, 0x00800001, 0x00802000, 0x00802081,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
392 0x00000081, 0x00000000, 0x00000000, 0x00802000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
393 0x00002080, 0x00800080, 0x00800081, 0x00000001,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
394 0x00802001, 0x00002081, 0x00002081, 0x00000080,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
395 0x00802081, 0x00000081, 0x00000001, 0x00002000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
396 0x00800001, 0x00002001, 0x00802080, 0x00800081,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
397 0x00002001, 0x00002080, 0x00800000, 0x00802001,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
398 0x00000080, 0x00800000, 0x00002000, 0x00802080
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
399 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
400 private static int[] SP5 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
401 0x00000100, 0x02080100, 0x02080000, 0x42000100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
402 0x00080000, 0x00000100, 0x40000000, 0x02080000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
403 0x40080100, 0x00080000, 0x02000100, 0x40080100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
404 0x42000100, 0x42080000, 0x00080100, 0x40000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
405 0x02000000, 0x40080000, 0x40080000, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
406 0x40000100, 0x42080100, 0x42080100, 0x02000100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
407 0x42080000, 0x40000100, 0x00000000, 0x42000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
408 0x02080100, 0x02000000, 0x42000000, 0x00080100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
409 0x00080000, 0x42000100, 0x00000100, 0x02000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
410 0x40000000, 0x02080000, 0x42000100, 0x40080100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
411 0x02000100, 0x40000000, 0x42080000, 0x02080100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
412 0x40080100, 0x00000100, 0x02000000, 0x42080000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
413 0x42080100, 0x00080100, 0x42000000, 0x42080100,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
414 0x02080000, 0x00000000, 0x40080000, 0x42000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
415 0x00080100, 0x02000100, 0x40000100, 0x00080000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
416 0x00000000, 0x40080000, 0x02080100, 0x40000100
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
417 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
418 private static int[] SP6 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
419 0x20000010, 0x20400000, 0x00004000, 0x20404010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
420 0x20400000, 0x00000010, 0x20404010, 0x00400000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
421 0x20004000, 0x00404010, 0x00400000, 0x20000010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
422 0x00400010, 0x20004000, 0x20000000, 0x00004010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
423 0x00000000, 0x00400010, 0x20004010, 0x00004000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
424 0x00404000, 0x20004010, 0x00000010, 0x20400010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
425 0x20400010, 0x00000000, 0x00404010, 0x20404000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
426 0x00004010, 0x00404000, 0x20404000, 0x20000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
427 0x20004000, 0x00000010, 0x20400010, 0x00404000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
428 0x20404010, 0x00400000, 0x00004010, 0x20000010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
429 0x00400000, 0x20004000, 0x20000000, 0x00004010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
430 0x20000010, 0x20404010, 0x00404000, 0x20400000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
431 0x00404010, 0x20404000, 0x00000000, 0x20400010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
432 0x00000010, 0x00004000, 0x20400000, 0x00404010,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
433 0x00004000, 0x00400010, 0x20004010, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
434 0x20404000, 0x20000000, 0x00400010, 0x20004010
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
435 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
436 private static int[] SP7 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
437 0x00200000, 0x04200002, 0x04000802, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
438 0x00000800, 0x04000802, 0x00200802, 0x04200800,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
439 0x04200802, 0x00200000, 0x00000000, 0x04000002,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
440 0x00000002, 0x04000000, 0x04200002, 0x00000802,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
441 0x04000800, 0x00200802, 0x00200002, 0x04000800,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
442 0x04000002, 0x04200000, 0x04200800, 0x00200002,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
443 0x04200000, 0x00000800, 0x00000802, 0x04200802,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
444 0x00200800, 0x00000002, 0x04000000, 0x00200800,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
445 0x04000000, 0x00200800, 0x00200000, 0x04000802,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
446 0x04000802, 0x04200002, 0x04200002, 0x00000002,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
447 0x00200002, 0x04000000, 0x04000800, 0x00200000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
448 0x04200800, 0x00000802, 0x00200802, 0x04200800,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
449 0x00000802, 0x04000002, 0x04200802, 0x04200000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
450 0x00200800, 0x00000000, 0x00000002, 0x04200802,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
451 0x00000000, 0x00200802, 0x04200000, 0x00000800,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
452 0x04000002, 0x04000800, 0x00000800, 0x00200002
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
453 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
454 private static int[] SP8 = {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
455 0x10001040, 0x00001000, 0x00040000, 0x10041040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
456 0x10000000, 0x10001040, 0x00000040, 0x10000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
457 0x00040040, 0x10040000, 0x10041040, 0x00041000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
458 0x10041000, 0x00041040, 0x00001000, 0x00000040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
459 0x10040000, 0x10000040, 0x10001000, 0x00001040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
460 0x00041000, 0x00040040, 0x10040040, 0x10041000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
461 0x00001040, 0x00000000, 0x00000000, 0x10040040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
462 0x10000040, 0x10001000, 0x00041040, 0x00040000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
463 0x00041040, 0x00040000, 0x10041000, 0x00001000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
464 0x00000040, 0x10040040, 0x00001000, 0x00041040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
465 0x10001000, 0x00000040, 0x10000040, 0x10040000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
466 0x10040040, 0x10000000, 0x00040000, 0x10001040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
467 0x00000000, 0x10041040, 0x00040040, 0x10000040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
468 0x10040000, 0x10001000, 0x10001040, 0x00000000,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
469 0x10041040, 0x00041000, 0x00041000, 0x00001040,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
470 0x00001040, 0x00040040, 0x10000000, 0x10041000
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
471 };
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
472
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
473 // Routines taken from other parts of the Acme utilities.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
474
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
475 /// Squash bytes down to ints.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
476 public static void squashBytesToInts( byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
477 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
478 for ( int i = 0; i < intLen; ++i )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
479 outInts[outOff + i] =
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
480 ( ( inBytes[inOff + i * 4 ] & 0xff ) << 24 ) |
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
481 ( ( inBytes[inOff + i * 4 + 1] & 0xff ) << 16 ) |
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
482 ( ( inBytes[inOff + i * 4 + 2] & 0xff ) << 8 ) |
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
483 ( inBytes[inOff + i * 4 + 3] & 0xff );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
484 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
485
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
486 /// Spread ints into bytes.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
487 public static void spreadIntsToBytes( int[] inInts, int inOff, byte[] outBytes, int outOff, int intLen )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
488 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
489 for ( int i = 0; i < intLen; ++i )
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
490 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
491 outBytes[outOff + i * 4 ] = (byte) ( inInts[inOff + i] >>> 24 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
492 outBytes[outOff + i * 4 + 1] = (byte) ( inInts[inOff + i] >>> 16 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
493 outBytes[outOff + i * 4 + 2] = (byte) ( inInts[inOff + i] >>> 8 );
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
494 outBytes[outOff + i * 4 + 3] = (byte) inInts[inOff + i];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
495 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
496 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
497 }