Author: toad
Date: 2006-01-06 18:35:38 +0000 (Fri, 06 Jan 2006)
New Revision: 7768

Modified:
   trunk/freenet/src/freenet/keys/ClientCHKBlock.java
   trunk/freenet/src/freenet/keys/ClientSSK.java
   trunk/freenet/src/freenet/keys/ClientSSKBlock.java
   trunk/freenet/src/freenet/keys/Key.java
   trunk/freenet/src/freenet/keys/SSKBlock.java
   trunk/freenet/src/freenet/node/Version.java
Log:
322:
Minor SSK-related changes.

Modified: trunk/freenet/src/freenet/keys/ClientCHKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/ClientCHKBlock.java  2006-01-06 12:27:49 UTC 
(rev 7767)
+++ trunk/freenet/src/freenet/keys/ClientCHKBlock.java  2006-01-06 18:35:38 UTC 
(rev 7768)
@@ -131,7 +131,7 @@
         byte[] output = new byte[size];
         // No particular reason to check the padding, is there?
         System.arraycopy(dbuf, 0, output, 0, size);
-        return Key.decompress(key.isCompressed(), output, bf, 
Math.min(maxLength, MAX_LENGTH_BEFORE_COMPRESSION), key.compressionAlgorithm);
+        return Key.decompress(key.isCompressed(), output, bf, 
Math.min(maxLength, MAX_LENGTH_BEFORE_COMPRESSION), key.compressionAlgorithm, 
false);
     }

     /**

Modified: trunk/freenet/src/freenet/keys/ClientSSK.java
===================================================================
--- trunk/freenet/src/freenet/keys/ClientSSK.java       2006-01-06 12:27:49 UTC 
(rev 7767)
+++ trunk/freenet/src/freenet/keys/ClientSSK.java       2006-01-06 18:35:38 UTC 
(rev 7768)
@@ -48,7 +48,6 @@
                } catch (UnsupportedCipherException e) {
                        throw new Error(e);
                }
-               
        }

        public FreenetURI getURI() {

Modified: trunk/freenet/src/freenet/keys/ClientSSKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/ClientSSKBlock.java  2006-01-06 12:27:49 UTC 
(rev 7767)
+++ trunk/freenet/src/freenet/keys/ClientSSKBlock.java  2006-01-06 18:35:38 UTC 
(rev 7768)
@@ -72,7 +72,7 @@
                }
         short compressionAlgorithm = 
(short)(((decryptedHeaders[DATA_DECRYPT_KEY_LENGTH+2] & 0xff) << 8) + 
(decryptedHeaders[DATA_DECRYPT_KEY_LENGTH+3] & 0xff));

-        Bucket b = Key.decompress(compressionAlgorithm >= 0, dataOutput, 
factory, Math.min(MAX_DECOMPRESSED_DATA_LENGTH, maxLength), 
compressionAlgorithm);
+        Bucket b = Key.decompress(compressionAlgorithm >= 0, dataOutput, 
factory, Math.min(MAX_DECOMPRESSED_DATA_LENGTH, maxLength), 
compressionAlgorithm, true);
         decoded = true;
         return b;
        }

Modified: trunk/freenet/src/freenet/keys/Key.java
===================================================================
--- trunk/freenet/src/freenet/keys/Key.java     2006-01-06 12:27:49 UTC (rev 
7767)
+++ trunk/freenet/src/freenet/keys/Key.java     2006-01-06 18:35:38 UTC (rev 
7768)
@@ -90,18 +90,22 @@
         return hash;
     }

-    static Bucket decompress(boolean isCompressed, byte[] output, 
BucketFactory bf, int maxLength, short compressionAlgorithm) throws 
CHKDecodeException, IOException {
+    static Bucket decompress(boolean isCompressed, byte[] output, 
BucketFactory bf, int maxLength, short compressionAlgorithm, boolean 
shortLength) throws CHKDecodeException, IOException {
         if(isCompressed) {
                Logger.minor(Key.class, "Decompressing in decode with codec 
"+compressionAlgorithm);
-            if(output.length < 5) throw new CHKDecodeException("No bytes to 
decompress");
+            if(output.length < (shortLength ? 3 : 5)) throw new 
CHKDecodeException("No bytes to decompress");
             // Decompress
             // First get the length
-            int len = ((((((output[0] & 0xff) << 8) + (output[1] & 0xff)) << 
8) + (output[2] & 0xff)) << 8) +
-               (output[3] & 0xff);
+            int len;
+            if(shortLength)
+               len = ((output[0] & 0xff) << 8) + (output[1] & 0xff);
+            else 
+               len = ((((((output[0] & 0xff) << 8) + (output[1] & 0xff)) << 8) 
+ (output[2] & 0xff)) << 8) +
+                       (output[3] & 0xff);
             if(len > maxLength)
                 throw new CHKDecodeException("Invalid precompressed size: 
"+len);
             Compressor decompressor = 
Compressor.getCompressionAlgorithmByMetadataID(compressionAlgorithm);
-            Bucket inputBucket = new SimpleReadOnlyArrayBucket(output, 4, 
output.length-4);
+            Bucket inputBucket = new SimpleReadOnlyArrayBucket(output, 
shortLength?2:4, output.length-(shortLength?2:4));
             try {
                                return decompressor.decompress(inputBucket, bf, 
maxLength);
                        } catch (CompressionOutputSizeException e) {

Modified: trunk/freenet/src/freenet/keys/SSKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/SSKBlock.java        2006-01-06 12:27:49 UTC 
(rev 7767)
+++ trunk/freenet/src/freenet/keys/SSKBlock.java        2006-01-06 18:35:38 UTC 
(rev 7768)
@@ -1,17 +1,13 @@
 package freenet.keys;

-import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;

 import net.i2p.util.NativeBigInteger;
-
 import freenet.crypt.DSA;
 import freenet.crypt.DSAPublicKey;
 import freenet.crypt.DSASignature;
-import freenet.support.Bucket;
-import freenet.support.BucketFactory;

 /**
  * SSKBlock. Contains a full fetched key. Can do a node-level verification. 
Can 

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-06 12:27:49 UTC (rev 
7767)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-06 18:35:38 UTC (rev 
7768)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       public static final int buildNumber = 321;
+       public static final int buildNumber = 322;

        /** Oldest build of Fred we will talk to */
        public static final int lastGoodBuild = 318;


Reply via email to