From: Felix Schumacher Date: Sun, 29 Mar 2009 18:25:02 +0000 (+0200) Subject: jcifs-1.3.8 from tgz X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6cf31d5021dd9370d2ec2a308651cc9d00b23f2d;p=jcifs_without_docs.git jcifs-1.3.8 from tgz Sat Mar 29 23:13:29 EDT 2009 jcifs-1.3.8 RC4 has been implemented which eliminates the Java 1.5u7 requirement. JCIFS 1.3 should now work with Java 1.4 (as well as 1.2 did anyway). --- diff --git a/README.txt b/README.txt index a7aaa9a..fafc039 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,12 @@ +Sat Mar 29 23:13:29 EDT 2009 +jcifs-1.3.8 + +RC4 has been implemented which eliminates the Java 1.5u7 +requirement. JCIFS 1.3 should now work with Java 1.4 (as well as 1.2 +did anyway). + Thu Mar 12 14:22:47 EDT 2009 -jcifs-1.3.6a +jcifs-1.3.7 Share security with Samba 3.0 was broken. This has been fixed. diff --git a/build.xml b/build.xml index 93963b0..a62182b 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - - + + diff --git a/src/jcifs/ntlmssp/Type3Message.java b/src/jcifs/ntlmssp/Type3Message.java index 4a454ba..629736e 100644 --- a/src/jcifs/ntlmssp/Type3Message.java +++ b/src/jcifs/ntlmssp/Type3Message.java @@ -35,6 +35,7 @@ import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import java.security.GeneralSecurityException; import jcifs.util.MD4; +import jcifs.util.RC4; /** * Represents an NTLMSSP Type-3 message. @@ -200,6 +201,9 @@ public class Type3Message extends NtlmMessage { RANDOM.nextBytes(masterKey); byte[] exchangedKey = new byte[16]; + RC4 rc4 = new RC4(ntlm2SessionKey); + rc4.update(masterKey, 0, 16, exchangedKey, 0); +/* RC4 was not added to Java until 1.5u7 so let's use our own for a little while longer ... try { Cipher rc4 = Cipher.getInstance("RC4"); rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(ntlm2SessionKey, "RC4")); @@ -207,6 +211,7 @@ public class Type3Message extends NtlmMessage { } catch (GeneralSecurityException gse) { throw new RuntimeException("", gse); } +*/ setSessionKey(exchangedKey); } else { @@ -244,6 +249,9 @@ public class Type3Message extends NtlmMessage { RANDOM.nextBytes(masterKey); byte[] exchangedKey = new byte[16]; + RC4 rc4 = new RC4(userSessionKey); + rc4.update(masterKey, 0, 16, exchangedKey, 0); +/* RC4 was not added to Java until 1.5u7 so let's use our own for a little while longer ... try { Cipher rc4 = Cipher.getInstance("RC4"); rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(userSessionKey, "RC4")); @@ -251,6 +259,7 @@ public class Type3Message extends NtlmMessage { } catch (GeneralSecurityException gse) { throw new RuntimeException("", gse); } +*/ setSessionKey(exchangedKey); } else { diff --git a/src/jcifs/util/RC4.java b/src/jcifs/util/RC4.java new file mode 100644 index 0000000..41eb634 --- /dev/null +++ b/src/jcifs/util/RC4.java @@ -0,0 +1,64 @@ +/* Copyright (C) 2009 "Michael B Allen" + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package jcifs.util; + +public class RC4 +{ + + byte[] s; + int i, j; + + public RC4() + { + } + public RC4(byte[] key) + { + init(key, 0, key.length); + } + + public void init(byte[] key, int ki, int klen) + { + s = new byte[256]; + + for (i = 0; i < 256; i++) + s[i] = (byte)i; + + for (i = j = 0; i < 256; i++) { + j = (j + key[ki + i % klen] + s[i]) & 0xff; + byte t = s[i]; + s[i] = s[j]; + s[j] = t; + } + + i = j = 0; + } + public void update(byte[] src, int soff, int slen, byte[] dst, int doff) + { + int slim; + + slim = soff + slen; + while (soff < slim) { + i = (i + 1) & 0xff; + j = (j + s[i]) & 0xff; + byte t = s[i]; + s[i] = s[j]; + s[j] = t; + dst[doff++] = (byte)(src[soff++] ^ s[(s[i] + s[j]) & 0xff]); + } + } +}