directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r233997 - in /directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto: ./ checksum/ encryption/
Date Sat, 20 Aug 2005 04:42:53 GMT
Author: erodriguez
Date: Fri Aug 19 21:42:45 2005
New Revision: 233997

URL: http://svn.apache.org/viewcvs?rev=233997&view=rev
Log:
Reformatting:  imports, whitespace, line breaks, or code convention.

Modified:
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/DesStringToKey.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/RandomKey.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumEngine.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Crc32Checksum.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd4Checksum.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd5Checksum.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Sha1Checksum.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/CipherType.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcCrcEncryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcEncryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd4Encryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd5Encryption.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngine.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngineFactory.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionType.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/NullEncryption.java

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/DesStringToKey.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/DesStringToKey.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/DesStringToKey.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/DesStringToKey.java Fri Aug 19 21:42:45 2005
@@ -16,158 +16,192 @@
  */
 package org.apache.kerberos.crypto;
 
-import org.bouncycastle.crypto.engines.*;
-import org.bouncycastle.crypto.modes.*;
-import org.bouncycastle.crypto.params.*;
-
-public class DesStringToKey {
-	
-	private byte[] _desKey;
-	
-	public DesStringToKey(String passPhrase) {
-		_desKey = generateKey(passPhrase);
-	}
-	
-	// This is the concatenation order as designated in RFC 1510
-	public DesStringToKey(String password, String realmName, String userName) {
-		_desKey = generateKey(password + realmName + userName);
-	}
-	
-	public byte[] getKey() {
-		return _desKey;
-	}
-	
-	private byte[] generateKey(String passPhrase) {
-
-		byte encodedByteArray[] = characterEncodeString(passPhrase);
-
-		byte paddedByteArray[] = padString(encodedByteArray);
-
-		byte secretKey[] = fanFold(paddedByteArray);
-		
-		DESParameters.setOddParity(secretKey);
-		
-		if (DESParameters.isWeakKey(secretKey, 0))
-			secretKey = getStrongKey(secretKey);
-
-		secretKey = encryptSecretKey(paddedByteArray, secretKey);
-
-		DESParameters.setOddParity(secretKey);
-
-		if (DESParameters.isWeakKey(secretKey, 0))
-			secretKey = getStrongKey(secretKey);
-		
-		return secretKey;
-	}
-
-	private byte[] fanFold(byte[] paddedByteArray) {
-		
-		byte secretKey[] = new byte[8];
-		
-		int i = paddedByteArray.length / 8;
-
-		for (int x = 0; x < i; x++) {
-			byte blockValue1[] = new byte[8];
-			System.arraycopy(paddedByteArray, x * 8, blockValue1, 0, 8);
-
-			if (x % 2 == 1) {
-				byte tempbyte1 = 0;
-				byte tempbyte2 = 0;
-				byte blockValue2[] = new byte[8];
-
-				for (int y = 0; y < 8; y++) {
-					tempbyte2 = 0;
-					for (int z = 0; z < 4; z++) {
-						tempbyte2 = (byte) ((1 << (7 - z)) & 0xff);
-						tempbyte1 |= (blockValue1[y] & tempbyte2) >>> (7 - 2 * z);
-						tempbyte2 = 0;
-					}
-					for (int z = 4; z < 8; z++) {
-						tempbyte2 = (byte) ((1 << (7 - z)) & 0xff);
-						tempbyte1 |= (blockValue1[y] & tempbyte2) << (2 * z - 7);
-						tempbyte2 = 0;
-					}
-					blockValue2[7 - y] = tempbyte1;
-					tempbyte1 = 0;
-				}
-
-				for (int a = 0; a < 8; a++)
-					blockValue2[a] = (byte) (((blockValue2[a] & 0xff) >>> 1) & 0xff);
-
-				System.arraycopy(blockValue2, 0, blockValue1, 0, blockValue2.length);
-			}
-
-			for (int a = 0; a < 8; a++)
-				blockValue1[a] = (byte) (((blockValue1[a] & 0xff) << 1) & 0xff);
-			
-			// ... eXclusive-ORed with itself to form an 8-byte DES key
-			for (int b = 0; b < 8; b++)
-				secretKey[b] ^= blockValue1[b];
-		}
-		return secretKey;
-	}
-	
-	// TODO - Re-evaluate when DES3 keys are supported.  This is duplicated
-	//        with parts of CryptoService, but makes this class standalone.
-	private byte[] encryptSecretKey(byte data[], byte key[]) {
-		
-		CBCBlockCipher cipher = new CBCBlockCipher(new DESEngine());
-		KeyParameter kp = new KeyParameter(key);
-		ParametersWithIV iv;
-		
-		iv = new ParametersWithIV(kp, key);
-		cipher.init(true, iv);
-
-		byte encKey[] = new byte[data.length];
-		byte ivBytes[] = new byte[8];
-
-		for (int x = 0; x < data.length / 8; x++) {
-			cipher.processBlock(data, x * 8, encKey, x * 8);
-			System.arraycopy(encKey, x * 8, ivBytes, 0, 8);
-			iv = new ParametersWithIV(kp, ivBytes);
-			cipher.init(true, iv);
-		}
-
-		return ivBytes;
-	}
-
-	// Corrects the weak key by exclusive OR with 0xF0 constant.
-	private byte[] getStrongKey(byte keyValue[]) {
-		keyValue[7] ^= 0xf0;
-		return keyValue;
-	}
-
-	// Encodes string with ISO-Latin encoding
-	private byte[] characterEncodeString(String str) {
-		byte encodedByteArray[] = new byte[str.length()];
-		try {
-			encodedByteArray = str.getBytes("8859_1");
-		} catch (java.io.UnsupportedEncodingException ue) {
-		}
-		return encodedByteArray;
-	}
-
-	// Add padding to make an exact multiple of 8.
-	// TODO - Re-evaluate when DES3 keys are supported.  This is duplicated
-	//        with parts of CryptoService, but makes this class standalone.
-	private byte[] padString(byte encodedString[]) {
-		int x;
-		if (encodedString.length < 8)
-			x = encodedString.length;
-		else
-			x = encodedString.length % 8;
-
-		if (x == 0)
-			return encodedString;
-
-		byte paddedByteArray[] = new byte[(8 - x) + encodedString.length];
-		for (int y = paddedByteArray.length - 1; y > encodedString.length - 1; y--)
-			paddedByteArray[y] = 0;
+import org.bouncycastle.crypto.engines.DESEngine;
+import org.bouncycastle.crypto.modes.CBCBlockCipher;
+import org.bouncycastle.crypto.params.DESParameters;
+import org.bouncycastle.crypto.params.KeyParameter;
+import org.bouncycastle.crypto.params.ParametersWithIV;
+
+public class DesStringToKey
+{
+    private byte[] desKey;
+
+    public DesStringToKey( String passPhrase )
+    {
+        desKey = generateKey( passPhrase );
+    }
+
+    // This is the concatenation order as designated in RFC 1510
+    public DesStringToKey( String password, String realmName, String userName )
+    {
+        desKey = generateKey( password + realmName + userName );
+    }
+
+    public byte[] getKey()
+    {
+        return desKey;
+    }
+
+    private byte[] generateKey( String passPhrase )
+    {
+        byte encodedByteArray[] = characterEncodeString( passPhrase );
+
+        byte paddedByteArray[] = padString( encodedByteArray );
+
+        byte secretKey[] = fanFold( paddedByteArray );
+
+        DESParameters.setOddParity( secretKey );
+
+        if ( DESParameters.isWeakKey( secretKey, 0 ) )
+        {
+            secretKey = getStrongKey( secretKey );
+        }
+
+        secretKey = encryptSecretKey( paddedByteArray, secretKey );
+
+        DESParameters.setOddParity( secretKey );
+
+        if ( DESParameters.isWeakKey( secretKey, 0 ) )
+        {
+            secretKey = getStrongKey( secretKey );
+        }
+
+        return secretKey;
+    }
+
+    private byte[] fanFold( byte[] paddedByteArray )
+    {
+        byte secretKey[] = new byte[ 8 ];
+
+        int i = paddedByteArray.length / 8;
+
+        for ( int x = 0; x < i; x++ )
+        {
+            byte blockValue1[] = new byte[ 8 ];
+            System.arraycopy( paddedByteArray, x * 8, blockValue1, 0, 8 );
+
+            if ( x % 2 == 1 )
+            {
+                byte tempbyte1 = 0;
+                byte tempbyte2 = 0;
+                byte blockValue2[] = new byte[ 8 ];
+
+                for ( int y = 0; y < 8; y++ )
+                {
+                    tempbyte2 = 0;
+                    for ( int z = 0; z < 4; z++ )
+                    {
+                        tempbyte2 = (byte) ( ( 1 << ( 7 - z ) ) & 0xff );
+                        tempbyte1 |= ( blockValue1[ y ] & tempbyte2 ) >>> ( 7 - 2 * z );
+                        tempbyte2 = 0;
+                    }
+                    for ( int z = 4; z < 8; z++ )
+                    {
+                        tempbyte2 = (byte) ( ( 1 << ( 7 - z ) ) & 0xff );
+                        tempbyte1 |= ( blockValue1[ y ] & tempbyte2 ) << ( 2 * z - 7 );
+                        tempbyte2 = 0;
+                    }
+                    blockValue2[ 7 - y ] = tempbyte1;
+                    tempbyte1 = 0;
+                }
+
+                for ( int a = 0; a < 8; a++ )
+                {
+                    blockValue2[ a ] = (byte) ( ( ( blockValue2[ a ] & 0xff ) >>> 1 ) & 0xff );
+                }
+
+                System.arraycopy( blockValue2, 0, blockValue1, 0, blockValue2.length );
+            }
+
+            for ( int a = 0; a < 8; a++ )
+            {
+                blockValue1[ a ] = (byte) ( ( ( blockValue1[ a ] & 0xff ) << 1 ) & 0xff );
+            }
+
+            // ... eXclusive-ORed with itself to form an 8-byte DES key
+            for ( int b = 0; b < 8; b++ )
+            {
+                secretKey[ b ] ^= blockValue1[ b ];
+            }
+        }
+        return secretKey;
+    }
+
+    // TODO - Re-evaluate when DES3 keys are supported.  This is duplicated
+    //        with parts of CryptoService, but makes this class standalone.
+    private byte[] encryptSecretKey( byte data[], byte key[] )
+    {
+        CBCBlockCipher cipher = new CBCBlockCipher( new DESEngine() );
+        KeyParameter kp = new KeyParameter( key );
+        ParametersWithIV iv;
+
+        iv = new ParametersWithIV( kp, key );
+        cipher.init( true, iv );
+
+        byte encKey[] = new byte[ data.length ];
+        byte ivBytes[] = new byte[ 8 ];
+
+        for ( int x = 0; x < data.length / 8; x++ )
+        {
+            cipher.processBlock( data, x * 8, encKey, x * 8 );
+            System.arraycopy( encKey, x * 8, ivBytes, 0, 8 );
+            iv = new ParametersWithIV( kp, ivBytes );
+            cipher.init( true, iv );
+        }
+
+        return ivBytes;
+    }
+
+    // Corrects the weak key by exclusive OR with 0xF0 constant.
+    private byte[] getStrongKey( byte keyValue[] )
+    {
+        keyValue[ 7 ] ^= 0xf0;
+        return keyValue;
+    }
+
+    // Encodes string with ISO-Latin encoding
+    private byte[] characterEncodeString( String str )
+    {
+        byte encodedByteArray[] = new byte[ str.length() ];
+        try
+        {
+            encodedByteArray = str.getBytes( "8859_1" );
+        }
+        catch ( java.io.UnsupportedEncodingException ue )
+        {
+        }
+        return encodedByteArray;
+    }
+
+    // Add padding to make an exact multiple of 8.
+    // TODO - Re-evaluate when DES3 keys are supported.  This is duplicated
+    //        with parts of CryptoService, but makes this class standalone.
+    private byte[] padString( byte encodedString[] )
+    {
+        int x;
+        if ( encodedString.length < 8 )
+        {
+            x = encodedString.length;
+        }
+        else
+        {
+            x = encodedString.length % 8;
+        }
+
+        if ( x == 0 )
+        {
+            return encodedString;
+        }
+
+        byte paddedByteArray[] = new byte[ ( 8 - x ) + encodedString.length ];
+
+        for ( int y = paddedByteArray.length - 1; y > encodedString.length - 1; y-- )
+        {
+            paddedByteArray[ y ] = 0;
+        }
 
-		System.arraycopy(encodedString, 0, paddedByteArray, 0, encodedString.length);
+        System.arraycopy( encodedString, 0, paddedByteArray, 0, encodedString.length );
 
-		return paddedByteArray;
-
-	}
+        return paddedByteArray;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/RandomKey.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/RandomKey.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/RandomKey.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/RandomKey.java Fri Aug 19 21:42:45 2005
@@ -16,44 +16,44 @@
  */
 package org.apache.kerberos.crypto;
 
-import org.apache.kerberos.crypto.encryption.EncryptionType;
-import org.apache.kerberos.messages.value.EncryptionKey;
+import java.security.SecureRandom;
 
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
-import java.security.SecureRandom;
+
+import org.apache.kerberos.crypto.encryption.EncryptionType;
+import org.apache.kerberos.messages.value.EncryptionKey;
 
 public class RandomKey
 {
     private static final SecureRandom random = new SecureRandom();
 
-	public EncryptionKey getNewSessionKey()
+    public EncryptionKey getNewSessionKey()
     {
-		byte[] confounder = getRandomBytes( 8 );
-		DesStringToKey subSessionKey = new DesStringToKey(new String(confounder));
+        byte[] confounder = getRandomBytes( 8 );
+        DesStringToKey subSessionKey = new DesStringToKey( new String( confounder ) );
 
-		return new EncryptionKey(EncryptionType.DES_CBC_MD5, subSessionKey.getKey());
-	}
+        return new EncryptionKey( EncryptionType.DES_CBC_MD5, subSessionKey.getKey() );
+    }
 
-    public static KerberosKey getRandomKeyFor(KerberosPrincipal principal)
+    public static KerberosKey getRandomKeyFor( KerberosPrincipal principal )
     {
         final int DES_KEY_TYPE = 3;
-		int keyVersion = 1;
+        int keyVersion = 1;
 
-		byte[] randomBytes = getRandomBytes( 8 );
-		DesStringToKey randomKey = new DesStringToKey( new String( randomBytes ) );
+        byte[] randomBytes = getRandomBytes( 8 );
+        DesStringToKey randomKey = new DesStringToKey( new String( randomBytes ) );
 
-		return new KerberosKey( principal, randomKey.getKey(), DES_KEY_TYPE, keyVersion );
+        return new KerberosKey( principal, randomKey.getKey(), DES_KEY_TYPE, keyVersion );
     }
 
-    private static byte[] getRandomBytes(int size)
+    private static byte[] getRandomBytes( int size )
     {
-        byte[] bytes = new byte[size];
+        byte[] bytes = new byte[ size ];
 
         // SecureRandom.nextBytes is already synchronized
-        random.nextBytes(bytes);
+        random.nextBytes( bytes );
 
         return bytes;
     }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumEngine.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumEngine.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumEngine.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumEngine.java Fri Aug 19 21:42:45 2005
@@ -22,24 +22,23 @@
 public abstract class ChecksumEngine
 {
     public abstract Digest getDigest();
-	public abstract ChecksumType checksumType();
-	public abstract CipherType keyType();
-	public abstract int checksumSize();
-	public abstract int keySize();
-	public abstract int confounderSize();
-	public abstract boolean isSafe();
-	public abstract byte[] calculateKeyedChecksum( byte[] data, byte[] key );
-	public abstract boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum );
+    public abstract ChecksumType checksumType();
+    public abstract CipherType keyType();
+    public abstract int checksumSize();
+    public abstract int keySize();
+    public abstract int confounderSize();
+    public abstract boolean isSafe();
+    public abstract byte[] calculateKeyedChecksum( byte[] data, byte[] key );
+    public abstract boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum );
 
     public byte[] calculateChecksum( byte[] data )
     {
         Digest digester = getDigest();
 
-		digester.reset();
-		digester.update( data, 0, data.length );
-		byte[] returnValue = new byte[ digester.getDigestSize() ];
-		digester.doFinal( returnValue, 0 );
-		return returnValue;
-	}
+        digester.reset();
+        digester.update( data, 0, data.length );
+        byte[] returnValue = new byte[ digester.getDigestSize() ];
+        digester.doFinal( returnValue, 0 );
+        return returnValue;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/ChecksumType.java Fri Aug 19 21:42:45 2005
@@ -42,47 +42,48 @@
 
 	public String toString()
     {
-		return _fName;
-	}
+        return name;
+    }
 
-	public int compareTo( Object that )
+    public int compareTo( Object that )
     {
-		return _fOrdinal - ((ChecksumType) that)._fOrdinal;
-	}
+        return ordinal - ( (ChecksumType) that ).ordinal;
+    }
 
-	public static ChecksumType getTypeByOrdinal( int type )
+    public static ChecksumType getTypeByOrdinal( int type )
     {
-		for (int i = 0; i < fValues.length; i++)
-			if (fValues[i]._fOrdinal == type)
-				return fValues[i];
-		return NULL;
-	}
-	
-	public int getOrdinal()
+        for ( int i = 0; i < values.length; i++ )
+        {
+            if ( values[ i ].ordinal == type ) return values[ i ];
+        }
+        
+        return NULL;
+    }
+
+    public int getOrdinal()
     {
-		return _fOrdinal;
-	}
+        return ordinal;
+    }
 
-	/// PRIVATE /////
-	private final String _fName;
-	private final int    _fOrdinal;
-
-	/**
-	 * Private constructor prevents construction outside of this class.
-	 */
-	private ChecksumType( int ordinal, String name )
+    /// PRIVATE /////
+    private final String name;
+    private final int ordinal;
+
+    /**
+     * Private constructor prevents construction outside of this class.
+     */
+    private ChecksumType( int ordinal, String name )
     {
-        _fOrdinal = ordinal;
-		_fName    = name;
-	}
-
-	/**
-	 * These two lines are all that's necessary to export a List of VALUES.
-	 */
-	private static final ChecksumType[] fValues = {NULL, CRC32, RSA_MD4, RSA_MD4_DES,
-			DES_MAC, DES_MAC_K, RSA_MD4_DES_K, RSA_MD5, RSA_MD5_DES, RSA_MD5_DES3,
-			SHA1, UNKNOWN11, HMAC_SHA1_DES3};
-	// VALUES needs to be located here, otherwise illegal forward reference
-	public static final List VALUES = Collections.unmodifiableList( Arrays.asList(fValues) );
+        this.ordinal = ordinal;
+        this.name = name;
+    }
+
+    /**
+     * These two lines are all that's necessary to export a List of VALUES.
+     */
+    private static final ChecksumType[] values = { NULL, CRC32, RSA_MD4, RSA_MD4_DES, DES_MAC,
+            DES_MAC_K, RSA_MD4_DES_K, RSA_MD5, RSA_MD5_DES, RSA_MD5_DES3, SHA1, UNKNOWN11,
+            HMAC_SHA1_DES3 };
+    // VALUES needs to be located here, otherwise illegal forward reference
+    public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Crc32Checksum.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Crc32Checksum.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Crc32Checksum.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Crc32Checksum.java Fri Aug 19 21:42:45 2005
@@ -16,11 +16,11 @@
  */
 package org.apache.kerberos.crypto.checksum;
 
+import java.util.zip.CRC32;
+
 import org.apache.kerberos.crypto.encryption.CipherType;
 import org.bouncycastle.crypto.Digest;
 
-import java.util.zip.CRC32;
-
 public class Crc32Checksum extends ChecksumEngine
 {
     public Digest getDigest()
@@ -28,45 +28,45 @@
         return new CRC32Digest();
     }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.CRC32;
-	}
+        return ChecksumType.CRC32;
+    }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.NULL;
-	}
+        return CipherType.NULL;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
         return 4;
-	}
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public boolean isSafe()
+    public boolean isSafe()
     {
-		return false;
-	}
+        return false;
+    }
 
-	public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
+    public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
     {
-		return null;
-	}
+        return null;
+    }
 
-	public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
+    public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
     {
-		return false;
-	}
+        return false;
+    }
 
     private class CRC32Digest implements Digest
     {
@@ -97,22 +97,24 @@
             crc32.update( in, inOff, len );
         }
 
-        public int doFinal(byte[] out, int outOff)
+        public int doFinal( byte[] out, int outOff )
         {
-            out = int2octet( (int)crc32.getValue() );
+            out = int2octet( (int) crc32.getValue() );
 
             return 0;
         }
 
         private byte[] int2octet( int value )
         {
-            byte[] bytes = new byte[4];
+            byte[] bytes = new byte[ 4 ];
             int i, shift;
 
-            for (i = 0, shift = 24; i < 4; i++, shift -= 8)
-                bytes[i] = (byte) (0xFF & (value >> shift));
+            for ( i = 0, shift = 24; i < 4; i++, shift -= 8 )
+            {
+                bytes[ i ] = (byte) ( 0xFF & ( value >> shift ) );
+            }
+
             return bytes;
         }
     }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd4Checksum.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd4Checksum.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd4Checksum.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd4Checksum.java Fri Aug 19 21:42:45 2005
