in src/states.js [241:263]
async recvHandshakeMessage(msg) {
if (! (msg instanceof ServerHello)) {
throw new TLSError(ALERT_DESCRIPTION.UNEXPECTED_MESSAGE);
}
if (! bytesAreEqual(msg.sessionId, this._sessionId)) {
throw new TLSError(ALERT_DESCRIPTION.ILLEGAL_PARAMETER);
}
const pskExt = msg.extensions.get(EXTENSION_TYPE.PRE_SHARED_KEY);
if (! pskExt) {
throw new TLSError(ALERT_DESCRIPTION.MISSING_EXTENSION);
}
// We expect only the SUPPORTED_VERSIONS and PRE_SHARED_KEY extensions.
if (msg.extensions.size !== 2) {
throw new TLSError(ALERT_DESCRIPTION.UNSUPPORTED_EXTENSION);
}
if (pskExt.selectedIdentity !== 0) {
throw new TLSError(ALERT_DESCRIPTION.ILLEGAL_PARAMETER);
}
await this.conn._keyschedule.addECDHE(null);
await this.conn._setSendKey(this.conn._keyschedule.clientHandshakeTrafficSecret);
await this.conn._setRecvKey(this.conn._keyschedule.serverHandshakeTrafficSecret);
await this.conn._transition(CLIENT_WAIT_EE);
}