[ice4j] r153 committed - Improves validation of incoming FINGERPRINT and MESSAGE-INTEGRITY attr...

ice4j at googlecode.com ice4j at googlecode.com
Tue Apr 27 00:02:16 CEST 2010


Revision: 153
Author: emcho at sip-communicator.org
Date: Mon Apr 26 14:34:03 2010
Log: Improves validation of incoming FINGERPRINT and MESSAGE-INTEGRITY  
attributes
http://code.google.com/p/ice4j/source/detail?r=153

Modified:
  /trunk/src/org/ice4j/attribute/AttributeDecoder.java
  /trunk/src/org/ice4j/attribute/ContentDependentAttribute.java
  /trunk/src/org/ice4j/attribute/FingerprintAttribute.java
  /trunk/src/org/ice4j/attribute/MessageIntegrityAttribute.java

=======================================
--- /trunk/src/org/ice4j/attribute/AttributeDecoder.java	Sun Apr 25  
07:42:55 2010
+++ /trunk/src/org/ice4j/attribute/AttributeDecoder.java	Mon Apr 26  
14:34:03 2010
@@ -132,19 +132,9 @@

          decodedAttribute.setAttributeType(attributeType);

-        if (decodedAttribute instanceof ContentDependentAttribute)
-        {
-             
((ContentDependentAttribute)decodedAttribute).decodeAttributeBody(
-                 bytes, (char)(Attribute.HEADER_LENGTH + offset),
-                 attributeLength,
-                 messageHeadBytes, messageHeadOffset, messageHeadLen );
-        }
-        else
-        {
-            decodedAttribute.decodeAttributeBody(bytes,
+        decodedAttribute.decodeAttributeBody(bytes,
                          (char)(Attribute.HEADER_LENGTH + offset),
                          attributeLength);
-        }

          return decodedAttribute;
      }
=======================================
--- /trunk/src/org/ice4j/attribute/ContentDependentAttribute.java	Sun Apr  
25 07:44:29 2010
+++ /trunk/src/org/ice4j/attribute/ContentDependentAttribute.java	Mon Apr  
26 14:34:03 2010
@@ -33,31 +33,4 @@
       * with the specified <tt>content</tt>.
       */
      public byte[] encode(byte[] content, int offset, int length);
-
-    /**
-     * Sets this attribute's fields according to the message and  
attributeValue
-     * arrays. This method allows the stack to validate the content of  
content
-     * dependent attributes such as the {@link MessageIntegrityAttribute}  
or
-     * the {@link FingerprintAttribute} and hide invalid ones from the
-     * application.
-     *
-     * @param attributeValue a binary array containing this attribute's  
field
-     * values and NOT containing the attribute header.
-     * @param offset the position where attribute values begin (most often
-     * offset is equal to the index of the first byte after length)
-     * @param length the length of the binary array.
-     * @param messageHead the bytes of the message that brought this  
attribute.
-     * @param mhOffset the start of the message that brought this attribute
-     * @param mhLen the length of the message in the messageHead param up  
until
-     * the start of this attribute.
-     *
-     * @throws StunException if attrubteValue contains invalid data.
-     */
-    public void decodeAttributeBody( byte[] attributeValue,
-                                     char offset,
-                                     char length,
-                                     byte[] messageHead,
-                                     char mhOffset,
-                                     char mhLen)
-        throws StunException;
-}
+}
=======================================
--- /trunk/src/org/ice4j/attribute/FingerprintAttribute.java	Mon Apr 26  
14:33:50 2010
+++ /trunk/src/org/ice4j/attribute/FingerprintAttribute.java	Mon Apr 26  
14:34:03 2010
@@ -6,7 +6,6 @@
   */
  package org.ice4j.attribute;

-import java.util.*;
  import java.util.zip.*;

  import org.ice4j.*;
@@ -181,29 +180,20 @@

      /**
       * Sets this attribute's fields according to the message and  
attributeValue
-     * arrays. This method allows the stack to validate the content of  
content
-     * dependent attributes such as the {@link MessageIntegrityAttribute}  
or
-     * the {@link FingerprintAttribute} and hide invalid ones from the
-     * application.
+     * arrays.
       *
       * @param attributeValue a binary array containing this attribute's  
field
       * values and NOT containing the attribute header.
       * @param offset the position where attribute values begin (most often
       * offset is equal to the index of the first byte after length)
       * @param length the length of the binary array.
-     * @param messageHead the bytes of the message that brought this  
attribute.
-     * @param mhOffset the start of the message that brought this attribute
-     * @param mhLen the length of the message in the messageHead param up  
until
       * the start of this attribute.
       *
       * @throws StunException if attrubteValue contains invalid data.
       */
      public void decodeAttributeBody( byte[] attributeValue,
                                       char offset,
-                                     char length,
-                                     byte[] messageHead,
-                                     char mhOffset,
-                                     char mhLen)
+                                     char length)
          throws StunException
      {
          if(length != 4)
@@ -250,43 +240,5 @@

          return xorCRC32;
      }
