I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3658cca3 authored by human's avatar human Committed by zzz
Browse files

Further simplified I2P repliable datagram format: they now contain

senderPubDest + S(H(payload)) + payload
(human)
parent 5e78a41b
No related branches found
No related tags found
No related merge requests found
...@@ -59,20 +59,20 @@ public final class I2PDatagramDissector { ...@@ -59,20 +59,20 @@ public final class I2PDatagramDissector {
*/ */
public void loadI2PDatagram(byte[] dgram) throws DataFormatException { public void loadI2PDatagram(byte[] dgram) throws DataFormatException {
ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram); ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram);
byte[] hashedData; byte[] rxTrimmedPayload;
try { try {
rxDest.readBytes(dgStream);
rxSign.readBytes(dgStream); rxSign.readBytes(dgStream);
rxDest.readBytes(dgStream);
rxPayloadLen = dgStream.read(rxPayload); rxPayloadLen = dgStream.read(rxPayload);
// FIXME: hashGen.calculateHash(source, offset, len) would rock...
rxTrimmedPayload = new byte[rxPayloadLen];
System.arraycopy(rxPayload, 0, rxTrimmedPayload, 0, rxPayloadLen);
hashedData = new byte[dgram.length - Signature.SIGNATURE_BYTES]; rxHashBytes =hashGen.calculateHash(rxTrimmedPayload).toByteArray();
System.arraycopy(dgram, Signature.SIGNATURE_BYTES,
hashedData, 0,
hashedData.length);
rxHashBytes = hashGen.calculateHash(hashedData).toByteArray();
} catch (IOException e) { } catch (IOException e) {
_log.error("Caught IOException - INCONSISTENT STATE!", e); _log.error("Caught IOException - INCONSISTENT STATE!", e);
} }
......
...@@ -36,7 +36,6 @@ public final class I2PDatagramMaker { ...@@ -36,7 +36,6 @@ public final class I2PDatagramMaker {
private SigningPrivateKey sxPrivKey = null; private SigningPrivateKey sxPrivKey = null;
private byte[] sxDestBytes = null; private byte[] sxDestBytes = null;
private ByteArrayOutputStream sxBuf = new ByteArrayOutputStream(DGRAM_BUFSIZE);
private ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE); private ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE);
/** /**
...@@ -56,22 +55,16 @@ public final class I2PDatagramMaker { ...@@ -56,22 +55,16 @@ public final class I2PDatagramMaker {
* @param payload Bytes to be contained in the I2P datagram. * @param payload Bytes to be contained in the I2P datagram.
*/ */
public byte[] makeI2PDatagram(byte[] payload) { public byte[] makeI2PDatagram(byte[] payload) {
byte[] hashedData;
sxBuf.reset();
sxDGram.reset(); sxDGram.reset();
try { try {
sxBuf.write(sxDestBytes); sxDGram.write(sxDestBytes);
sxBuf.write(payload);
dsaEng.sign(hashGen.calculateHash(payload).toByteArray(),
hashedData = sxBuf.toByteArray();
dsaEng.sign(hashGen.calculateHash(hashedData).toByteArray(),
sxPrivKey).writeBytes(sxDGram); sxPrivKey).writeBytes(sxDGram);
sxDGram.write(hashedData); sxDGram.write(payload);
return sxDGram.toByteArray(); return sxDGram.toByteArray();
} catch (IOException e) { } catch (IOException e) {
_log.error("Caught IOException", e); _log.error("Caught IOException", e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment