Author: toad
Date: 2006-01-05 18:56:15 +0000 (Thu, 05 Jan 2006)
New Revision: 7759
Modified:
trunk/freenet/src/freenet/keys/ClientCHKBlock.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:
313:
Lots more work on SSKs at key level. More or less finished with that level.
Next is request/insert level.
After that, testing!
Modified: trunk/freenet/src/freenet/keys/ClientCHKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/ClientCHKBlock.java 2006-01-05 18:22:00 UTC
(rev 7758)
+++ trunk/freenet/src/freenet/keys/ClientCHKBlock.java 2006-01-05 18:56:15 UTC
(rev 7759)
@@ -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, output, bf, maxLength,
key.compressionAlgorithm, Math.min(maxLength, MAX_LENGTH_BEFORE_COMPRESSION));
+ return Key.decompress(key.isCompressed(), output, bf,
Math.min(maxLength, MAX_LENGTH_BEFORE_COMPRESSION), key.compressionAlgorithm);
}
/**
Modified: trunk/freenet/src/freenet/keys/ClientSSKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/ClientSSKBlock.java 2006-01-05 18:22:00 UTC
(rev 7758)
+++ trunk/freenet/src/freenet/keys/ClientSSKBlock.java 2006-01-05 18:56:15 UTC
(rev 7759)
@@ -12,6 +12,8 @@
static final int DATA_DECRYPT_KEY_LENGTH = 32;
+ static final int MAX_DECOMPRESSED_DATA_LENGTH = 32768;
+
/** Is metadata. Set on decode. */
private boolean isMetadata;
/** Has decoded? */
@@ -69,11 +71,10 @@
dataOutput = realDataOutput;
}
short compressionAlgorithm =
(short)(((decryptedHeaders[DATA_DECRYPT_KEY_LENGTH+2] & 0xff) << 8) +
(decryptedHeaders[DATA_DECRYPT_KEY_LENGTH+3] & 0xff));
-
-
- decoded = true;
- // TODO Auto-generated method stub
- return null;
+
+ Bucket b = Key.decompress(compressionAlgorithm >= 0, dataOutput,
factory, Math.min(MAX_DECOMPRESSED_DATA_LENGTH, maxLength),
compressionAlgorithm);
+ decoded = true;
+ return b;
}
public boolean isMetadata() {
Modified: trunk/freenet/src/freenet/keys/Key.java
===================================================================
--- trunk/freenet/src/freenet/keys/Key.java 2006-01-05 18:22:00 UTC (rev
7758)
+++ trunk/freenet/src/freenet/keys/Key.java 2006-01-05 18:56:15 UTC (rev
7759)
@@ -90,15 +90,15 @@
return hash;
}
- static Bucket decompress(ClientCHK key, byte[] output, BucketFactory bf,
int maxLength, short compressionAlgorithm, int maxDecompressedLength) throws
CHKDecodeException, IOException {
- if(key.isCompressed()) {
- Logger.minor(key, "Decompressing in decode: "+key.getURI()+"
with codec "+compressionAlgorithm);
+ static Bucket decompress(boolean isCompressed, byte[] output,
BucketFactory bf, int maxLength, short compressionAlgorithm) 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");
// Decompress
// First get the length
int len = ((((((output[0] & 0xff) << 8) + (output[1] & 0xff)) <<
8) + (output[2] & 0xff)) << 8) +
(output[3] & 0xff);
- if(len > maxDecompressedLength)
+ if(len > maxLength)
throw new CHKDecodeException("Invalid precompressed size:
"+len);
Compressor decompressor =
Compressor.getCompressionAlgorithmByMetadataID(compressionAlgorithm);
Bucket inputBucket = new SimpleReadOnlyArrayBucket(output, 4,
output.length-4);
Modified: trunk/freenet/src/freenet/keys/SSKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/SSKBlock.java 2006-01-05 18:22:00 UTC
(rev 7758)
+++ trunk/freenet/src/freenet/keys/SSKBlock.java 2006-01-05 18:56:15 UTC
(rev 7759)
@@ -26,8 +26,8 @@
/* HEADERS FORMAT:
* 2 bytes - hash ID
* SIGNATURE ON THE BELOW HASH:
- * 20 bytes - signature: R (unsigned bytes)
- * 20 bytes - signature: S (unsigned bytes)
+ * 32 bytes - signature: R (unsigned bytes)
+ * 32 bytes - signature: S (unsigned bytes)
* IMPLICIT - hash of remaining fields, including the implicit hash of
data
* IMPLICIT - hash of data
* 2 bytes - symmetric cipher ID
@@ -48,8 +48,8 @@
static final short DATA_LENGTH = 1024;
- static final short SIG_R_LENGTH = 20;
- static final short SIG_S_LENGTH = 20;
+ static final short SIG_R_LENGTH = 32;
+ static final short SIG_S_LENGTH = 32;
static final short E_H_DOCNAME_LENGTH = 32;
/**
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-05 18:22:00 UTC (rev
7758)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-05 18:56:15 UTC (rev
7759)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 312;
+ public static final int buildNumber = 313;
/** Oldest build of Fred we will talk to */
public static final int lastGoodBuild = 310;