Program: 154356
Project: 154356
Buggy source:
private void serverHandshake() throws AlertException {
switch (type) {
case CLIENT_HELLO:
    if (lastMessage != HELLO_REQUEST && lastMessage != FINISHED)     throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str" + lastMessage);
  serverRandom=new byte[RANDOM_SIZE];
genRandom(serverRandom);
clientHello=new ClientHello(content);
state.addHandshakeLog(new LogEvent("String_Node_Str",clientHello.getStringValue()));
serverHello=new ServerHello(clientHello,serverRandom);
state.setServerRandom(serverRandom);
state.setClientRandom(clientHello.getClientRandom());
if (serverHello.isSessionResume()) {
State tmpState=TLSEngine.findState(serverHello.getSessionId());
if (tmpState != null) {
state.resumeSession(tmpState);
state.addHandshakeLog("String_Node_Str");
}
 else {
state.addHandshakeLog("String_Node_Str");
genRandom(sessionId);
serverHello.setSessionId(sessionId);
}
}
sessionId=serverHello.getSessionId();
state.setSessionId(sessionId);
responseQueue.add(serverHello);
serverCertificate=new ServerCertificate(state.getPeerHost(),serverHello);
responseQueue.add(serverCertificate);
if (serverHello.getChosenCipherSuite().getKeyExchange().requireServerKeyExchange()) {
serverKeyExchange=new ServerKeyExchange(serverHello);
responseQueue.add(serverKeyExchange);
}
serverHelloDone=new ServerHelloDone();
responseQueue.add(serverHelloDone);
break;
case CERTIFICATE_VERIFY:
state.addHandshakeLog(new LogEvent("String_Node_Str","String_Node_Str"));
throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str");
case CLIENT_KEY_EXCHANGE:
clientKeyExchange=new ClientKeyExchange(content);
state.addHandshakeLog(new LogEvent("String_Node_Str",clientKeyExchange.getStringValue()));
if (lastMessage != SERVER_HELLO_DONE) throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str" + lastMessage);
break;
case CHANGE_CIPHER_SPEC:
state.addHandshakeLog(new LogEvent("String_Node_Str",Tools.byteArrayToString(content)));
state.setChangeCipherSpecClient();
state.setCipherSuite(serverHello.getChosenCipherSuite());
break;
case FINISHED:
if (lastMessage != CHANGE_CIPHER_SPEC) throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str" + lastMessage);
if (!state.getChangeCipherSpecClient()) throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str");
responseQueue.add(new ChangeCipherSpec());
clientFinished=new Finished(content);
state.addHandshakeLog(new LogEvent("String_Node_Str",clientFinished.getStringValue()));
state.setChangeCipherSpecServer();
serverFinished=new Finished();
responseQueue.add(serverFinished);
break;
default :
throw new AlertException(AlertException.alert_warning,AlertException.handshake_failure,"String_Node_Str" + type);
}
}

Fixed version (ground truth):
private void serverHandshake() throws AlertException {
switch (type) {
case CLIENT_HELLO:
    if (lastMessage != HELLO_REQUEST && lastMessage != FINISHED)     throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str" + lastMessage);
  serverRandom=new byte[RANDOM_SIZE];
genRandom(serverRandom);
clientHello=new ClientHello(content);
state.addHandshakeLog(new LogEvent("String_Node_Str",clientHello.getStringValue()));
serverHello=new ServerHello(clientHello,serverRandom);
state.setServerRandom(serverRandom);
state.setClientRandom(clientHello.getClientRandom());
if (serverHello.isSessionResume()) {
State tmpState=TLSEngine.findState(serverHello.getSessionId());
if (tmpState != null) {
state.resumeSession(tmpState);
state.addHandshakeLog("String_Node_Str");
}
 else {
state.addHandshakeLog("String_Node_Str");
genRandom(sessionId);
serverHello.setSessionId(sessionId);
}
}
sessionId=serverHello.getSessionId();
state.setSessionId(sessionId);
responseQueue.add(serverHello);
serverCertificate=new ServerCertificate(state.getPeerHost(),serverHello);
responseQueue.add(serverCertificate);
if (serverHello.getChosenCipherSuite().getKeyExchange().requireServerKeyExchange()) {
serverKeyExchange=new ServerKeyExchange(serverHello);
responseQueue.add(serverKeyExchange);
}
serverHelloDone=new ServerHelloDone();
responseQueue.add(serverHelloDone);
break;
case CERTIFICATE_VERIFY:
state.addHandshakeLog(new LogEvent("String_Node_Str","String_Node_Str"));
throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str");
case CLIENT_KEY_EXCHANGE:
clientKeyExchange=new ClientKeyExchange(content);
state.setPreMasterSecret(clientKeyExchange.getByte());
state.addHandshakeLog(new LogEvent("String_Node_Str",clientKeyExchange.getStringValue()));
if (lastMessage != SERVER_HELLO_DONE) throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str" + lastMessage);
break;
case CHANGE_CIPHER_SPEC:
state.addHandshakeLog(new LogEvent("String_Node_Str",Tools.byteArrayToString(content)));
state.setChangeCipherSpecClient();
state.setCipherSuite(serverHello.getChosenCipherSuite());
break;
case FINISHED:
if (lastMessage != CHANGE_CIPHER_SPEC) throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str" + lastMessage);
if (!state.getChangeCipherSpecClient()) throw new AlertException(AlertException.alert_fatal,AlertException.handshake_failure,"String_Node_Str");
responseQueue.add(new ChangeCipherSpec());
clientFinished=new Finished(content);
state.addHandshakeLog(new LogEvent("String_Node_Str",clientFinished.getStringValue()));
state.setChangeCipherSpecServer();
serverFinished=new Finished();
responseQueue.add(serverFinished);
break;
default :
throw new AlertException(AlertException.alert_warning,AlertException.handshake_failure,"String_Node_Str" + type);
}
}