directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1043147 - in /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption: CipherTextHandler.java EncryptionEngine.java
Date Tue, 07 Dec 2010 17:56:52 GMT
Author: elecharny
Date: Tue Dec  7 17:56:52 2010
New Revision: 1043147

URL: http://svn.apache.org/viewvc?rev=1043147&view=rev
Log:
o Using System.arraycopy instead of loops
o some minor code clarification

Modified:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/EncryptionEngine.java

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java?rev=1043147&r1=1043146&r2=1043147&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/CipherTextHandler.java
Tue Dec  7 17:56:52 2010
@@ -26,13 +26,13 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 import org.apache.directory.shared.asn1.AbstractAsn1Object;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
 import org.apache.directory.shared.kerberos.exceptions.ErrorType;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 
 
 /**
@@ -75,7 +75,8 @@ public class CipherTextHandler
         {
             int bufferSize = message.computeLength();
             ByteBuffer buffer = ByteBuffer.allocate( bufferSize );
-            return encrypt( key, message.encode( buffer ).array(), usage );
+            byte[] encoded = message.encode( buffer ).array();
+            return encrypt( key, encoded, usage );
         }
         catch ( EncoderException ioe )
         {

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/EncryptionEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/EncryptionEngine.java?rev=1043147&r1=1043146&r2=1043147&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/EncryptionEngine.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/EncryptionEngine.java
Tue Dec  7 17:56:52 2010
@@ -22,10 +22,10 @@ package org.apache.directory.server.kerb
 
 import java.security.SecureRandom;
 
-import org.apache.directory.shared.kerberos.exceptions.KerberosException;
-import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
 
 
 /**
@@ -138,17 +138,12 @@ public abstract class EncryptionEngine
     // Encryption
     protected byte[] concatenateBytes( byte[] array1, byte[] array2 )
     {
-        byte concatenatedBytes[] = new byte[array1.length + array2.length];
+        int l1 = array1.length;
+        int l2 = array2.length;
+        byte concatenatedBytes[] = new byte[l1 + l2];
 
-        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];
-        }
+        System.arraycopy( array1, 0, concatenatedBytes, 0, l1 );
+        System.arraycopy( array2, 0, concatenatedBytes, l1, l2 );
 
         return concatenatedBytes;
     }



Mime
View raw message