Further simplified I2P repliable datagram format: they now contain
senderPubDest + S(H(payload)) + payload (human)
This commit is contained in:
@ -59,20 +59,20 @@ public final class I2PDatagramDissector {
|
||||
*/
|
||||
public void loadI2PDatagram(byte[] dgram) throws DataFormatException {
|
||||
ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram);
|
||||
byte[] hashedData;
|
||||
|
||||
byte[] rxTrimmedPayload;
|
||||
|
||||
try {
|
||||
rxDest.readBytes(dgStream);
|
||||
|
||||
rxSign.readBytes(dgStream);
|
||||
|
||||
rxDest.readBytes(dgStream);
|
||||
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];
|
||||
System.arraycopy(dgram, Signature.SIGNATURE_BYTES,
|
||||
hashedData, 0,
|
||||
hashedData.length);
|
||||
rxHashBytes = hashGen.calculateHash(hashedData).toByteArray();
|
||||
rxHashBytes =hashGen.calculateHash(rxTrimmedPayload).toByteArray();
|
||||
} catch (IOException e) {
|
||||
_log.error("Caught IOException - INCONSISTENT STATE!", e);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ public final class I2PDatagramMaker {
|
||||
private SigningPrivateKey sxPrivKey = null;
|
||||
private byte[] sxDestBytes = null;
|
||||
|
||||
private ByteArrayOutputStream sxBuf = new ByteArrayOutputStream(DGRAM_BUFSIZE);
|
||||
private ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE);
|
||||
|
||||
/**
|
||||
@ -56,22 +55,16 @@ public final class I2PDatagramMaker {
|
||||
* @param payload Bytes to be contained in the I2P datagram.
|
||||
*/
|
||||
public byte[] makeI2PDatagram(byte[] payload) {
|
||||
byte[] hashedData;
|
||||
|
||||
sxBuf.reset();
|
||||
sxDGram.reset();
|
||||
|
||||
try {
|
||||
sxBuf.write(sxDestBytes);
|
||||
sxBuf.write(payload);
|
||||
|
||||
hashedData = sxBuf.toByteArray();
|
||||
|
||||
dsaEng.sign(hashGen.calculateHash(hashedData).toByteArray(),
|
||||
sxDGram.write(sxDestBytes);
|
||||
|
||||
dsaEng.sign(hashGen.calculateHash(payload).toByteArray(),
|
||||
sxPrivKey).writeBytes(sxDGram);
|
||||
|
||||
sxDGram.write(hashedData);
|
||||
|
||||
sxDGram.write(payload);
|
||||
|
||||
return sxDGram.toByteArray();
|
||||
} catch (IOException e) {
|
||||
_log.error("Caught IOException", e);
|
||||
|
Reference in New Issue
Block a user