Author: nextgens
Date: 2008-08-06 16:59:32 +0000 (Wed, 06 Aug 2008)
New Revision: 21637
Modified:
trunk/freenet/src/freenet/node/NodeCrypto.java
trunk/freenet/src/freenet/node/PeerNode.java
Log:
Use a byte instead of 4 (an int)... bugfix to the bitmask
Modified: trunk/freenet/src/freenet/node/NodeCrypto.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeCrypto.java 2008-08-06 16:25:09 UTC
(rev 21636)
+++ trunk/freenet/src/freenet/node/NodeCrypto.java 2008-08-06 16:59:32 UTC
(rev 21637)
@@ -368,6 +368,7 @@
private byte[] myCompressedRef(boolean setup, boolean heavySetup,
boolean forARK) {
SimpleFieldSet fs = exportPublicFieldSet(setup, heavySetup,
forARK);
+ // TODO: we should change that to ((setup || heavySetup) &&
!forARK) when all the nodes have the new code
boolean shouldStripGroup = heavySetup &&
Global.DSAgroupBigA.equals(cryptoGroup);
if(shouldStripGroup)
fs.removeSubset("dsaGroup");
@@ -385,19 +386,18 @@
}
byte[] buf = baos.toByteArray();
- byte[] obuf = new byte[buf.length + 1 + (shouldStripGroup ? 4 :
0)];
+ if(buf.length >= 4096)
+ throw new IllegalStateException("We are attempting to
send a "+buf.length+" bytes big reference!");
+ byte[] obuf = new byte[buf.length + 1 + (shouldStripGroup ? 1 :
0)];
int offset = 0;
if(shouldStripGroup) {
- obuf[offset++] = (byte) (0x02); // compressed noderef -
group
+ obuf[offset++] = 0x3; // compressed noderef - group
int dsaGroupIndex = Global.GROUP_INDEX_BIG_A;
if(logMINOR)
Logger.minor(this, "We are stripping the group
from the reference as it's a known group (groupIndex="+dsaGroupIndex+')');
obuf[offset++] = (byte)(dsaGroupIndex & 0xff);
- obuf[offset++] = (byte)(dsaGroupIndex >>> 8 & 0xff);
- obuf[offset++] = (byte)(dsaGroupIndex >>> 16 & 0xff);
- obuf[offset++] = (byte)(dsaGroupIndex >>> 24 & 0xff);
} else
- obuf[offset++] = 1 & 0xff; // compressed noderef
+ obuf[offset++] = 0x01; // compressed noderef
System.arraycopy(buf, 0, obuf, offset, buf.length);
if(logMINOR)
Logger.minor(this,
"myCompressedRef("+setup+","+heavySetup+") returning "+obuf.length+" bytes");
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2008-08-06 16:25:09 UTC
(rev 21636)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2008-08-06 16:59:32 UTC
(rev 21637)
@@ -2259,14 +2259,15 @@
int firstByte = data[offset];
offset++;
length--;
- if((firstByte & 2) == 2) {
- int groupIndex = Fields.bytesToInt(data, offset);
- offset += 4;
- length -= 4;
+ if((firstByte & 0x2) == 2) {
+ int groupIndex = (data[offset] & 0xff);
+ offset++;
+ length--;
group = Global.getGroup(groupIndex);
if(group == null) throw new FSParseException("Unknown
group number "+groupIndex);
if(logMINOR)
Logger.minor(PeerNode.class, "DSAGroup set to
"+group.fingerprintToString()+ " using the group-index "+groupIndex);
+ System.out.println("group");
}
// Is it compressed?
if((firstByte & 1) == 1) {