MCPcopy Create free account
hub / github.com/mscdex/ssh2 / openssh_hostKeysProve

Method openssh_hostKeysProve

lib/protocol/Protocol.js:1472–1507  ·  view source on GitHub ↗
(keys)

Source from the content-addressed store, hash-verified

1470 sendPacket(this, this._packetRW.write.finalize(packet));
1471 }
1472 openssh_hostKeysProve(keys) {
1473 if (this._server)
1474 throw new Error('Client-only method called in server mode');
1475
1476 let keysTotal = 0;
1477 const publicKeys = [];
1478 for (const key of keys) {
1479 const publicKey = key.getPublicSSH();
1480 keysTotal += 4 + publicKey.length;
1481 publicKeys.push(publicKey);
1482 }
1483
1484 let p = this._packetRW.write.allocStart;
1485 const packet = this._packetRW.write.alloc(1 + 4 + 29 + 1 + keysTotal);
1486
1487 packet[p] = MESSAGE.GLOBAL_REQUEST;
1488
1489 writeUInt32BE(packet, 29, ++p);
1490 packet.utf8Write('hostkeys-prove-00@openssh.com', p += 4, 29);
1491
1492 packet[p += 29] = 1; // want reply
1493
1494 ++p;
1495 for (const buf of publicKeys) {
1496 writeUInt32BE(packet, buf.length, p);
1497 bufferCopy(buf, packet, 0, buf.length, p += 4);
1498 p += buf.length;
1499 }
1500
1501 if (this._debug) {
1502 this._debug(
1503 'Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)'
1504 );
1505 }
1506 sendPacket(this, this._packetRW.write.finalize(packet));
1507 }
1508
1509 // ===========================================================================
1510 // Server-specific ===========================================================

Callers 1

hostKeysProveFunction · 0.80

Calls 5

writeUInt32BEFunction · 0.85
bufferCopyFunction · 0.85
pushMethod · 0.80
allocMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected