Author: nextgens
Date: 2008-08-06 13:57:25 +0000 (Wed, 06 Aug 2008)
New Revision: 21633
Modified:
trunk/freenet/src/freenet/crypt/Global.java
trunk/freenet/src/freenet/node/NodeCrypto.java
Log:
transmit the dsaGroup-index instead of the dsaGroup itself in
link-setup-references
Do we really need the index to be an int? imho a byte would be sufficient!
Modified: trunk/freenet/src/freenet/crypt/Global.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Global.java 2008-08-06 13:54:44 UTC (rev
21632)
+++ trunk/freenet/src/freenet/crypt/Global.java 2008-08-06 13:57:25 UTC (rev
21633)
@@ -28,7 +28,7 @@
"00b143368abcd51f58d6440d5417399339a4d15bef096a2c5d8e6df44f52d6d379", 16),
new NativeBigInteger( /* g */
"51a45ab670c1c9fd10bd395a6805d33339f5675e4b0d35defc9fa03aa5c2bf4ce9cfcdc256781291bfff6d546e67d47ae4e160f804ca72ec3c5492709f5f80f69e6346dd8d3e3d8433b6eeef63bce7f98574185c6aff161c9b536d76f873137365a4246cf414bfe8049ee11e31373cd0a6558e2950ef095320ce86218f992551cc292224114f3b60146d22dd51f8125c9da0c028126ffa85efd4f4bfea2c104453329cc1268a97e9a835c14e4a9a43c6a1886580e35ad8f1de230e1af32208ef9337f1924702a4514e95dc16f30f0c11e714a112ee84a9d8d6c9bc9e74e336560bb5cd4e91eabf6dad26bf0ca04807f8c31a2fc18ea7d45baab7cc997b53c356",
16));
- static final int GROUP_INDEX_BIG_A = 1;
+ public static final int GROUP_INDEX_BIG_A = 1;
public static final DHGroup /* -- Diffie-Hellman Group A
----------------------------
* For use in internode symmetric-cipher key exchange
*
Modified: trunk/freenet/src/freenet/node/NodeCrypto.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeCrypto.java 2008-08-06 13:54:44 UTC
(rev 21632)
+++ trunk/freenet/src/freenet/node/NodeCrypto.java 2008-08-06 13:57:25 UTC
(rev 21633)
@@ -32,6 +32,7 @@
import freenet.keys.InsertableClientSSK;
import freenet.support.Base64;
import freenet.support.Fields;
+import freenet.support.HexUtil;
import freenet.support.IllegalBase64Exception;
import freenet.support.Logger;
import freenet.support.SimpleFieldSet;
@@ -367,6 +368,10 @@
private byte[] myCompressedRef(boolean setup, boolean heavySetup,
boolean forARK) {
SimpleFieldSet fs = exportPublicFieldSet(setup, heavySetup,
forARK);
+ boolean shouldStripGroup = heavySetup &&
Global.DSAgroupBigA.equals(cryptoGroup);
+ if(shouldStripGroup)
+ fs.removeSubset("dsaGroup");
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DeflaterOutputStream gis;
gis = new DeflaterOutputStream(baos);
@@ -380,9 +385,20 @@
}
byte[] buf = baos.toByteArray();
- byte[] obuf = new byte[buf.length + 1];
- obuf[0] = 1;
- System.arraycopy(buf, 0, obuf, 1, buf.length);
+ byte[] obuf = new byte[buf.length + 1 + (shouldStripGroup ? 4 :
0)];
+ int offset = 0;
+ if(shouldStripGroup) {
+ obuf[offset++] = (byte) (0x02); // 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
+ System.arraycopy(buf, 0, obuf, offset, buf.length);
if(logMINOR)
Logger.minor(this,
"myCompressedRef("+setup+","+heavySetup+") returning "+obuf.length+" bytes");
return obuf;