Tiny spec incompatibility.

Hezekiah <[email protected]> Thu, 7 Aug 2003 00:34:03 -0400
Newsgroups gmane.comp.security.invisiblenet.iip.devel
Message-ID <[email protected]>
Hi, jrand0m! :)
	You like mail on the list so here it is. :)

	I've been up to more testing between Java and Python i2p code. I found 
another problem. The data structures spec for Payload says:

	"The first 4 bytes make up an Integer specifying the number of bytes in the 
Payload data structure (including these first 4 bytes)."

	I'm not entirely sure why you want the size to include the size of the 4 byte 
integer, but that's what the spec says. Anyway, that's not what the Java code 
does. It gives the size of the Payload data _without_ the size of the 4 byte 
integer (which I think makes more sense, and is consistent with the rest of 
the spec.) Anyway, that's a little incompatibility. Here's a diff of the code 
in Payload.java showing the original code and the changes I think would be 
needed to bring it up to spec.

	(And as a note, I'd rather just change the spec and leave the java code as 
is. I really don't think we need to include the size of the 4 byte integer. 
We don't do that anywhere else.)

	-- Hezekiah
Payload.diff (text/x-diff, 1.5 KB)
*** Payload.java.~1.10.~	Wed Aug  6 23:26:41 2003
--- Payload.java	Thu Aug  7 00:25:40 2003
*************** public class Payload implements DataStru
*** 116,120 ****
      public void readBytes(InputStream in) throws DataFormatException, IOException {
          int size = (int)DataHelper.readLong(in, 4);
!         _encryptedData = new byte[size];
          int read = in.read(_encryptedData);
          if (read != size)
--- 116,120 ----
      public void readBytes(InputStream in) throws DataFormatException, IOException {
          int size = (int)DataHelper.readLong(in, 4);
!         _encryptedData = new byte[size - 4];
          int read = in.read(_encryptedData);
          if (read != size)
*************** public class Payload implements DataStru
*** 126,130 ****
          if (_encryptedData == null)
              throw new DataFormatException("Not yet encrypted.  Please set the encrypted data");
!         DataHelper.writeLong(out, 4, _encryptedData.length);
          out.write(_encryptedData);
          _log.debug("wrote payload: " + _encryptedData.length + " bytes:\n" + DataHelper.toString(_encryptedData, 16));
--- 126,130 ----
          if (_encryptedData == null)
              throw new DataFormatException("Not yet encrypted.  Please set the encrypted data");
!         DataHelper.writeLong(out, 4, _encryptedData.length + 4);
          out.write(_encryptedData);
          _log.debug("wrote payload: " + _encryptedData.length + " bytes:\n" + DataHelper.toString(_encryptedData, 16));
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQA/MdbHeHiZTMH32ioRAg6gAJ0akArCUd/fdHdTaiB1uZB+kd3fNACfd5/R
fSYRT2lhmc2WseXt+7QiAmQ=
=Htbf
-----END PGP SIGNATURE-----