SSU2: Stub out path challenge/response

This commit is contained in:
zzz
2022-07-27 10:56:18 -04:00
parent 5948a7dec3
commit e250531174
6 changed files with 69 additions and 0 deletions

View File

@ -2825,6 +2825,14 @@ class EstablishmentManager {
public void gotTermination(int reason, long count) {
throw new IllegalStateException("Bad block in HP");
}
public void gotPathChallenge(byte[] data) {
throw new IllegalStateException("Bad block in HP");
}
public void gotPathResponse(byte[] data) {
throw new IllegalStateException("Bad block in HP");
}
}

View File

@ -420,6 +420,14 @@ class InboundEstablishState2 extends InboundEstablishState implements SSU2Payloa
_transport.getEstablisher().receiveSessionDestroy(_remoteHostId);
}
public void gotPathChallenge(byte[] data) {
throw new IllegalStateException("Bad block in handshake");
}
public void gotPathResponse(byte[] data) {
throw new IllegalStateException("Bad block in handshake");
}
/////////////////////////////////////////////////////////
// end payload callbacks
/////////////////////////////////////////////////////////

View File

@ -348,6 +348,14 @@ class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payl
_transport.getEstablisher().receiveSessionDestroy(_remoteHostId, this);
}
public void gotPathChallenge(byte[] data) {
// won't be called, SSU2Payload will throw
}
public void gotPathResponse(byte[] data) {
// won't be called, SSU2Payload will throw
}
/////////////////////////////////////////////////////////
// end payload callbacks
/////////////////////////////////////////////////////////

View File

@ -637,6 +637,14 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
_transport.getEstablisher().receiveSessionDestroy(_remoteHostId, this);
}
public void gotPathChallenge(byte[] data) {
// TODO
}
public void gotPathResponse(byte[] data) {
// TODO
}
/////////////////////////////////////////////////////////
// end payload callbacks
/////////////////////////////////////////////////////////

View File

@ -1837,6 +1837,9 @@ class PeerTestManager {
}
/**
* This is only for out-of-session messages 5-7,
* where most blocks are not allowed.
*
* @since 0.9.54
*/
private class PTCallback implements SSU2Payload.PayloadCallback {
@ -1920,5 +1923,13 @@ class PeerTestManager {
public void gotTermination(int reason, long count) {
throw new IllegalStateException("Bad block in PT");
}
public void gotPathChallenge(byte[] data) {
throw new IllegalStateException("Bad block in PT");
}
public void gotPathResponse(byte[] data) {
throw new IllegalStateException("Bad block in PT");
}
}
}

View File

@ -124,6 +124,16 @@ class SSU2Payload {
* @param lastReceived in theory could wrap around to negative, but very unlikely
*/
public void gotTermination(int reason, long lastReceived);
/**
* @since 0.9.55
*/
public void gotPathChallenge(byte[] data);
/**
* @since 0.9.55
*/
public void gotPathResponse(byte[] data);
}
/**
@ -352,6 +362,22 @@ class SSU2Payload {
gotTermination = true;
break;
case BLOCK_PATHCHALLENGE:
if (isHandshake)
throw new IOException("Illegal block in handshake: " + type);
byte[] cdata = new byte[len];
System.arraycopy(payload, i, cdata, 0, len);
cb.gotPathChallenge(cdata);
break;
case BLOCK_PATHRESP:
if (isHandshake)
throw new IOException("Illegal block in handshake: " + type);
byte[] rdata = new byte[len];
System.arraycopy(payload, i, rdata, 0, len);
cb.gotPathResponse(rdata);
break;
case BLOCK_PADDING:
gotPadding = true;
break;