* Streaming, I2PSession:

Prep for SessionKeyManager work in the router -
      Comment out, deprecate, and javadoc for unused keys and tags,
      they are vestiges of end-to-end crypto
This commit is contained in:
zzz
2009-08-22 22:55:37 +00:00
parent faeb58f7e2
commit 3f3d43df41
12 changed files with 145 additions and 62 deletions

View File

@ -93,6 +93,10 @@ class I2CPMessageProducer {
/**
* Package up and send the payload to the router for delivery
*
* @param tag unused - no end-to-end crypto
* @param tags unused - no end-to-end crypto
* @param key unused - no end-to-end crypto
* @param newKey unused - no end-to-end crypto
*/
public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload, SessionTag tag,
SessionKey key, Set tags, SessionKey newKey, long expires) throws I2PSessionException {
@ -135,6 +139,10 @@ class I2CPMessageProducer {
/**
* Create a new signed payload and send it off to the destination
*
* @param tag unused - no end-to-end crypto
* @param tags unused - no end-to-end crypto
* @param key unused - no end-to-end crypto
* @param newKey unused - no end-to-end crypto
*/
private Payload createPayload(Destination dest, byte[] payload, SessionTag tag, SessionKey key, Set tags,
SessionKey newKey) throws I2PSessionException {

View File

@ -355,17 +355,23 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
*/
public abstract boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException;
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
public abstract boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed,
Set tagsSent) throws I2PSessionException;
public abstract void receiveStatus(int msgId, long nonce, int status);
/****** no end-to-end crypto
protected static final Set createNewTags(int num) {
Set tags = new HashSet();
for (int i = 0; i < num; i++)
tags.add(new SessionTag(true));
return tags;
}
*******/
/**
* Recieve a payload message and let the app know its available

View File

@ -133,14 +133,28 @@ class I2PSessionImpl2 extends I2PSessionImpl {
return sendMessage(dest, payload, offset, size, null, null, 0);
}
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
@Override
public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException {
return sendMessage(dest, payload, 0, payload.length, keyUsed, tagsSent, 0);
}
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent)
throws I2PSessionException {
return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0);
}
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expires)
throws I2PSessionException {
if (_log.shouldLog(Log.DEBUG)) _log.debug("sending message");
@ -196,13 +210,17 @@ class I2PSessionImpl2 extends I2PSessionImpl {
private static final int NUM_TAGS = 50;
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
protected boolean sendBestEffort(Destination dest, byte payload[], SessionKey keyUsed, Set tagsSent, long expires)
throws I2PSessionException {
SessionKey key = null;
SessionKey newKey = null;
SessionTag tag = null;
Set sentTags = null;
int oldTags = 0;
//SessionKey key = null;
//SessionKey newKey = null;
//SessionTag tag = null;
//Set sentTags = null;
//int oldTags = 0;
long begin = _context.clock().now();
/***********
if (I2CPMessageProducer.END_TO_END_CRYPTO) {
@ -256,27 +274,27 @@ class I2PSessionImpl2 extends I2PSessionImpl {
long nonce = _context.random().nextInt(Integer.MAX_VALUE);
if (_log.shouldLog(Log.DEBUG)) _log.debug("before sync state");
MessageState state = new MessageState(_context, nonce, getPrefix());
state.setKey(key);
state.setTags(sentTags);
state.setNewKey(newKey);
//state.setKey(key);
//state.setTags(sentTags);
//state.setNewKey(newKey);
state.setTo(dest);
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Setting key = " + key);
//if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Setting key = " + key);
if (keyUsed != null) {
//if (keyUsed != null) {
//if (I2CPMessageProducer.END_TO_END_CRYPTO) {
// if (newKey != null)
// keyUsed.setData(newKey.getData());
// else
// keyUsed.setData(key.getData());
//} else {
keyUsed.setData(SessionKey.INVALID_KEY.getData());
// keyUsed.setData(SessionKey.INVALID_KEY.getData());
//}
}
if (tagsSent != null) {
if (sentTags != null) {
tagsSent.addAll(sentTags);
}
}
//}
//if (tagsSent != null) {
// if (sentTags != null) {
// tagsSent.addAll(sentTags);
// }
//}
if (_log.shouldLog(Log.DEBUG)) _log.debug("before sync state");
long beforeSendingSync = _context.clock().now();
@ -291,7 +309,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
+ state.getNonce() + " for best effort "
+ " sync took " + (inSendingSync-beforeSendingSync)
+ " add took " + (afterSendingSync-inSendingSync));
_producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey, expires);
//_producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey, expires);
_producer.sendMessage(this, dest, nonce, payload, null, null, null, null, expires);
// since this is 'best effort', all we're waiting for is a status update
// saying that the router received it - in theory, that should come back

View File

@ -128,6 +128,10 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
return sendMessage(dest, payload, 0, payload.length, null, null, 0, proto, fromport, toport);
}
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
@Override
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size,
SessionKey keyUsed, Set tagsSent, long expires)
@ -135,6 +139,10 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0, PROTO_UNSPECIFIED, PORT_UNSPECIFIED, PORT_UNSPECIFIED);
}
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
@Override
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent,
int proto, int fromport, int toport) throws I2PSessionException {
@ -142,6 +150,8 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
}
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
* @param proto 1-254 or 0 for unset; recommended:
* I2PSession.PROTO_UNSPECIFIED
* I2PSession.PROTO_STREAMING

View File

@ -12,7 +12,7 @@ import org.bouncycastle.crypto.macs.I2PHMac;
/**
* Calculate the HMAC-SHA256 of a key+message. All the good stuff occurs
* in {@link org.bouncycastle.crypto.macs.HMac} and
* in {@link org.bouncycastle.crypto.macs.I2PHMac} and
* {@link org.bouncycastle.crypto.digests.MD5Digest}.
*
*/

View File

@ -15,7 +15,7 @@ import org.bouncycastle.crypto.macs.I2PHMac;
/**
* Calculate the HMAC-MD5 of a key+message. All the good stuff occurs
* in {@link org.bouncycastle.crypto.macs.HMac} and
* in {@link org.bouncycastle.crypto.macs.I2PHMac} and
* {@link org.bouncycastle.crypto.digests.MD5Digest}.
*
*/