@@ -27,44 +27,43 @@
         return new MD4Digest();
     }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.RSA_MD4;
-	}
+        return ChecksumType.RSA_MD4;
+    }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.NULL;
-	}
-	
-	public int checksumSize()
+        return CipherType.NULL;
+    }
+
+    public int checksumSize()
     {
-		return 16;
-	}
+        return 16;
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public boolean isSafe()
+    public boolean isSafe()
     {
-		return false;
-	}
+        return false;
+    }
 
-	public byte[] calculateKeyedChecksum(byte[] data, byte[] key)
+    public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
     {
-		return null;
-	}
+        return null;
+    }
 
-	public boolean verifyKeyedChecksum(byte[] data, byte[] key, byte[] checksum)
+    public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
     {
-		return false;
-	}
+        return false;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd5Checksum.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd5Checksum.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd5Checksum.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/RsaMd5Checksum.java Fri Aug 19 21:42:45 2005
@@ -27,44 +27,43 @@
         return new MD5Digest();
     }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.RSA_MD5;
-	}
+        return ChecksumType.RSA_MD5;
+    }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.NULL;
-	}
+        return CipherType.NULL;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 16;
-	}
+        return 16;
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public boolean isSafe()
+    public boolean isSafe()
     {
-		return false;
-	}
+        return false;
+    }
 
