throw ISE on attempt to change peer value

This commit is contained in:
zzz
2012-03-16 12:17:07 +00:00
parent e7898b5b8f
commit 045627a583

View File

@@ -198,9 +198,14 @@ public class DHSessionKeyBuilder {
/**
* Specify the value given by the peer for use in the session key negotiation
*
* @throws IllegalStateException if already set
*/
public void setPeerPublicValue(BigInteger peerVal) throws InvalidPublicParameterException {
public synchronized void setPeerPublicValue(BigInteger peerVal) throws InvalidPublicParameterException {
if (_peerValue != null) {
if (!_peerValue.equals(peerVal))
throw new IllegalStateException();
return;
}
validatePublic(peerVal);
_peerValue = peerVal;
}