-
-    /**
-     * Creates a <tt>long</tt> CRC value out of the specified  
<tt>bytes</tt>.
-     *
-     * @param bytes the byte array to convert into a <tt>long</tt>.
-     *
-     * @return the CRC value contained by the <tt>bytes</tt> array.
-     */
-    private long byteArrayToCRC(byte[] bytes)
-    {
-        long crc = ((bytes[0] << 24) & 0xff000000)
-                 + ((bytes[1] << 16) & 0x00ff0000)
-                 + ((bytes[2] << 8)  & 0x0000ff00)
-                 +  (bytes[3]        & 0x000000ff);
-
-        return crc;
-    }
-
-    /**
-     * Always throws an {@link UnsupportedOperationException} since this
-     * attribute should be decoded through the content specific decode  
method.
-     *
-     * @param attributeValue a binary array containing this attribute's
-     * field values and NOT containing the attribute header.
-     * @param offset the position where attribute values begin (most often
-     * offset is equal to the index of the first byte after length)
-     * @param length the length of the binary array.
-     *
-     * @throws UnsupportedOperationException since we are supposed to  
decode
-     * through the content specific decode method.
-     */
-    void decodeAttributeBody(byte[] attributeValue, char offset, char  
length)
-        throws UnsupportedOperationException
-    {
-        throw new UnsupportedOperationException(
-                        "ContentDependentAttributes should be decoded "
-                        +"through the contend-dependent decode method");
-    }
  }

=======================================
--- /trunk/src/org/ice4j/attribute/MessageIntegrityAttribute.java	Mon Apr  
26 14:33:21 2010
+++ /trunk/src/org/ice4j/attribute/MessageIntegrityAttribute.java	Mon Apr  
26 14:34:03 2010
@@ -191,61 +191,22 @@

      /**
       * Sets this attribute's fields according to the message and  
attributeValue
-     * arrays. This method allows the stack to validate the content of  
content
-     * dependent attributes such as the {@link MessageIntegrityAttribute}  
or
-     * the {@link FingerprintAttribute} and hide invalid ones from the
-     * application.
+     * arrays.
       *
       * @param attributeValue a binary array containing this attribute's  
field
       * values and NOT containing the attribute header.
       * @param offset the position where attribute values begin (most often
       * offset is equal to the index of the first byte after length)
       * @param length the length of the binary array.
-     * @param messageHead the bytes of the message that brought this  
attribute.
-     * @param mhOffset the start of the message that brought this attribute
-     * @param mhLen the length of the message in the messageHead param up  
until
       * the start of this attribute.
-     *
-     * @throws StunException if attrubteValue contains invalid data.
       */
      public void decodeAttributeBody( byte[] attributeValue,
                                       char offset,
-                                     char length,
-                                     byte[] messageHead,
-                                     char mhOffset,
-                                     char mhLen)
-        throws StunException
+                                     char length)
      {
          hmacSha1Content = new byte[length];
          System.arraycopy(attributeValue, offset, hmacSha1Content, 0,  
length);
-
-        //we can't check the validity of the attribute here since we don't  
have
-        //the password
-        //todo: we should think of a way to access passwords from here.
-    }
-
-    /**
-     * Always throws an {@link UnsupportedOperationException} since this
-     * attribute should be decoded through the content specific decode  
method.
-     *
-     * @param attributeValue a binary array containing this attribute's
-     * field values and NOT containing the attribute header.
-     * @param offset the position where attribute values begin (most often
-     * offset is equal to the index of the first byte after length)
-     * @param length the length of the binary array.
-     *
-     * @throws UnsupportedOperationException since we are supposed to  
decode
-     * through the content specific decode method.
-     */
-    void decodeAttributeBody(byte[] attributeValue, char offset, char  
length)
-        throws UnsupportedOperationException
-    {
-        throw new UnsupportedOperationException(
-                        "ContentDependentAttributes should be decoded "
-                        +"through the contend-dependent decode method");
-    }
-
-
+    }

      /**
       * Returns a binary representation of this attribute.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: commits-help at sip-communicator.dev.java.net





More information about the commits mailing list