directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 54964 - in incubator/directory/kerberos/trunk/source/main/org/apache/kerberos: crypto crypto/encryption kdc
Date Sun, 17 Oct 2004 13:47:53 GMT
Author: erodriguez
Date: Sun Oct 17 06:47:53 2004
New Revision: 54964

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java
Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/CryptoService.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/DefaultConfig.java
Log:
Added support for DES3-CBC-SHA1 and DES3-CBC-MD5 encryption types.

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/CryptoService.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/CryptoService.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/CryptoService.java
Sun Oct 17 06:47:53 2004
@@ -31,10 +31,12 @@
 	
 	// TODO - these maps are classic configuration and, as such, probably belong elsewhere
 	public CryptoService() {
-		_encryptionEngines.put(EncryptionType.NULL,        new NullEncryption());
-		_encryptionEngines.put(EncryptionType.DES_CBC_CRC, new DesCbcCrcEncryption());
-		_encryptionEngines.put(EncryptionType.DES_CBC_MD4, new DesCbcMd4Encryption());
-		_encryptionEngines.put(EncryptionType.DES_CBC_MD5, new DesCbcMd5Encryption());
+		_encryptionEngines.put(EncryptionType.NULL,          new NullEncryption());
+		_encryptionEngines.put(EncryptionType.DES_CBC_CRC,   new DesCbcCrcEncryption());
+		_encryptionEngines.put(EncryptionType.DES_CBC_MD4,   new DesCbcMd4Encryption());
+		_encryptionEngines.put(EncryptionType.DES_CBC_MD5,   new DesCbcMd5Encryption());
+		_encryptionEngines.put(EncryptionType.DES3_CBC_MD5,  new Des3CbcMd5Encryption());
+		_encryptionEngines.put(EncryptionType.DES3_CBC_SHA1, new Des3CbcSha1Encryption());
 		
 		_checksumEngines.put(ChecksumType.CRC32,   new Crc32Checksum());
 		_checksumEngines.put(ChecksumType.RSA_MD4, new RsaMd4Checksum());

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java
Sun Oct 17 06:47:53 2004
@@ -0,0 +1,65 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.kerberos.crypto.encryption;
+
+import org.bouncycastle.crypto.engines.*;
+import org.bouncycastle.crypto.modes.*;
+import org.bouncycastle.crypto.params.*;
+
+public abstract class Des3CbcEncryption extends EncryptionEngine {
+
+	public CipherType keyType() {
+		return CipherType.DES3;
+	}
+
+	public int blockSize() {
+		return 8;
+	}
+
+	public int keySize() {
+		return 24;
+	}
+	
+	// TODO - duplicated in CryptoService.
+	protected synchronized byte[] processBlockCipher(boolean encrypt, byte[] data, byte[] key,
byte[] ivec) {
+		byte[] returnData = new byte[data.length];
+		CBCBlockCipher cbcCipher = new CBCBlockCipher(new DESedeEngine());
+		KeyParameter keyParameter = new KeyParameter(key);
+
+		if (ivec != null) {
+			ParametersWithIV kpWithIV = new ParametersWithIV(keyParameter, ivec);
+			cbcCipher.init(encrypt, kpWithIV);
+		} else
+			cbcCipher.init(encrypt, keyParameter);
+
+		int offset = 0;
+		int processedBytesLength = 0;
+
+		while (offset < returnData.length) {
+			try {
+				processedBytesLength = cbcCipher.processBlock(data, offset, returnData, offset);
+				offset += processedBytesLength;
+			} catch (Exception e) {
+				e.printStackTrace();
+				break;
+			}
+		}
+
+		return returnData;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java
Sun Oct 17 06:47:53 2004
@@ -0,0 +1,43 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.kerberos.crypto.encryption;
+
+import org.apache.kerberos.crypto.checksum.*;
+
+public class Des3CbcMd5Encryption extends Des3CbcEncryption {
+
+	public EncryptionType encryptionType() {
+		return EncryptionType.DES3_CBC_MD5;
+	}
+
+	public ChecksumType checksumType() {
+		return ChecksumType.RSA_MD5;
+	}
+
+	public int confounderSize() {
+		return 8;
+	}
+
+	public int checksumSize() {
+		return 16;
+	}
+	
+	public int minimumPadSize() {
+		return 0;
+	}
+}
+

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java
Sun Oct 17 06:47:53 2004
@@ -0,0 +1,43 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.kerberos.crypto.encryption;
+
+import org.apache.kerberos.crypto.checksum.*;
+
+public class Des3CbcSha1Encryption extends Des3CbcEncryption {
+
+	public EncryptionType encryptionType() {
+		return EncryptionType.DES3_CBC_SHA1;
+	}
+
+	public ChecksumType checksumType() {
+		return ChecksumType.SHA1;
+	}
+
+	public int confounderSize() {
+		return 8;
+	}
+
+	public int checksumSize() {
+		return 16;
+	}
+	
+	public int minimumPadSize() {
+		return 0;
+	}
+}
+

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/DefaultConfig.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/DefaultConfig.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/DefaultConfig.java
Sun Oct 17 06:47:53 2004
@@ -24,19 +24,20 @@
 public class DefaultConfig {
 	
     // Default inet port
-	public static final int KDC_INET_DEFAULT_PORT   = 88;
+	public static final int KDC_INET_DEFAULT_PORT    = 88;
     // Default server name
-	public static final String TGS_DEFAULT_SRV_NAME = "krbtgt";
+	public static final String TGS_DEFAULT_SRV_NAME  = "krbtgt";
 	// Default NT
-	public static final int TGS_DEFAULT_NT          = PrincipalName.KRB_NT_SRV_INST;
+	public static final int TGS_DEFAULT_NT           = PrincipalName.KRB_NT_SRV_INST;
 	
-    public static final ReplayCache REPLAY_CACHE    = new InMemoryReplayCache();
+    public static final ReplayCache REPLAY_CACHE     = new InMemoryReplayCache();
     
     // Default encryption type
-	public static final EncryptionType DEFAULT_ETYPE        = EncryptionType.DES_CBC_MD5;
+	public static final EncryptionType DEFAULT_ETYPE = EncryptionType.DES_CBC_MD5;
 
     // Default encryption type list 
 	public static final EncryptionType[] DEFAULT_ETYPE_LIST = { EncryptionType.DES_CBC_MD5,
+			EncryptionType.DES3_CBC_SHA1, EncryptionType.DES3_CBC_MD5,
 			EncryptionType.DES_CBC_MD4,	EncryptionType.DES_CBC_CRC
 	};
 	

Mime
View raw message