SSU: Return unused DH to the queue

This commit is contained in:
zzz
2014-09-22 18:49:20 +00:00
parent 591f48856d
commit 3331e1c152
2 changed files with 14 additions and 6 deletions

View File

@ -1363,6 +1363,7 @@ class EstablishmentManager {
_transport.markUnreachable(peer);
_transport.dropPeer(peer, false, err);
//_context.profileManager().commErrorOccurred(peer);
outboundState.fail();
} else {
OutNetMessage msg;
while ((msg = outboundState.getNextQueuedMessage()) != null) {

View File

@ -201,15 +201,17 @@ class OutboundEstablishState {
/** caller must synch - only call once */
private void prepareSessionRequest() {
_keyBuilder = _keyFactory.getBuilder();
_sentX = new byte[UDPPacketReader.SessionRequestReader.X_LENGTH];
byte X[] = _keyBuilder.getMyPublicValue().toByteArray();
if (X.length == 257)
if (X.length == 257) {
_sentX = new byte[256];
System.arraycopy(X, 1, _sentX, 0, _sentX.length);
else if (X.length == 256)
System.arraycopy(X, 0, _sentX, 0, _sentX.length);
else
} else if (X.length == 256) {
_sentX = X;
} else {
_sentX = new byte[256];
System.arraycopy(X, 0, _sentX, _sentX.length - X.length, X.length);
}
}
public synchronized byte[] getSentX() {
// We defer keygen until now so that it gets done in the Establisher loop,
@ -219,7 +221,7 @@ class OutboundEstablishState {
return _sentX;
}
/**
/**x
* The remote side (Bob) - note that in some places he's called Charlie.
* Warning - may change after introduction. May be null before introduction.
*/
@ -339,6 +341,11 @@ class OutboundEstablishState {
_receivedEncryptedSignature = null;
_receivedIV = null;
_receivedSignature = null;
if (_keyBuilder != null) {
if (_keyBuilder.getPeerPublicValue() == null)
_keyFactory.returnUnused(_keyBuilder);
_keyBuilder = null;
}
// sure, there's a chance the packet was corrupted, but in practice
// this means that Bob doesn't know his external port, so give up.
_currentState = OutboundState.OB_STATE_VALIDATION_FAILED;