-	public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
+    public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
     {
-		return null;
-	}
+        return null;
+    }
 
-	public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
+    public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
     {
-		return false;
-	}
+        return false;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Sha1Checksum.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Sha1Checksum.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Sha1Checksum.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/checksum/Sha1Checksum.java Fri Aug 19 21:42:45 2005
@@ -27,44 +27,43 @@
         return new SHA1Digest();
     }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.SHA1;
-	}
+        return ChecksumType.SHA1;
+    }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.NULL;
-	}
-	
-	public int checksumSize()
+        return CipherType.NULL;
+    }
+
+    public int checksumSize()
     {
-		return 20;
-	}
+        return 20;
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public boolean isSafe()
+    public boolean isSafe()
     {
-		return false;
-	}
+        return false;
+    }
 
-	public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
+    public byte[] calculateKeyedChecksum( byte[] data, byte[] key )
     {
-		return null;
-	}
+        return null;
+    }
 
-	public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
+    public boolean verifyKeyedChecksum( byte[] data, byte[] key, byte[] checksum )
     {
-		return false;
-	}
+        return false;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/CipherType.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/CipherType.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/CipherType.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/CipherType.java Fri Aug 19 21:42:45 2005
@@ -16,10 +16,12 @@
  */
 package org.apache.kerberos.crypto.encryption;
 
-import java.util.*;
-
-public final class CipherType implements Comparable {
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 
+public final class CipherType implements Comparable
+{
 	/**
 	 * Enumeration elements are constructed once upon class loading.
 	 * Order of appearance here determines the order of compareTo.
@@ -29,38 +31,40 @@
 	public static final CipherType DES3   = new CipherType("DES3");
 	public static final CipherType AES128 = new CipherType("AES128");
 
-	public String toString() {
-		return fName;
-	}
-
-	public int compareTo(Object that) {
-		return fOrdinal - ((CipherType) that).fOrdinal;
-	}
-
-	public CipherType getTypeByOrdinal(int type) {
-		for (int i = 0; i < fValues.length; i++)
-			if (fValues[i].fOrdinal == type)
-				return fValues[i];
-		return NULL;
-	}
-
-	/// PRIVATE /////
-	private final String fName;
-	private static int fNextOrdinal = 0;
-	private final int fOrdinal = fNextOrdinal++;
-
-	/**
-	 * Private constructor prevents construction outside of this class.
-	 */
-	private CipherType(String aName) {
-		fName = aName;
-	}
-
-	/**
-	 * These two lines are all that's necessary to export a List of VALUES.
-	 */
-	private static final CipherType[] fValues = {NULL, DES, DES3, AES128};
-	// VALUES needs to be located here, otherwise illegal forward reference
-	public static final List VALUES = Collections.unmodifiableList(Arrays.asList(fValues));
+	public String toString()
+    {
+        return name;
+    }
+
+    public int compareTo( Object that )
+    {
+        return ordinal - ( (CipherType) that ).ordinal;
+    }
+
+    public CipherType getTypeByOrdinal( int type )
+    {
+        for ( int i = 0; i < values.length; i++ )
+            if ( values[ i ].ordinal == type ) return values[ i ];
+        return NULL;
+    }
+
+    /// PRIVATE /////
+    private final String name;
+    private static int nextOrdinal = 0;
+    private final int ordinal = nextOrdinal++;
+
+    /**
+     * Private constructor prevents construction outside of this class.
+     */
+    private CipherType( String name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * These two lines are all that's necessary to export a List of VALUES.
+     */
+    private static final CipherType[] values = { NULL, DES, DES3, AES128 };
+    // VALUES needs to be located here, otherwise illegal forward reference
+    public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcEncryption.java Fri Aug 19 21:42:45 2005
@@ -26,19 +26,18 @@
         return new DESedeEngine();
     }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.DES3;
-	}
+        return CipherType.DES3;
+    }
 
