(username, password, newPassword)
| 578 | // 'ssh-userauth' service-specific |
| 579 | // ------------------------------- |
| 580 | authPassword(username, password, newPassword) { |
| 581 | if (this._server) |
| 582 | throw new Error('Client-only method called in server mode'); |
| 583 | |
| 584 | const userLen = Buffer.byteLength(username); |
| 585 | const passLen = Buffer.byteLength(password); |
| 586 | const newPassLen = (newPassword ? Buffer.byteLength(newPassword) : 0); |
| 587 | let p = this._packetRW.write.allocStart; |
| 588 | const packet = this._packetRW.write.alloc( |
| 589 | 1 + 4 + userLen + 4 + 14 + 4 + 8 + 1 + 4 + passLen |
| 590 | + (newPassword ? 4 + newPassLen : 0) |
| 591 | ); |
| 592 | |
| 593 | packet[p] = MESSAGE.USERAUTH_REQUEST; |
| 594 | |
| 595 | writeUInt32BE(packet, userLen, ++p); |
| 596 | packet.utf8Write(username, p += 4, userLen); |
| 597 | |
| 598 | writeUInt32BE(packet, 14, p += userLen); |
| 599 | packet.utf8Write('ssh-connection', p += 4, 14); |
| 600 | |
| 601 | writeUInt32BE(packet, 8, p += 14); |
| 602 | packet.utf8Write('password', p += 4, 8); |
| 603 | |
| 604 | packet[p += 8] = (newPassword ? 1 : 0); |
| 605 | |
| 606 | writeUInt32BE(packet, passLen, ++p); |
| 607 | if (Buffer.isBuffer(password)) |
| 608 | bufferCopy(password, packet, 0, passLen, p += 4); |
| 609 | else |
| 610 | packet.utf8Write(password, p += 4, passLen); |
| 611 | |
| 612 | if (newPassword) { |
| 613 | writeUInt32BE(packet, newPassLen, p += passLen); |
| 614 | if (Buffer.isBuffer(newPassword)) |
| 615 | bufferCopy(newPassword, packet, 0, newPassLen, p += 4); |
| 616 | else |
| 617 | packet.utf8Write(newPassword, p += 4, newPassLen); |
| 618 | this._debug && this._debug( |
| 619 | 'Outbound: Sending USERAUTH_REQUEST (changed password)' |
| 620 | ); |
| 621 | } else { |
| 622 | this._debug && this._debug( |
| 623 | 'Outbound: Sending USERAUTH_REQUEST (password)' |
| 624 | ); |
| 625 | } |
| 626 | |
| 627 | this._authsQueue.push('password'); |
| 628 | |
| 629 | sendPacket(this, this._packetRW.write.finalize(packet)); |
| 630 | } |
| 631 | authPK(username, pubKey, keyAlgo, cbSign) { |
| 632 | if (this._server) |
| 633 | throw new Error('Client-only method called in server mode'); |
no test coverage detected