(scOnly)
| 557 | this._sig = undefined; |
| 558 | } |
| 559 | finish(scOnly) { |
| 560 | if (this._finished) |
| 561 | return false; |
| 562 | this._finished = true; |
| 563 | |
| 564 | const isServer = this._protocol._server; |
| 565 | const negotiated = this.negotiated; |
| 566 | |
| 567 | const pubKey = this.convertPublicKey(this._dhData); |
| 568 | let secret = this.computeSecret(this._dhData); |
| 569 | if (secret instanceof Error) { |
| 570 | secret.message = |
| 571 | `Error while computing DH secret (${this.type}): ${secret.message}`; |
| 572 | secret.level = 'handshake'; |
| 573 | return doFatalError( |
| 574 | this._protocol, |
| 575 | secret, |
| 576 | DISCONNECT_REASON.KEY_EXCHANGE_FAILED |
| 577 | ); |
| 578 | } |
| 579 | |
| 580 | const hash = createHash(this.hashName); |
| 581 | // V_C |
| 582 | hashString(hash, (isServer ? this._remoteIdentRaw : this._identRaw)); |
| 583 | // "V_S" |
| 584 | hashString(hash, (isServer ? this._identRaw : this._remoteIdentRaw)); |
| 585 | // "I_C" |
| 586 | hashString(hash, (isServer ? this._remoteKexinit : this._kexinit)); |
| 587 | // "I_S" |
| 588 | hashString(hash, (isServer ? this._kexinit : this._remoteKexinit)); |
| 589 | // "K_S" |
| 590 | const serverPublicHostKey = (isServer |
| 591 | ? this._hostKey.getPublicSSH() |
| 592 | : this._hostKey); |
| 593 | hashString(hash, serverPublicHostKey); |
| 594 | |
| 595 | if (this.type === 'groupex') { |
| 596 | // Group exchange-specific |
| 597 | const params = this.getDHParams(); |
| 598 | const num = Buffer.allocUnsafe(4); |
| 599 | // min (uint32) |
| 600 | writeUInt32BE(num, this._minBits, 0); |
| 601 | hash.update(num); |
| 602 | // preferred (uint32) |
| 603 | writeUInt32BE(num, this._prefBits, 0); |
| 604 | hash.update(num); |
| 605 | // max (uint32) |
| 606 | writeUInt32BE(num, this._maxBits, 0); |
| 607 | hash.update(num); |
| 608 | // prime |
| 609 | hashString(hash, params.prime); |
| 610 | // generator |
| 611 | hashString(hash, params.generator); |
| 612 | } |
| 613 | |
| 614 | // method-specific data sent by client |
| 615 | hashString(hash, (isServer ? pubKey : this.getPublicKey())); |
| 616 | // method-specific data sent by server |
no test coverage detected