-	public int blockSize()
+    public int blockSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 24;
-	}
+        return 24;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcMd5Encryption.java Fri Aug 19 21:42:45 2005
@@ -27,29 +27,28 @@
         return new RsaMd5Checksum();
     }
 
-	public EncryptionType encryptionType()
+    public EncryptionType encryptionType()
     {
-		return EncryptionType.DES3_CBC_MD5;
-	}
+        return EncryptionType.DES3_CBC_MD5;
+    }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.RSA_MD5;
-	}
+        return ChecksumType.RSA_MD5;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 16;
-	}
-	
-	public int minimumPadSize()
+        return 16;
+    }
+
+    public int minimumPadSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/Des3CbcSha1Encryption.java Fri Aug 19 21:42:45 2005
@@ -27,29 +27,28 @@
         return new Sha1Checksum();
     }
 
-	public EncryptionType encryptionType()
+    public EncryptionType encryptionType()
     {
-		return EncryptionType.DES3_CBC_SHA1;
-	}
+        return EncryptionType.DES3_CBC_SHA1;
+    }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.SHA1;
-	}
+        return ChecksumType.SHA1;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 20;
-	}
-	
-	public int minimumPadSize()
+        return 20;
+    }
+
+    public int minimumPadSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcCrcEncryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcCrcEncryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcCrcEncryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcCrcEncryption.java Fri Aug 19 21:42:45 2005
@@ -27,34 +27,33 @@
         return new Crc32Checksum();
     }
 
-	public EncryptionType encryptionType()
+    public EncryptionType encryptionType()
     {
-		return EncryptionType.DES_CBC_CRC;
-	}
+        return EncryptionType.DES_CBC_CRC;
+    }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.CRC32;
-	}
+        return ChecksumType.CRC32;
+    }
 
-	public CipherType cipherType()
+    public CipherType cipherType()
     {
-		return CipherType.DES;
-	}
+        return CipherType.DES;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 4;
-	}
+        return 4;
+    }
 
-	public int minimumPadSize()
+    public int minimumPadSize()
     {
-		return 4;
-	}
+        return 4;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcEncryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcEncryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcEncryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcEncryption.java Fri Aug 19 21:42:45 2005
@@ -26,19 +26,18 @@
         return new DESEngine();
     }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.DES;
-	}
+        return CipherType.DES;
+    }
 
-	public int blockSize()
+    public int blockSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 8;
-	}
+        return 8;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd4Encryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd4Encryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd4Encryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd4Encryption.java Fri Aug 19 21:42:45 2005
@@ -27,29 +27,28 @@
         return new RsaMd4Checksum();
     }
 
-	public EncryptionType encryptionType()
+    public EncryptionType encryptionType()
     {
-		return EncryptionType.DES_CBC_MD4;
-	}
+        return EncryptionType.DES_CBC_MD4;
+    }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.RSA_MD4;
-	}
+        return ChecksumType.RSA_MD4;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 16;
-	}
-	
-	public int minimumPadSize()
+        return 16;
+    }
+
+    public int minimumPadSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd5Encryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd5Encryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd5Encryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/DesCbcMd5Encryption.java Fri Aug 19 21:42:45 2005
@@ -27,29 +27,28 @@
         return new RsaMd5Checksum();
     }
 
