- case SPTPS_SECONDARY_KEX:
- // We receive a secondary KEX request, first respond by sending our own.
- if(!send_kex(s))
- return false;
- case SPTPS_KEX:
- // We have sent our KEX request, we expect our peer to sent one as well.
- if(!receive_kex(s, data, len))
- return false;
- s->state = SPTPS_SIG;
- return true;
- case SPTPS_SIG:
- // If we already sent our secondary public ECDH key, we expect the peer to send his.
- if(!receive_sig(s, data, len))
+ case SPTPS_SECONDARY_KEX:
+
+ // We receive a secondary KEX request, first respond by sending our own.
+ if(!send_kex(s)) {
+ return false;
+ }
+
+ // Fall through
+ case SPTPS_KEX:
+
+ // We have sent our KEX request, we expect our peer to sent one as well.
+ if(!receive_kex(s, data, len)) {
+ return false;
+ }
+
+ s->state = SPTPS_SIG;
+ return true;
+
+ case SPTPS_SIG:
+
+ // If we already sent our secondary public ECDH key, we expect the peer to send his.
+ if(!receive_sig(s, data, len)) {
+ return false;
+ }
+
+ if(s->outstate) {
+ s->state = SPTPS_ACK;
+ } else {
+ s->outstate = true;
+
+ if(!receive_ack(s, NULL, 0)) {