-	public EncryptionType encryptionType()
+    public EncryptionType encryptionType()
     {
-		return EncryptionType.DES_CBC_MD5;
-	}
+        return EncryptionType.DES_CBC_MD5;
+    }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.RSA_MD5;
-	}
+        return ChecksumType.RSA_MD5;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 8;
-	}
+        return 8;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 16;
-	}
-	
-	public int minimumPadSize()
+        return 16;
+    }
+
+    public int minimumPadSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngine.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngine.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngine.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngine.java Fri Aug 19 21:42:45 2005
@@ -31,147 +31,167 @@
 public abstract class EncryptionEngine
 {
     private static final SecureRandom random = new SecureRandom();
-
     public abstract ChecksumEngine getChecksumEngine();
     public abstract BlockCipher getBlockCipher();
-
-	public abstract EncryptionType encryptionType();
-	public abstract ChecksumType checksumType();
-	public abstract CipherType keyType();
-	public abstract int confounderSize();
-	public abstract int checksumSize();
-	public abstract int blockSize();
-	public abstract int minimumPadSize();
-	public abstract int keySize();
+    public abstract EncryptionType encryptionType();
+    public abstract ChecksumType checksumType();
+    public abstract CipherType keyType();
+    public abstract int confounderSize();
+    public abstract int checksumSize();
+    public abstract int blockSize();
+    public abstract int minimumPadSize();
+    public abstract int keySize();
 
     public byte[] getDecryptedData( EncryptionKey key, EncryptedData data )
             throws KerberosException
     {
-		byte[] decryptedData = decrypt( data.getCipherText(), key.getKeyValue() );
+        byte[] decryptedData = decrypt( data.getCipherText(), key.getKeyValue() );
 
-		return removeBytes( decryptedData, confounderSize(), checksumSize() );
-	}
+        return removeBytes( decryptedData, confounderSize(), checksumSize() );
+    }
 
     public EncryptedData getEncryptedData( EncryptionKey key, byte[] plainText )
-			throws KerberosException
+            throws KerberosException
     {
-		byte[] conFounder      = getRandomBytes(confounderSize());
-		byte[] zeroedChecksum  = new byte[checksumSize()];
-        byte[] paddedPlainText = padString(plainText);
-		byte[] dataBytes       = concatenateBytes(conFounder, concatenateBytes(zeroedChecksum, paddedPlainText));
-		byte[] checksumBytes   = calculateChecksum(dataBytes);
-		byte[] paddedDataBytes = padString(dataBytes);
+        byte[] conFounder = getRandomBytes( confounderSize() );
+        byte[] zeroedChecksum = new byte[ checksumSize() ];
+        byte[] paddedPlainText = padString( plainText );
+        byte[] dataBytes = concatenateBytes( conFounder, concatenateBytes( zeroedChecksum,
+                paddedPlainText ) );
+        byte[] checksumBytes = calculateChecksum( dataBytes );
+        byte[] paddedDataBytes = padString( dataBytes );
 
         // lay the checksum into the ciphertext
-		for (int i = confounderSize(); i < confounderSize() + checksumSize(); i++)
+        for ( int i = confounderSize(); i < confounderSize() + checksumSize(); i++ )
         {
-			paddedDataBytes[i] = checksumBytes[i - confounderSize()];
+            paddedDataBytes[ i ] = checksumBytes[ i - confounderSize() ];
         }
 
-		byte[] encryptedData = encrypt(paddedDataBytes, key.getKeyValue());
+        byte[] encryptedData = encrypt( paddedDataBytes, key.getKeyValue() );
 
-		return new EncryptedData( encryptionType(), key.getKeyVersion(), encryptedData );
-	}
+        return new EncryptedData( encryptionType(), key.getKeyVersion(), encryptedData );
+    }
 
     private byte[] encrypt( byte[] data, byte[] key )
     {
-		return processBlockCipher( true, data, key, null );
-	}
+        return processBlockCipher( true, data, key, null );
+    }
 
-	private byte[] decrypt( byte[] data, byte[] key )
+    private byte[] decrypt( byte[] data, byte[] key )
     {
-		return processBlockCipher( false, data, key, null );
-	}
+        return processBlockCipher( false, data, key, null );
+    }
 
     private byte[] getRandomBytes( int size )
     {
-        byte[] bytes = new byte[size];
+        byte[] bytes = new byte[ size ];
 
         // SecureRandom.nextBytes is already synchronized
-        random.nextBytes(bytes);
+        random.nextBytes( bytes );
 
         return bytes;
     }
 
-   	private byte[] padString( byte encodedString[] )
+    private byte[] padString( byte encodedString[] )
     {
-		int x;
-		if (encodedString.length < 8)
-			x = encodedString.length;
-		else
-			x = encodedString.length % 8;
+        int x;
+        if ( encodedString.length < 8 )
+        {
+            x = encodedString.length;
+        }
+        else
+        {
+            x = encodedString.length % 8;
+        }
 
-		if (x == 0)
-			return encodedString;
+        if ( x == 0 )
+        {
+            return encodedString;
+        }
 
-		byte paddedByteArray[] = new byte[(8 - x) + encodedString.length];
-		for (int y = paddedByteArray.length - 1; y > encodedString.length - 1; y--)
-			paddedByteArray[y] = 0;
+        byte paddedByteArray[] = new byte[ ( 8 - x ) + encodedString.length ];
+        
+        for ( int y = paddedByteArray.length - 1; y > encodedString.length - 1; y-- )
+        {
+            paddedByteArray[ y ] = 0;
+        }
 
-		System.arraycopy(encodedString, 0, paddedByteArray, 0, encodedString.length);
+        System.arraycopy( encodedString, 0, paddedByteArray, 0, encodedString.length );
 
-		return paddedByteArray;
-	}
+        return paddedByteArray;
+    }
 
-	private byte[] concatenateBytes( byte[] array1, byte[] array2 )
+    private byte[] concatenateBytes( byte[] array1, byte[] array2 )
     {
-		byte concatenatedBytes[] = new byte[array1.length + array2.length];
+        byte concatenatedBytes[] = new byte[ array1.length + array2.length ];
 
-		for (int i = 0; i < array1.length; i++)
-			concatenatedBytes[i] = array1[i];
+        for ( int i = 0; i < array1.length; i++ )
+        {
+            concatenatedBytes[ i ] = array1[ i ];
+        }
 
-		for (int j = array1.length; j < concatenatedBytes.length; j++)
-			concatenatedBytes[j] = array2[j - array1.length];
+        for ( int j = array1.length; j < concatenatedBytes.length; j++ )
+        {
+            concatenatedBytes[ j ] = array2[ j - array1.length ];
+        }
 
-		return concatenatedBytes;
-	}
+        return concatenatedBytes;
+    }
 
     private byte[] calculateChecksum( byte[] data )
     {
-		ChecksumEngine digester = getChecksumEngine();
+        ChecksumEngine digester = getChecksumEngine();
 
-		return digester.calculateChecksum(data);
-	}
+        return digester.calculateChecksum( data );
+    }
 
     private byte[] removeBytes( byte[] array, int confounder, int checksum )
     {
-		byte lessBytes[] = new byte[array.length - confounder - checksum];
+        byte lessBytes[] = new byte[ array.length - confounder - checksum ];
 
-		int j = 0;
-		for (int i = confounder + checksum; i < array.length; i++) {
-			lessBytes[j] = array[i];
-			j++;
-		}
+        int j = 0;
+        for ( int i = confounder + checksum; i < array.length; i++ )
+        {
+            lessBytes[ j ] = array[ i ];
+            j++;
+        }
 
-		return lessBytes;
-	}
+        return lessBytes;
+    }
 
     private byte[] processBlockCipher( boolean encrypt, byte[] data, byte[] key, byte[] ivec )
     {
-		byte[] returnData = new byte[data.length];
-		CBCBlockCipher cbcCipher = new CBCBlockCipher(getBlockCipher());
-		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;
-			}
-		}
+        byte[] returnData = new byte[ data.length ];
+        CBCBlockCipher cbcCipher = new CBCBlockCipher( getBlockCipher() );
+        KeyParameter keyParameter = new KeyParameter( key );
 
-		return returnData;
-	}
-}
+        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;
+    }
+}

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngineFactory.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngineFactory.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngineFactory.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionEngineFactory.java Fri Aug 19 21:42:45 2005
@@ -14,14 +14,12 @@
  *   limitations under the License.
  *
  */
-
 package org.apache.kerberos.crypto.encryption;
 
 import org.apache.kerberos.exceptions.ErrorType;
 import org.apache.kerberos.exceptions.KerberosException;
 import org.apache.kerberos.messages.value.EncryptionKey;
 
-
 public class EncryptionEngineFactory
 {
     public static EncryptionEngine getEncryptionEngineFor( EncryptionKey key )
@@ -48,4 +46,3 @@
         throw new KerberosException( ErrorType.KDC_ERR_ETYPE_NOSUPP );
     }
 }
-

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionType.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionType.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionType.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/EncryptionType.java Fri Aug 19 21:42:45 2005
@@ -58,7 +58,10 @@
     public static EncryptionType getTypeByOrdinal( int type )
     {
         for ( int i = 0; i < values.length; i++ )
+        {
             if ( values[ i ].ordinal == type ) return values[ i ];
+        }
+        
         return NULL;
     }
 

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/NullEncryption.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/NullEncryption.java?rev=233997&r1=233996&r2=233997&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/NullEncryption.java (original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/crypto/encryption/NullEncryption.java Fri Aug 19 21:42:45 2005
@@ -32,54 +32,53 @@
         return null;
     }
 
-	public EncryptionType encryptionType()
+    public EncryptionType encryptionType()
     {
-		return EncryptionType.NULL;
-	}
+        return EncryptionType.NULL;
+    }
 
-	public CipherType keyType()
+    public CipherType keyType()
     {
-		return CipherType.NULL;
-	}
+        return CipherType.NULL;
+    }
 
-	public ChecksumType checksumType()
+    public ChecksumType checksumType()
     {
-		return ChecksumType.NULL;
-	}
+        return ChecksumType.NULL;
+    }
 
-	public int blockSize()
+    public int blockSize()
     {
-		return 1;
-	}
+        return 1;
+    }
 
-	public int keySize()
+    public int keySize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int checksumSize()
+    public int checksumSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int confounderSize()
+    public int confounderSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	public int minimumPadSize()
+    public int minimumPadSize()
     {
-		return 0;
-	}
+        return 0;
+    }
 
-	protected byte[] processBlockCipher(boolean encrypt, byte[] data, byte[] key, byte[] ivec)
+    protected byte[] processBlockCipher( boolean encrypt, byte[] data, byte[] key, byte[] ivec )
     {
-		return data;
-	}
+        return data;
+    }
 
-	public byte[] calculateChecksum(byte[] plainText)
+    public byte[] calculateChecksum( byte[] plainText )
     {
-		return null;
-	}
+        return null;
+    }
 }
-



Mime
View raw message