first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

17
build/node_modules/ssh2-streams/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,17 @@
sudo: false
language: cpp
notifications:
email: false
env:
matrix:
- TRAVIS_NODE_VERSION="0.10"
- TRAVIS_NODE_VERSION="0.12"
- TRAVIS_NODE_VERSION="4"
- TRAVIS_NODE_VERSION="6"
- TRAVIS_NODE_VERSION="7"
install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
- node --version
- npm --version
- npm install
script: npm test

19
build/node_modules/ssh2-streams/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright 2014 Brian White. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

569
build/node_modules/ssh2-streams/README.md generated vendored Normal file
View File

@@ -0,0 +1,569 @@
Description
===========
SSH2 and SFTP(v3) client/server protocol streams for [node.js](http://nodejs.org/).
[![Build Status](https://travis-ci.org/mscdex/ssh2-streams.svg?branch=master)](https://travis-ci.org/mscdex/ssh2-streams)
Requirements
============
* [node.js](http://nodejs.org/) -- v0.10 or newer
Install
=======
npm install ssh2-streams
API
===
`require('ssh2-streams').SSH2Stream` returns an **_SSH2Stream_** constructor.
`require('ssh2-streams').SFTPStream` returns an [**_SFTPStream_**](SFTPStream.md) constructor.
`require('ssh2-streams').utils` returns an _object_ of useful utility functions.
`require('ssh2-streams').constants` returns an _object_ containing useful SSH protocol constants.
SSH2Stream events
-----------------
**Client/Server events**
* **header**(< _object_ >headerInfo) - Emitted when the protocol header is seen. `headerInfo` contains:
* **greeting** - _string_ - (Client-only) An optional greeting message presented by the server.
* **identRaw** - _string_ - The raw identification string sent by the remote party.
* **versions** - _object_ - Contains various information parsed from `identRaw`:
* **protocol** - _string_ - The protocol version (always `1.99` or `2.0`) supported by the remote party.
* **software** - _string_ - The software name used by the remote party.
* **comments** - _string_ - Any additional text that comes after the software name.
* **GLOBAL_REQUEST**(< _string_ >reqName, < _boolean_ >wantReply, < _mixed_ >reqData)
* **CHANNEL_DATA:\<channel\>**(< _Buffer_ >data)
* **CHANNEL_EXTENDED_DATA:\<channel\>**(< _integer_ >type, < _Buffer_ >data)
* **CHANNEL_WINDOW_ADJUST:\<channel\>**(< _integer_ >bytesToAdd)
* **CHANNEL_SUCCESS:\<channel\>**()
* **CHANNEL_FAILURE:\<channel\>**()
* **CHANNEL_EOF:\<channel\>**()
* **CHANNEL_CLOSE:\<channel\>**()
* **CHANNEL_OPEN_CONFIRMATION:\<channel\>**(< _object_ >channelInfo) - `channelInfo` contains:
* **recipient** - _integer_ - The local channel number.
* **sender** - _integer_ - The remote party's channel number.
* **window** - _integer_ - The initial window size for the channel.
* **packetSize** - _integer_ - The maximum packet size for the channel.
* **CHANNEL_OPEN_FAILURE:\<channel\>**(< _object_ >failInfo) - `failInfo` contains:
* **recipient** - _integer_ - The local channel number.
* **reasonCode** - _integer_ - The reason code of the failure.
* **reason** - _string_ - A text representation of the `reasonCode`.
* **description** - _string_ - An optional description of the failure.
* **DISCONNECT**(< _string_ >reason, < _integer_ >reasonCode, < _string_ >description)
* **DEBUG**(< _string_ >message)
* **NEWKEYS**()
* **REQUEST_SUCCESS**([< _Buffer_ >resData])
* **REQUEST_FAILURE**()
**Client-only events**
* **fingerprint**(< _Buffer_ >hostKey, < _function_ >callback) - This event allows you to verify a host's key. If `callback` is called with `true`, the handshake continues. Otherwise a disconnection will occur if `callback` is called with `false`. The default behavior is to auto-allow any host key if there are no handlers for this event.
* **SERVICE_ACCEPT**(< _string_ >serviceName)
* **USERAUTH_PASSWD_CHANGEREQ**(< _string_ >message)
* **USERAUTH_INFO_REQUEST**(< _string_ >name, < _string_ >instructions, < _string_ >lang, < _array_ >prompts)
* **USERAUTH_PK_OK**()
* **USERAUTH_SUCCESS**()
* **USERAUTH_FAILURE**(< _array_ >methodsContinue, < _boolean_ >partialSuccess)
* **USERAUTH_BANNER**(< _string_ >message)
* **CHANNEL_OPEN**(< _object_ >channelInfo) - `channelInfo` contains:
* **type** - _string_ - The channel type (e.g. `x11`, `forwarded-tcpip`).
* **sender** - _integer_ - The remote party's channel number.
* **window** - _integer_ - The initial window size for the channel.
* **packetSize** - _integer_ - The maximum packet size for the channel.
* **data** - _object_ - The properties available depend on `type`:
* `x11`:
* **srcIP** - _string_ - Source IP address of X11 connection request.
* **srcPort** - _string_ - Source port of X11 connection request.
* `forwarded-tcpip`:
* **srcIP** - _string_ - Source IP address of incoming connection.
* **srcPort** - _string_ - Source port of incoming connection.
* **destIP** - _string_ - Destination IP address of incoming connection.
* **destPort** - _string_ - Destination port of incoming connection.
* `forwarded-streamlocal@openssh.com`:
* **socketPath** - _string_ - Source socket path of incoming connection.
* `auth-agent@openssh.com` has no extra data.
* **CHANNEL_REQUEST:\<channel\>**(< _object_ >reqInfo) - `reqInfo` properties depend on `reqInfo.request`:
* `exit-status`:
* **code** - _integer_ - The exit status code of the remote process.
* `exit-signal`:
* **signal** - _string_ - The signal name.
* **coredump** - _boolean_ - Was the exit the result of a core dump?
* **description** - _string_ - An optional error message.
**Server-only events**
* **SERVICE_REQUEST**(< _string_ >serviceName)
* **USERAUTH_REQUEST**(< _string_ >username, < _string_ >serviceName, < _string_ >authMethod, < _mixed_ >authMethodData) - `authMethodData` depends on `authMethod`:
* For `password`, it's a _string_ containing the password.
* For `publickey`, it's an _object_ containing:
* **keyAlgo** - _string_ - The public key algorithm.
* **key** - _Buffer_ - The public key data.
* **signature** - _mixed_ - If set, it is a _Buffer_ containing the signature to be verified.
* **blob** - _mixed_ - If set, it is a _Buffer_ containing the data to sign. The resulting signature is what is compared to `signature`.
* For `hostbased`, it's an _object_ including the properties from `publickey` but also:
* **localHostname** - _string_ - The client's hostname to be verified.
* **localUsername** - _string_ - The client's (local) username to be verified.
* **USERAUTH_INFO_RESPONSE**(< _array_ >responses)
* **GLOBAL_REQUEST**(< _string_ >reqName, < _boolean_ >wantReply, < _mixed_ >reqData) - `reqData` depends on `reqName`:
* For `tcpip-forward`/`cancel-tcpip-forward`, it's an _object_ containing:
* **bindAddr** - _string_ - The IP address to start/stop binding to.
* **bindPort** - _string_ - The port to start/stop binding to.
* For `streamlocal-forward@openssh.com`/`cancel-streamlocal-forward@openssh.com`, it's an _object_ containing:
* **socketPath** - _string_ - The socket path to start/stop listening on.
* For `no-more-sessions@openssh.com`, there is no `reqData`.
* For any other requests, it's a _Buffer_ containing raw request-specific data *if* there is any extra data.
* **CHANNEL_OPEN**(< _object_ >channelInfo) - `channelInfo` contains:
* **type** - _string_ - The channel type (e.g. `session`, `direct-tcpip`).
* **sender** - _integer_ - The remote party's channel number.
* **window** - _integer_ - The initial window size for the channel.
* **packetSize** - _integer_ - The maximum packet size for the channel.
* **data** - _object_ - The properties available depend on `type`:
* `direct-tcpip`:
* **srcIP** - _string_ - Source IP address of outgoing connection.
* **srcPort** - _string_ - Source port of outgoing connection.
* **destIP** - _string_ - Destination IP address of outgoing connection.
* **destPort** - _string_ - Destination port of outgoing connection.
* `direct-streamlocal@openssh.com`:
* **socketPath** - _string_ - Destination socket path of outgoing connection.
* `session` has no extra data.
* **CHANNEL_REQUEST:\<channel\>**(< _object_ >reqInfo) - `reqInfo` properties depend on `reqInfo.request`:
* `pty-req`:
* **wantReply** - _boolean_ - The client is requesting a response to this request.
* **term** - _string_ - The terminal type name.
* **cols** - _integer_ - The number of columns.
* **rows** - _integer_ - The number of rows.
* **width** - _integer_ - The width in pixels.
* **height** - _integer_ - The height in pixels.
* **modes** - _object_ - The terminal modes.
* `window-change`:
* **cols** - _integer_ - The number of columns.
* **rows** - _integer_ - The number of rows.
* **width** - _integer_ - The width in pixels.
* **height** - _integer_ - The height in pixels.
* `x11-req`:
* **wantReply** - _boolean_ - The client is requesting a response to this request.
* **single** - _boolean_ - Whether only a single X11 connection should be allowed.
* **protocol** - _string_ - The X11 authentication protocol to be used.
* **cookie** - _string_ - The hex-encoded X11 authentication cookie.
* **screen** - _integer_ - The screen number for incoming X11 connections.
* `env`:
* **wantReply** - _boolean_ - The client is requesting a response to this request.
* **key** - _string_ - The environment variable name.
* **val** - _string_ - The environment variable value.
* `shell`:
* **wantReply** - _boolean_ - The client is requesting a response to this request.
* `exec`:
* **wantReply** - _boolean_ - The client is requesting a response to this request.
* **command** - _string_ - The command to be executed.
* `subsystem`:
* **wantReply** - _boolean_ - The client is requesting a response to this request.
* **subsystem** - _string_ - The name of the subsystem.
* `signal`:
* **signal** - _string_ - The signal name (prefixed with `SIG`).
* `xon-xoff`:
* **clientControl** - _boolean_ - Client can/can't perform flow control (control-S/control-Q processing).
* `auth-agent-req@openssh.com` has no `reqInfo`.
SSH2Stream properties
---------------------
* **bytesSent** - _integer_ - The number of bytes sent since the last keying. This metric can be useful in determining when to call `rekey()`.
* **bytesReceived** - _integer_ - The number of bytes received since the last keying. This metric can be useful in determining when to call `rekey()`.
SSH2Stream methods
------------------
* **(constructor)**(< _object_ >config) - Creates and returns a new SSH2Stream instance. SSH2Stream instances are Duplex streams. `config` can contain:
* **server** - _boolean_ - Set to `true` to create an instance in server mode. **Default:** `false`
* **hostKeys** - _object_ - If in server mode, an object keyed on host key format (see supported `serverHostKey` values in `algorithms` option below) with values being (decrypted) _Buffer_s or _string_s that contain PEM-encoded (OpenSSH format) host private key(s). **Default:** (none)
* **greeting** - _string_ - If in server mode, an optional message to send to the user immediately upon connection, before the handshake. **Note:** Most clients usually ignore this. **Default:** (none)
* **banner** - _string_ - If in server mode, an optional message to send to the user once, right before authentication begins. **Default:** (none)
* **ident** - _string_ - A custom software name/version identifier. **Default:** `'ssh2js' + moduleVersion + 'srv'` (server mode) `'ssh2js' + moduleVersion` (client mode)
* **maxPacketSize** - _string_ - This is the maximum packet size that will be accepted. It should be 35000 bytes or larger to be compatible with other SSH2 implementations. **Default:** `35000`
* **highWaterMark** - _integer_ - This is the `highWaterMark` to use for the stream. **Default:** `32 * 1024`
* **algorithms** - _object_ - This option allows you to explicitly override the default transport layer algorithms used for the connection. Each value must be an array of valid algorithms for that category. The order of the algorithms in the arrays are important, with the most favorable being first. Valid keys:
* **kex** - _array_ - Key exchange algorithms.
* Default values:
1. ecdh-sha2-nistp256 **(node v0.11.14 or newer)**
2. ecdh-sha2-nistp384 **(node v0.11.14 or newer)**
3. ecdh-sha2-nistp521 **(node v0.11.14 or newer)**
4. diffie-hellman-group-exchange-sha256 **(node v0.11.12 or newer)**
5. diffie-hellman-group14-sha1
* Supported values:
* ecdh-sha2-nistp256 **(node v0.11.14 or newer)**
* ecdh-sha2-nistp384 **(node v0.11.14 or newer)**
* ecdh-sha2-nistp521 **(node v0.11.14 or newer)**
* diffie-hellman-group-exchange-sha256 **(node v0.11.12 or newer)**
* diffie-hellman-group14-sha1
* diffie-hellman-group-exchange-sha1 **(node v0.11.12 or newer)**
* diffie-hellman-group1-sha1
* **cipher** - _array_ - Ciphers.
* Default values:
1. aes128-ctr
2. aes192-ctr
3. aes256-ctr
4. aes128-gcm **(node v0.11.12 or newer)**
5. aes128-gcm@openssh.com **(node v0.11.12 or newer)**
6. aes256-gcm **(node v0.11.12 or newer)**
7. aes256-gcm@openssh.com **(node v0.11.12 or newer)**
* Supported values:
* aes128-ctr
* aes192-ctr
* aes256-ctr
* aes128-gcm **(node v0.11.12 or newer)**
* aes128-gcm@openssh.com **(node v0.11.12 or newer)**
* aes256-gcm **(node v0.11.12 or newer)**
* aes256-gcm@openssh.com **(node v0.11.12 or newer)**
* aes256-cbc
* aes192-cbc
* aes128-cbc
* blowfish-cbc
* 3des-cbc
* arcfour256
* arcfour128
* cast128-cbc
* arcfour
* **serverHostKey** - _array_ - Server host key formats. In server mode, this list must agree with the host private keys set in the `hostKeys` config setting.
* Default values:
1. ssh-rsa
2. ecdsa-sha2-nistp256 **(node v5.2.0 or newer)**
3. ecdsa-sha2-nistp384 **(node v5.2.0 or newer)**
4. ecdsa-sha2-nistp521 **(node v5.2.0 or newer)**
* Supported values:
* ssh-rsa
* ecdsa-sha2-nistp256 **(node v5.2.0 or newer)**
* ecdsa-sha2-nistp384 **(node v5.2.0 or newer)**
* ecdsa-sha2-nistp521 **(node v5.2.0 or newer)**
* ssh-dss
* **hmac** - _array_ - (H)MAC algorithms.
* Default values:
1. hmac-sha2-256
2. hmac-sha2-512
3. hmac-sha1
* Supported values:
* hmac-sha2-256
* hmac-sha2-512
* hmac-sha1
* hmac-md5
* hmac-sha2-256-96
* hmac-sha2-512-96
* hmac-ripemd160
* hmac-sha1-96
* hmac-md5-96
* **compress** - _array_ - Compression algorithms.
* Default values:
1. none
2. zlib@openssh.com
3. zlib
* Supported values:
* none
* zlib@openssh.com
* zlib
* **debug** - _function_ - Set this to a function that receives a single string argument to get detailed (local) debug information. **Default:** (none)
**Client/Server methods**
* **ping**() - _boolean_ - Writes a dummy GLOBAL_REQUEST packet (specifically "keepalive@openssh.com") that requests a reply. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **disconnect**([< _integer_ >reasonCode]) - _boolean_ - Writes a disconnect packet and closes the stream. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **rekey**() - _boolean_ - Starts the re-keying process. Incoming/Outgoing packets are buffered until the re-keying process has finished. Returns `false` to indicate that no more packets should be written until the `NEWKEYS` event is seen.
* **requestSuccess**([< _Buffer_ >data]) - _boolean_ - Writes a request success packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **requestFailure**() - _boolean_ - Writes a request failure packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelSuccess**() - _boolean_ - Writes a channel success packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelFailure**() - _boolean_ - Writes a channel failure packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelEOF**(< _integer_ >channel) - _boolean_ - Writes a channel EOF packet for the given `channel`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelClose**(< _integer_ >channel) - _boolean_ - Writes a channel close packet for the given `channel`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelWindowAdjust**(< _integer_ >channel, < _integer_ >amount) - _boolean_ - Writes a channel window adjust packet for the given `channel` where `amount` is the number of bytes to add to the channel window. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelData**(< _integer_ >channel, < _mixed_ >data) - _boolean_ - Writes a channel data packet for the given `channel` where `data` is a _Buffer_ or _string_. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelExtData**(< _integer_ >channel, < _mixed_ >data, < _integer_ >type) - _boolean_ - Writes a channel extended data packet for the given `channel` where `data is a _Buffer_ or _string_. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelOpenConfirm**(< _integer_ >remoteChannel, < _integer_ >localChannel, < _integer_ >initWindow, < _integer_ >maxPacket) - _boolean_ - Writes a channel open confirmation packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **channelOpenFail**(< _integer_ >remoteChannel, < _integer_ >reasonCode[, < _string_ >description]) - _boolean_ - Writes a channel open failure packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
**Client-only methods**
* **service**(< _string_ >serviceName) - _boolean_ - Writes a service request packet for `serviceName`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **tcpipForward**(< _string_ >bindAddr, < _integer_ >bindPort[, < _boolean_ >wantReply]) - _boolean_ - Writes a tcpip forward global request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **cancelTcpipForward**(< _string_ >bindAddr, < _integer_ >bindPort[, < _boolean_ >wantReply]) - _boolean_ - Writes a cancel tcpip forward global request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authPassword**(< _string_ >username, < _string_ >password) - _boolean_ - Writes a password userauth request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authPK**(< _string_ >username, < _object_ >pubKey[, < _function_ >cbSign]) - _boolean_ - Writes a publickey userauth request packet. `pubKey` is the object returned from using `utils.parseKey()` on a private or public key. If `cbSign` is not present, a pubkey check userauth packet is written. Otherwise `cbSign` is called with `(blob, callback)`, where `blob` is the data to sign with the private key and the resulting signature _Buffer_ is passed to `callback` as the first argument. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authHostbased**(< _string_ >username, < _object_ >pubKey, < _string_ >localHostname, < _string_ >localUsername, < _function_ >cbSign) - _boolean_ - Writes a hostbased userauth request packet. `pubKey` is the object returned from using `utils.parseKey()` on a private or public key. `cbSign` is called with `(blob, callback)`, where `blob` is the data to sign with the private key and the resulting signature _Buffer_ is passed to `callback` as the first argument. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authKeyboard**(< _string_ >username) - _boolean_ - Writes a keyboard-interactive userauth request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authNone**(< _string_ >username) - _boolean_ - Writes a "none" userauth request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authInfoRes**(< _array_ >responses) - _boolean_ - Writes a userauth info response packet. `responses` is an _array_ of zero or more strings corresponding to responses to prompts previously sent by the server. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **directTcpip**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >config) - _boolean_ - Writes a direct tcpip channel open packet. `config` must contain `srcIP`, `srcPort`, `dstIP`, and `dstPort`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **session**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket) - _boolean_ - Writes a session channel open packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **openssh_agentForward**(< _integer_ >channel[, < _boolean_ >wantReply]) - _boolean_ - Writes an `auth-agent-req@openssh.com` channel request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **windowChange**(< _integer_ >channel, < _integer_ >rows, < _integer_ >cols, < _integer_ >height, < _integer_ >width) - _boolean_ - Writes a window change channel request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **pty**(< _integer_ >channel, < _integer_ >rows, < _integer_ >cols, < _integer_ >height, < _integer_ >width, < _string_ >terminalType, < _mixed_ >terminalModes[, < _boolean_ >wantReply]) - _boolean_ - Writes a pty channel request packet. If `terminalType` is falsey, `vt100` is used. `terminalModes` can be the raw bytes, an _object_ of the terminal modes to set, or a falsey value for no modes. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **env**(< _integer_ >channel, < _string_ >key, < _mixed_ >value[, < _boolean_ >wantReply]) - _boolean_ - Writes an env channel request packet. `value` can be a _string_ or _Buffer_. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **shell**(< _integer_ >channel[, < _boolean_ >wantReply]) - _boolean_ - Writes a shell channel request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **exec**(< _integer_ >channel, < _string_ >command[, < _boolean_ >wantReply]) - _boolean_ - Writes an exec channel request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **signal**(< _integer_ >channel, < _string_ >signalName) - _boolean_ - Writes a signal channel request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **x11Forward**(< _integer_ >channel, < _object_ >config[, < _boolean_ >wantReply]) - _boolean_ - Writes an X11 forward channel request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `config` can contain:
* **single** - _boolean_ - `true` if only a single connection should be forwarded.
* **protocol** - _string_ - The name of the X11 authentication method used (e.g. `MIT-MAGIC-COOKIE-1`).
* **cookie** - _string_ - The X11 authentication cookie encoded in hexadecimal.
* **screen** - _integer_ - The screen number to forward X11 connections for.
* **subsystem**(< _integer_ >channel, < _string_ >name[, < _boolean_ >wantReply]) - _boolean_ - Writes a subsystem channel request packet. `name` is the name of the subsystem (e.g. `sftp` or `netconf`). `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **openssh_noMoreSessions**([< _boolean_ >wantReply]) - _boolean_ - Writes a no-more-sessions@openssh.com request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **openssh_streamLocalForward**(< _string_ >socketPath[, < _boolean_ >wantReply]) - _boolean_ - Writes a streamlocal-forward@openssh.com request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **openssh_cancelStreamLocalForward**(< _string_ >socketPath[, < _boolean_ >wantReply]) - _boolean_ - Writes a cancel-streamlocal-forward@openssh.com request packet. `wantReply` defaults to `true`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **openssh_directStreamLocal**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >config) - _boolean_ - Writes a direct-streamlocal@openssh.com channel open packet. `config` must contain `socketPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
**Server-only methods**
* **serviceAccept**(< _string_ >serviceName) - _boolean_ - Writes a service accept packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authFailure**([< _array_ >authMethods[, < _boolean_ >partialSuccess]]) - _boolean_ - Writes a userauth failure packet. `authMethods` is an _array_ of authentication methods that can continue. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authSuccess**() - _boolean_ - Writes a userauth success packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authPKOK**(< _string_ >keyAlgorithm, < _Buffer_ >keyData) - _boolean_ - Writes a userauth PK OK packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **authInfoReq**(< _string_ >name, < _string_ >instructions, < _array_ >prompts) - _boolean_ - Writes a userauth info request packet. `prompts` is an array of `{ prompt: 'Prompt text', echo: true }` objects (`prompt` being the prompt text and `echo` indicating whether the client's response to the prompt should be echoed to their display). Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **forwardedTcpip**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes a forwarded tcpip channel open packet. `info` must contain `boundAddr`, `boundPort`, `remoteAddr`, and `remotePort`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **x11**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes an X11 channel open packet. `info` must contain `originAddr` and `originPort`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **openssh_forwardedStreamLocal**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes an forwarded-streamlocal@openssh.com channel open packet. `info` must contain `socketPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **exitStatus**(< _integer_ >channel, < _integer_ >exitCode) - _boolean_ - Writes an exit status channel request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **exitSignal**(< _integer_ >channel, < _string_ >signalName, < _boolean_ >coreDumped, < _string_ >errorMessage) - _boolean_ - Writes an exit signal channel request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic.
Utility methods
---------------
* **parseKey**(< _mixed_ >keyData) - _object_ - Parses a private/public key in OpenSSH and RFC4716 formats.
* **decryptKey**(< _object_ >privKeyInfo, < _string_ >passphrase) - _(void)_ - Takes a private key parsed with `parseKey()` and decrypts it with `passphrase`. The decrypted key data overwrites the original encrypted copy.
* **genPublicKey**(< _object_ >privKeyInfo) - _object_ - Takes a private key parsed with `parseKey()` and generates the associated public key and returns the public key information in the same format as `parseKey()`.

405
build/node_modules/ssh2-streams/SFTPStream.md generated vendored Normal file
View File

@@ -0,0 +1,405 @@
SFTPStream events
-----------------
**Client/Server events**
* **ready**() - Emitted after initial protocol version check has passed.
**Server-only events**
_Responses to these client requests are sent using one of the methods listed further in this document under `Server-only methods`. The valid response(s) for each request are documented below._
* **OPEN**(< _integer_ >reqID, < _string_ >filename, < _integer_ >flags, < _ATTRS_ >attrs)
`flags` is a bitfield containing any of the flags defined in
`SFTPStream.OPEN_MODE`. Use the static method `SFTPStream.flagsToString()`
to convert the value to a mode string to be used by `fs.open()` (e.g. `'r'`).
Respond using one of the following:
* `handle()` - This indicates a successful opening of the file and passes
the given handle back to the client to use to refer to this open file for
future operations (e.g. reading, writing, closing).
* `status()` - Use this to indicate a failure to open the requested file.
* **READ**(< _integer_ >reqID, < _Buffer_ >handle, < _integer_ >offset, < _integer_ >length)
Respond using one of the following:
* `data()` - Use this to send the requested chunk of data back to the client.
The amount of data sent is allowed to be less than the `length` requested,
for example if the file ends between `offset` and `offset + length`.
* `status()` - Use this to indicate either end of file (`STATUS_CODE.EOF`)
has been reached (`offset` is past the end of the file) or if an error
occurred while reading the requested part of the file.
* **WRITE**(< _integer_ >reqID, < _Buffer_ >handle, < _integer_ >offset, < _Buffer_ >data)
Respond using:
* `status()` - Use this to indicate success/failure of the write to the file.
* **FSTAT**(< _integer_ >reqID, < _Buffer_ >handle)
Respond using one of the following:
* `attrs()` - Use this to send the attributes for the requested
file/directory back to the client.
* `status()` - Use this to indicate an error occurred while accessing the
file/directory.
* **FSETSTAT**(< _integer_ >reqID, < _Buffer_ >handle, < _ATTRS_ >attrs)
Respond using:
* `status()` - Use this to indicates success/failure of the setting of the
given file/directory attributes.
* **CLOSE**(< _integer_ >reqID, < _Buffer_ >handle)
Respond using:
* `status()` - Use this to indicate success (`STATUS_CODE.OK`) or failure of
the closing of the file identified by `handle`.
* **OPENDIR**(< _integer_ >reqID, < _string_ >path)
Respond using one of the following:
* `handle()` - This indicates a successful opening of the directory and
passes the given handle back to the client to use to refer to this open
directory for future operations (e.g. reading directory contents, closing).
* `status()` - Use this to indicate a failure to open the requested
directory.
* **READDIR**(< _integer_ >reqID, < _Buffer_ >handle)
Respond using one of the following:
* `name()` - Use this to send one or more directory listings for the open
directory back to the client.
* `status()` - Use this to indicate either end of directory contents
(`STATUS_CODE.EOF`) or if an error occurred while reading the directory
contents.
* **LSTAT**(< _integer_ >reqID, < _string_ >path)
Respond using one of the following:
* `attrs()` - Use this to send the attributes for the requested
file/directory back to the client.
* `status()` - Use this to indicate an error occurred while accessing the
file/directory.
* **STAT**(< _integer_ >reqID, < _string_ >path)
Respond using one of the following:
* `attrs()` - Use this to send the attributes for the requested
file/directory back to the client.
* `status()` - Use this to indicate an error occurred while accessing the
file/directory.
* **REMOVE**(< _integer_ >reqID, < _string_ >path)
Respond using:
* `status()` - Use this to indicate success/failure of the removal of the
file at `path`.
* **RMDIR**(< _integer_ >reqID, < _string_ >path)
Respond using:
* `status()` - Use this to indicate success/failure of the removal of the
directory at `path`.
* **REALPATH**(< _integer_ >reqID, < _string_ >path)
Respond using one of the following:
* `name()` - Use this to respond with a normalized version of `path`.
No file/directory attributes are required to be sent in this response.
* `status()` - Use this to indicate a failure in normalizing `path`.
* **READLINK**(< _integer_ >reqID, < _string_ >path)
Respond using one of the following:
* `name()` - Use this to respond with the target of the symlink at `path`.
No file/directory attributes are required to be sent in this response.
* `status()` - Use this to indicate a failure in reading the symlink at
`path`.
* **SETSTAT**(< _integer_ >reqID, < _string_ >path, < _ATTRS_ >attrs)
Respond using:
* `status()` - Use this to indicates success/failure of the setting of the
given file/directory attributes.
* **MKDIR**(< _integer_ >reqID, < _string_ >path, < _ATTRS_ >attrs)
Respond using:
* `status()` - Use this to indicate success/failure of the creation of the
directory at `path`.
* **RENAME**(< _integer_ >reqID, < _string_ >oldPath, < _string_ >newPath)
Respond using:
* `status()` - Use this to indicate success/failure of the renaming of the
file/directory at `oldPath` to `newPath`.
* **SYMLINK**(< _integer_ >reqID, < _string_ >linkPath, < _string_ >targetPath)
Respond using:
* `status()` - Use this to indicate success/failure of the symlink creation.
SFTPStream static constants
---------------------------
* **SFTPStream.STATUS_CODE** - _object_ - Contains the various status codes (for use especially with `status()`):
* `OK`
* `EOF`
* `NO_SUCH_FILE`
* `PERMISSION_DENIED`
* `FAILURE`
* `BAD_MESSAGE`
* `OP_UNSUPPORTED`
* **SFTPStream.OPEN_MODE** - _object_ - Contains the various open file flags:
* `READ`
* `WRITE`
* `APPEND`
* `CREAT`
* `TRUNC`
* `EXCL`
SFTPStream static methods
-------------------------
* **SFTPStream.stringToFlags**(< _string_ >flagsStr) - _integer_ - Converts string flags (e.g. `'r'`, `'a+'`, etc.) to the appropriate `SFTPStream.OPEN_MODE` flag mask. Returns `null` if conversion failed.
* **SFTPStream.flagsToString**(< _integer_ >flagsMask) - _string_ - Converts flag mask (e.g. number containing `SFTPStream.OPEN_MODE` values) to the appropriate string value. Returns `null` if conversion failed.
SFTPStream methods
------------------
* **(constructor)**(< _object_ >config[, < _string_ >remoteIdentRaw]) - Creates and returns a new SFTPStream instance. SFTPStream instances are Duplex streams. `remoteIdentRaw` can be the raw SSH identification string of the remote party. This is used to change internal behavior based on particular SFTP implementations. `config` can contain:
* **server** - _boolean_ - Set to `true` to create an instance in server mode. **Default:** `false`
* **highWaterMark** - _integer_ - This is the `highWaterMark` to use for the stream. **Default:** `32 * 1024`
* **debug** - _function_ - Set this to a function that receives a single string argument to get detailed (local) debug information. **Default:** (none)
**Client-only methods**
* **fastGet**(< _string_ >remotePath, < _string_ >localPath[, < _object_ >options], < _function_ >callback) - _(void)_ - Downloads a file at `remotePath` to `localPath` using parallel reads for faster throughput. `options` can have the following properties:
* **concurrency** - _integer_ - Number of concurrent reads **Default:** `64`
* **chunkSize** - _integer_ - Size of each read in bytes **Default:** `32768`
* **step** - _function_(< _integer_ >total_transferred, < _integer_ >chunk, < _integer_ >total) - Called every time a part of a file was transferred
`callback` has 1 parameter: < _Error_ >err.
* **fastPut**(< _string_ >localPath, < _string_ >remotePath[, < _object_ >options], < _function_ >callback) - _(void)_ - Uploads a file from `localPath` to `remotePath` using parallel reads for faster throughput. `options` can have the following properties:
* **concurrency** - _integer_ - Number of concurrent reads **Default:** `64`
* **chunkSize** - _integer_ - Size of each read in bytes **Default:** `32768`
* **step** - _function_(< _integer_ >total_transferred, < _integer_ >chunk, < _integer_ >total) - Called every time a part of a file was transferred
* **mode** - _mixed_ - Integer or string representing the file mode to set for the uploaded file.
`callback` has 1 parameter: < _Error_ >err.
* **createReadStream**(< _string_ >path[, < _object_ >options]) - _ReadStream_ - Returns a new readable stream for `path`. `options` has the following defaults:
```javascript
{ flags: 'r',
encoding: null,
handle: null,
mode: 0o666,
autoClose: true
}
```
`options` can include `start` and `end` values to read a range of bytes from the file instead of the entire file. Both `start` and `end` are inclusive and start at 0. The `encoding` can be `'utf8'`, `'ascii'`, or `'base64'`.
If `autoClose` is false, then the file handle won't be closed, even if there's an error. It is your responsiblity to close it and make sure there's no file handle leak. If `autoClose` is set to true (default behavior), on `error` or `end` the file handle will be closed automatically.
An example to read the last 10 bytes of a file which is 100 bytes long:
```javascript
sftp.createReadStream('sample.txt', {start: 90, end: 99});
```
* **createWriteStream**(< _string_ >path[, < _object_ >options]) - _WriteStream_ - Returns a new writable stream for `path`. `options` has the following defaults:
```javascript
{
flags: 'w',
encoding: null,
mode: 0o666,
autoClose: true
}
```
`options` may also include a `start` option to allow writing data at some position past the beginning of the file. Modifying a file rather than replacing it may require a flags mode of 'r+' rather than the default mode 'w'.
If 'autoClose' is set to false and you pipe to this stream, this stream will not automatically close after there is no more data upstream -- allowing future pipes and/or manual writes.
* **open**(< _string_ >filename, < _string_ >flags, [< _mixed_ >attrs_mode, ]< _function_ >callback) - _boolean_ - Opens a file `filename` with `flags` with optional _ATTRS_ object or file mode `attrs_mode`. `flags` is any of the flags supported by `fs.open` (except sync flag). Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _Buffer_ >handle.
* **close**(< _Buffer_ >handle, < _function_ >callback) - _boolean_ - Closes the resource associated with `handle` given by open() or opendir(). Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **readData**(< _Buffer_ >handle, < _Buffer_ >buffer, < _integer_ >offset, < _integer_ >length, < _integer_ >position, < _function_ >callback) - _boolean_ - Reads `length` bytes from the resource associated with `handle` starting at `position` and stores the bytes in `buffer` starting at `offset`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 4 parameters: < _Error_ >err, < _integer_ >bytesRead, < _Buffer_ >buffer (offset adjusted), < _integer_ >position.
* **writeData**(< _Buffer_ >handle, < _Buffer_ >buffer, < _integer_ >offset, < _integer_ >length, < _integer_ >position, < _function_ >callback) - _boolean_ - Writes `length` bytes from `buffer` starting at `offset` to the resource associated with `handle` starting at `position`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **fstat**(< _Buffer_ >handle, < _function_ >callback) - _boolean_ - Retrieves attributes for the resource associated with `handle`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _Stats_ >stats.
* **fsetstat**(< _Buffer_ >handle, < _ATTRS_ >attributes, < _function_ >callback) - _boolean_ - Sets the attributes defined in `attributes` for the resource associated with `handle`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **futimes**(< _Buffer_ >handle, < _mixed_ >atime, < _mixed_ >mtime, < _function_ >callback) - _boolean_ - Sets the access time and modified time for the resource associated with `handle`. `atime` and `mtime` can be Date instances or UNIX timestamps. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **fchown**(< _Buffer_ >handle, < _integer_ >uid, < _integer_ >gid, < _function_ >callback) - _boolean_ - Sets the owner for the resource associated with `handle`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **fchmod**(< _Buffer_ >handle, < _mixed_ >mode, < _function_ >callback) - _boolean_ - Sets the mode for the resource associated with `handle`. `mode` can be an integer or a string containing an octal number. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **opendir**(< _string_ >path, < _function_ >callback) - _boolean_ - Opens a directory `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _Buffer_ >handle.
* **readdir**(< _mixed_ >location, < _function_ >callback) - _boolean_ - Retrieves a directory listing. `location` can either be a _Buffer_ containing a valid directory handle from opendir() or a _string_ containing the path to a directory. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _mixed_ >list. `list` is an _Array_ of `{ filename: 'foo', longname: '....', attrs: {...} }` style objects (attrs is of type _ATTR_). If `location` is a directory handle, this function may need to be called multiple times until `list` is boolean false, which indicates that no more directory entries are available for that directory handle.
* **unlink**(< _string_ >path, < _function_ >callback) - _boolean_ - Removes the file/symlink at `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **rename**(< _string_ >srcPath, < _string_ >destPath, < _function_ >callback) - _boolean_ - Renames/moves `srcPath` to `destPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **mkdir**(< _string_ >path, [< _ATTRS_ >attributes, ]< _function_ >callback) - _boolean_ - Creates a new directory `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **rmdir**(< _string_ >path, < _function_ >callback) - _boolean_ - Removes the directory at `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **stat**(< _string_ >path, < _function_ >callback) - _boolean_ - Retrieves attributes for `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameter: < _Error_ >err, < _Stats_ >stats.
* **lstat**(< _string_ >path, < _function_ >callback) - _boolean_ - Retrieves attributes for `path`. If `path` is a symlink, the link itself is stat'ed instead of the resource it refers to. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _Stats_ >stats.
* **setstat**(< _string_ >path, < _ATTRS_ >attributes, < _function_ >callback) - _boolean_ - Sets the attributes defined in `attributes` for `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **utimes**(< _string_ >path, < _mixed_ >atime, < _mixed_ >mtime, < _function_ >callback) - _boolean_ - Sets the access time and modified time for `path`. `atime` and `mtime` can be Date instances or UNIX timestamps. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **chown**(< _string_ >path, < _integer_ >uid, < _integer_ >gid, < _function_ >callback) - _boolean_ - Sets the owner for `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **chmod**(< _string_ >path, < _mixed_ >mode, < _function_ >callback) - _boolean_ - Sets the mode for `path`. `mode` can be an integer or a string containing an octal number. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **readlink**(< _string_ >path, < _function_ >callback) - _boolean_ - Retrieves the target for a symlink at `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _string_ >target.
* **symlink**(< _string_ >targetPath, < _string_ >linkPath, < _function_ >callback) - _boolean_ - Creates a symlink at `linkPath` to `targetPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **realpath**(< _string_ >path, < _function_ >callback) - _boolean_ - Resolves `path` to an absolute path. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _string_ >absPath.
* **ext_openssh_rename**(< _string_ >srcPath, < _string_ >destPath, < _function_ >callback) - _boolean_ - **OpenSSH extension** Performs POSIX rename(3) from `srcPath` to `destPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **ext_openssh_statvfs**(< _string_ >path, < _function_ >callback) - _boolean_ - **OpenSSH extension** Performs POSIX statvfs(2) on `path`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _object_ >fsInfo. `fsInfo` contains the information as found in the [statvfs struct](http://linux.die.net/man/2/statvfs).
* **ext_openssh_fstatvfs**(< _Buffer_ >handle, < _function_ >callback) - _boolean_ - **OpenSSH extension** Performs POSIX fstatvfs(2) on open handle `handle`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 2 parameters: < _Error_ >err, < _object_ >fsInfo. `fsInfo` contains the information as found in the [statvfs struct](http://linux.die.net/man/2/statvfs).
* **ext_openssh_hardlink**(< _string_ >targetPath, < _string_ >linkPath, < _function_ >callback) - _boolean_ - **OpenSSH extension** Performs POSIX link(2) to create a hard link to `targetPath` at `linkPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
* **ext_openssh_fsync**(< _Buffer_ >handle, < _function_ >callback) - _boolean_ - **OpenSSH extension** Performs POSIX fsync(3) on the open handle `handle`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `callback` has 1 parameter: < _Error_ >err.
**Server-only methods**
* **status**(< _integer_ >reqID, < _integer_ >statusCode[, < _string_ >message]) - _boolean_ - Sends a status response for the request identified by `id`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **handle**(< _integer_ >reqID, < _Buffer_ >handle) - _boolean_ - Sends a handle response for the request identified by `id`. `handle` must be less than 256 bytes and is an opaque value that could merely contain the value of a backing file descriptor or some other unique, custom value. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **data**(< _integer_ >reqID, < _mixed_ >data[, < _string_ >encoding]) - _boolean_ - Sends a data response for the request identified by `id`. `data` can be a _Buffer_ or _string_. If `data` is a string, `encoding` is the encoding of `data`. Returns `false` if you should wait for the `continue` event before sending any more traffic.
* **name**(< _integer_ >reqID, < _array_ >names) - _boolean_ - Sends a name response for the request identified by `id`. Returns `false` if you should wait for the `continue` event before sending any more traffic. `names` must be an _array_ of _object_ where each _object_ can contain:
* **filename** - _string_ - The entry's name.
* **longname** - _string_ - This is the `ls -l`-style format for the entry (e.g. `-rwxr--r-- 1 bar bar 718 Dec 8 2009 foo`)
* **attrs** - _ATTRS_ - This is an optional _ATTRS_ object that contains requested/available attributes for the entry.
* **attrs**(< _integer_ >reqID, < _ATTRS_ >attrs) - _boolean_ - Sends an attrs response for the request identified by `id`. `attrs` contains the requested/available attributes.
ATTRS
-----
An object with the following valid properties:
* **mode** - _integer_ - Mode/permissions for the resource.
* **uid** - _integer_ - User ID of the resource.
* **gid** - _integer_ - Group ID of the resource.
* **size** - _integer_ - Resource size in bytes.
* **atime** - _integer_ - UNIX timestamp of the access time of the resource.
* **mtime** - _integer_ - UNIX timestamp of the modified time of the resource.
When supplying an ATTRS object to one of the SFTP methods:
* `atime` and `mtime` can be either a Date instance or a UNIX timestamp.
* `mode` can either be an integer or a string containing an octal number.
Stats
-----
An object with the same attributes as an ATTRS object with the addition of the following methods:
* `stats.isDirectory()`
* `stats.isFile()`
* `stats.isBlockDevice()`
* `stats.isCharacterDevice()`
* `stats.isSymbolicLink()`
* `stats.isFIFO()`
* `stats.isSocket()`

6
build/node_modules/ssh2-streams/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
module.exports = {
SFTPStream: require('./lib/sftp'),
SSH2Stream: require('./lib/ssh'),
utils: require('./lib/utils'),
constants: require('./lib/constants')
};

386
build/node_modules/ssh2-streams/lib/constants.js generated vendored Normal file
View File

@@ -0,0 +1,386 @@
var semver = require('semver');
var i;
var keys;
var len;
var MESSAGE = exports.MESSAGE = {
// Transport layer protocol -- generic (1-19)
DISCONNECT: 1,
IGNORE: 2,
UNIMPLEMENTED: 3,
DEBUG: 4,
SERVICE_REQUEST: 5,
SERVICE_ACCEPT: 6,
// Transport layer protocol -- algorithm negotiation (20-29)
KEXINIT: 20,
NEWKEYS: 21,
// Transport layer protocol -- key exchange method-specific (30-49)
// User auth protocol -- generic (50-59)
USERAUTH_REQUEST: 50,
USERAUTH_FAILURE: 51,
USERAUTH_SUCCESS: 52,
USERAUTH_BANNER: 53,
// User auth protocol -- user auth method-specific (60-79)
// Connection protocol -- generic (80-89)
GLOBAL_REQUEST: 80,
REQUEST_SUCCESS: 81,
REQUEST_FAILURE: 82,
// Connection protocol -- channel-related (90-127)
CHANNEL_OPEN: 90,
CHANNEL_OPEN_CONFIRMATION: 91,
CHANNEL_OPEN_FAILURE: 92,
CHANNEL_WINDOW_ADJUST: 93,
CHANNEL_DATA: 94,
CHANNEL_EXTENDED_DATA: 95,
CHANNEL_EOF: 96,
CHANNEL_CLOSE: 97,
CHANNEL_REQUEST: 98,
CHANNEL_SUCCESS: 99,
CHANNEL_FAILURE: 100
// Reserved for client protocols (128-191)
// Local extensions (192-155)
};
for (i = 0, keys = Object.keys(MESSAGE), len = keys.length; i < len; ++i)
MESSAGE[MESSAGE[keys[i]]] = keys[i];
// context-specific message codes:
MESSAGE.KEXDH_INIT = 30;
MESSAGE.KEXDH_REPLY = 31;
MESSAGE.KEXDH_GEX_REQUEST = 34;
MESSAGE.KEXDH_GEX_GROUP = 31;
MESSAGE.KEXDH_GEX_INIT = 32;
MESSAGE.KEXDH_GEX_REPLY = 33;
MESSAGE.KEXECDH_INIT = 30; // included here for completeness
MESSAGE.KEXECDH_REPLY = 31; // included here for completeness
MESSAGE.USERAUTH_PASSWD_CHANGEREQ = 60;
MESSAGE.USERAUTH_PK_OK = 60;
MESSAGE.USERAUTH_INFO_REQUEST = 60;
MESSAGE.USERAUTH_INFO_RESPONSE = 61;
var DYNAMIC_KEXDH_MESSAGE = exports.DYNAMIC_KEXDH_MESSAGE = {};
DYNAMIC_KEXDH_MESSAGE[MESSAGE.KEXDH_GEX_GROUP] = 'KEXDH_GEX_GROUP';
DYNAMIC_KEXDH_MESSAGE[MESSAGE.KEXDH_GEX_REPLY] = 'KEXDH_GEX_REPLY';
var KEXDH_MESSAGE = exports.KEXDH_MESSAGE = {};
KEXDH_MESSAGE[MESSAGE.KEXDH_INIT] = 'KEXDH_INIT';
KEXDH_MESSAGE[MESSAGE.KEXDH_REPLY] = 'KEXDH_REPLY';
var DISCONNECT_REASON = exports.DISCONNECT_REASON = {
HOST_NOT_ALLOWED_TO_CONNECT: 1,
PROTOCOL_ERROR: 2,
KEY_EXCHANGE_FAILED: 3,
RESERVED: 4,
MAC_ERROR: 5,
COMPRESSION_ERROR: 6,
SERVICE_NOT_AVAILABLE: 7,
PROTOCOL_VERSION_NOT_SUPPORTED: 8,
HOST_KEY_NOT_VERIFIABLE: 9,
CONNECTION_LOST: 10,
BY_APPLICATION: 11,
TOO_MANY_CONNECTIONS: 12,
AUTH_CANCELED_BY_USER: 13,
NO_MORE_AUTH_METHODS_AVAILABLE: 14,
ILLEGAL_USER_NAME: 15
};
for (i = 0, keys = Object.keys(DISCONNECT_REASON), len = keys.length;
i < len;
++i) {
DISCONNECT_REASON[DISCONNECT_REASON[keys[i]]] = keys[i];
}
var CHANNEL_OPEN_FAILURE = exports.CHANNEL_OPEN_FAILURE = {
ADMINISTRATIVELY_PROHIBITED: 1,
CONNECT_FAILED: 2,
UNKNOWN_CHANNEL_TYPE: 3,
RESOURCE_SHORTAGE: 4
};
for (i = 0, keys = Object.keys(CHANNEL_OPEN_FAILURE), len = keys.length;
i < len;
++i) {
CHANNEL_OPEN_FAILURE[CHANNEL_OPEN_FAILURE[keys[i]]] = keys[i];
}
var TERMINAL_MODE = exports.TERMINAL_MODE = {
TTY_OP_END: 0, // Indicates end of options.
VINTR: 1, // Interrupt character; 255 if none. Similarly for the
// other characters. Not all of these characters are
// supported on all systems.
VQUIT: 2, // The quit character (sends SIGQUIT signal on POSIX
// systems).
VERASE: 3, // Erase the character to left of the cursor.
VKILL: 4, // Kill the current input line.
VEOF: 5, // End-of-file character (sends EOF from the terminal).
VEOL: 6, // End-of-line character in addition to carriage return
// and/or linefeed.
VEOL2: 7, // Additional end-of-line character.
VSTART: 8, // Continues paused output (normally control-Q).
VSTOP: 9, // Pauses output (normally control-S).
VSUSP: 10, // Suspends the current program.
VDSUSP: 11, // Another suspend character.
VREPRINT: 12, // Reprints the current input line.
VWERASE: 13, // Erases a word left of cursor.
VLNEXT: 14, // Enter the next character typed literally, even if it
// is a special character
VFLUSH: 15, // Character to flush output.
VSWTCH: 16, // Switch to a different shell layer.
VSTATUS: 17, // Prints system status line (load, command, pid, etc).
VDISCARD: 18, // Toggles the flushing of terminal output.
IGNPAR: 30, // The ignore parity flag. The parameter SHOULD be 0
// if this flag is FALSE, and 1 if it is TRUE.
PARMRK: 31, // Mark parity and framing errors.
INPCK: 32, // Enable checking of parity errors.
ISTRIP: 33, // Strip 8th bit off characters.
INLCR: 34, // Map NL into CR on input.
IGNCR: 35, // Ignore CR on input.
ICRNL: 36, // Map CR to NL on input.
IUCLC: 37, // Translate uppercase characters to lowercase.
IXON: 38, // Enable output flow control.
IXANY: 39, // Any char will restart after stop.
IXOFF: 40, // Enable input flow control.
IMAXBEL: 41, // Ring bell on input queue full.
ISIG: 50, // Enable signals INTR, QUIT, [D]SUSP.
ICANON: 51, // Canonicalize input lines.
XCASE: 52, // Enable input and output of uppercase characters by
// preceding their lowercase equivalents with "\".
ECHO: 53, // Enable echoing.
ECHOE: 54, // Visually erase chars.
ECHOK: 55, // Kill character discards current line.
ECHONL: 56, // Echo NL even if ECHO is off.
NOFLSH: 57, // Don't flush after interrupt.
TOSTOP: 58, // Stop background jobs from output.
IEXTEN: 59, // Enable extensions.
ECHOCTL: 60, // Echo control characters as ^(Char).
ECHOKE: 61, // Visual erase for line kill.
PENDIN: 62, // Retype pending input.
OPOST: 70, // Enable output processing.
OLCUC: 71, // Convert lowercase to uppercase.
ONLCR: 72, // Map NL to CR-NL.
OCRNL: 73, // Translate carriage return to newline (output).
ONOCR: 74, // Translate newline to carriage return-newline
// (output).
ONLRET: 75, // Newline performs a carriage return (output).
CS7: 90, // 7 bit mode.
CS8: 91, // 8 bit mode.
PARENB: 92, // Parity enable.
PARODD: 93, // Odd parity, else even.
TTY_OP_ISPEED: 128, // Specifies the input baud rate in bits per second.
TTY_OP_OSPEED: 129 // Specifies the output baud rate in bits per second.
};
for (i = 0, keys = Object.keys(TERMINAL_MODE), len = keys.length; i < len; ++i)
TERMINAL_MODE[TERMINAL_MODE[keys[i]]] = keys[i];
var CHANNEL_EXTENDED_DATATYPE = exports.CHANNEL_EXTENDED_DATATYPE = {
STDERR: 1
};
for (i = 0, keys = Object.keys(CHANNEL_EXTENDED_DATATYPE), len = keys.length;
i < len;
++i) {
CHANNEL_EXTENDED_DATATYPE[CHANNEL_EXTENDED_DATATYPE[keys[i]]] = keys[i];
}
exports.SIGNALS = ['ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT',
'QUIT', 'SEGV', 'TERM', 'USR1', 'USR2', 'KILL',
'PIPE'];
var DEFAULT_KEX = [
'diffie-hellman-group14-sha1' // REQUIRED
];
var SUPPORTED_KEX = [
'diffie-hellman-group1-sha1' // REQUIRED
];
if (semver.gte(process.version, '0.11.12')) {
// https://tools.ietf.org/html/rfc4419#section-4
DEFAULT_KEX = [
'diffie-hellman-group-exchange-sha256'
].concat(DEFAULT_KEX);
SUPPORTED_KEX = [
'diffie-hellman-group-exchange-sha1'
].concat(SUPPORTED_KEX);
}
if (semver.gte(process.version, '0.11.14')) {
// https://tools.ietf.org/html/rfc5656#section-10.1
DEFAULT_KEX = [
'ecdh-sha2-nistp256',
'ecdh-sha2-nistp384',
'ecdh-sha2-nistp521'
].concat(DEFAULT_KEX);
}
var KEX_BUF = new Buffer(DEFAULT_KEX.join(','), 'ascii');
SUPPORTED_KEX = DEFAULT_KEX.concat(SUPPORTED_KEX);
var DEFAULT_SERVER_HOST_KEY = [
'ssh-rsa'
];
var SUPPORTED_SERVER_HOST_KEY = [
'ssh-dss'
];
if (semver.gte(process.version, '5.2.0')) {
// ECDSA keys are only supported in v5.2.0+ because of a crypto change that
// made it possible to (efficiently) generate an ECDSA public key from a
// private key (commit nodejs/node#da5ac55c83eb2c09cfb3baf7875529e8f1113529)
DEFAULT_SERVER_HOST_KEY.push(
'ecdsa-sha2-nistp256',
'ecdsa-sha2-nistp384',
'ecdsa-sha2-nistp521'
);
}
var SERVER_HOST_KEY_BUF = new Buffer(DEFAULT_SERVER_HOST_KEY.join(','),
'ascii');
SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat(
SUPPORTED_SERVER_HOST_KEY
);
var DEFAULT_CIPHER = [];
var SUPPORTED_CIPHER = [
'aes256-cbc',
'aes192-cbc',
'aes128-cbc',
'blowfish-cbc',
'3des-cbc',
// http://tools.ietf.org/html/rfc4345#section-4:
'arcfour256',
'arcfour128',
'cast128-cbc',
'arcfour'
];
if (semver.gte(process.version, '0.11.12')) {
// node v0.11.12 introduced support for setting AAD, which is needed for
// AES-GCM in SSH2
DEFAULT_CIPHER = [
// http://tools.ietf.org/html/rfc5647
'aes128-gcm',
'aes128-gcm@openssh.com',
'aes256-gcm',
'aes256-gcm@openssh.com'
].concat(DEFAULT_CIPHER);
}
DEFAULT_CIPHER = [
// http://tools.ietf.org/html/rfc4344#section-4
'aes128-ctr',
'aes192-ctr',
'aes256-ctr'
].concat(DEFAULT_CIPHER);
var CIPHER_BUF = new Buffer(DEFAULT_CIPHER.join(','), 'ascii');
SUPPORTED_CIPHER = DEFAULT_CIPHER.concat(SUPPORTED_CIPHER);
var DEFAULT_HMAC = [
'hmac-sha2-256',
'hmac-sha2-512',
'hmac-sha1',
];
var SUPPORTED_HMAC = [
'hmac-md5',
'hmac-sha2-256-96', // first 96 bits of HMAC-SHA256
'hmac-sha2-512-96', // first 96 bits of HMAC-SHA512
'hmac-ripemd160',
'hmac-sha1-96', // first 96 bits of HMAC-SHA1
'hmac-md5-96' // first 96 bits of HMAC-MD5
];
var HMAC_BUF = new Buffer(DEFAULT_HMAC.join(','), 'ascii');
SUPPORTED_HMAC = DEFAULT_HMAC.concat(SUPPORTED_HMAC);
var DEFAULT_COMPRESS = [
'none',
'zlib@openssh.com', // ZLIB (LZ77) compression, except
// compression/decompression does not start until after
// successful user authentication
'zlib' // ZLIB (LZ77) compression
];
var SUPPORTED_COMPRESS = [];
var COMPRESS_BUF = new Buffer(DEFAULT_COMPRESS.join(','), 'ascii');
SUPPORTED_COMPRESS = DEFAULT_COMPRESS.concat(SUPPORTED_COMPRESS);
exports.ALGORITHMS = {
KEX: DEFAULT_KEX,
KEX_BUF: KEX_BUF,
SUPPORTED_KEX: SUPPORTED_KEX,
SERVER_HOST_KEY: DEFAULT_SERVER_HOST_KEY,
SERVER_HOST_KEY_BUF: SERVER_HOST_KEY_BUF,
SUPPORTED_SERVER_HOST_KEY: SUPPORTED_SERVER_HOST_KEY,
CIPHER: DEFAULT_CIPHER,
CIPHER_BUF: CIPHER_BUF,
SUPPORTED_CIPHER: SUPPORTED_CIPHER,
HMAC: DEFAULT_HMAC,
HMAC_BUF: HMAC_BUF,
SUPPORTED_HMAC: SUPPORTED_HMAC,
COMPRESS: DEFAULT_COMPRESS,
COMPRESS_BUF: COMPRESS_BUF,
SUPPORTED_COMPRESS: SUPPORTED_COMPRESS
};
exports.SSH_TO_OPENSSL = {
// ECDH key exchange
'ecdh-sha2-nistp256': 'prime256v1', // OpenSSL's name for 'secp256r1'
'ecdh-sha2-nistp384': 'secp384r1',
'ecdh-sha2-nistp521': 'secp521r1',
// Ciphers
'aes128-gcm': 'aes-128-gcm',
'aes256-gcm': 'aes-256-gcm',
'aes128-gcm@openssh.com': 'aes-128-gcm',
'aes256-gcm@openssh.com': 'aes-256-gcm',
'3des-cbc': 'des-ede3-cbc',
'blowfish-cbc': 'bf-cbc',
'aes256-cbc': 'aes-256-cbc',
'aes192-cbc': 'aes-192-cbc',
'aes128-cbc': 'aes-128-cbc',
'idea-cbc': 'idea-cbc',
'cast128-cbc': 'cast-cbc',
'rijndael-cbc@lysator.liu.se': 'aes-256-cbc',
'arcfour128': 'rc4',
'arcfour256': 'rc4',
'arcfour512': 'rc4',
'arcfour': 'rc4',
'camellia128-cbc': 'camellia-128-cbc',
'camellia192-cbc': 'camellia-192-cbc',
'camellia256-cbc': 'camellia-256-cbc',
'camellia128-cbc@openssh.com': 'camellia-128-cbc',
'camellia192-cbc@openssh.com': 'camellia-192-cbc',
'camellia256-cbc@openssh.com': 'camellia-256-cbc',
'3des-ctr': 'des-ede3',
'blowfish-ctr': 'bf-ecb',
'aes256-ctr': 'aes-256-ctr',
'aes192-ctr': 'aes-192-ctr',
'aes128-ctr': 'aes-128-ctr',
'cast128-ctr': 'cast5-ecb',
'camellia128-ctr': 'camellia-128-ecb',
'camellia192-ctr': 'camellia-192-ecb',
'camellia256-ctr': 'camellia-256-ecb',
'camellia128-ctr@openssh.com': 'camellia-128-ecb',
'camellia192-ctr@openssh.com': 'camellia-192-ecb',
'camellia256-ctr@openssh.com': 'camellia-256-ecb',
// HMAC
'hmac-sha1-96': 'sha1',
'hmac-sha1': 'sha1',
'hmac-sha2-256': 'sha256',
'hmac-sha2-256-96': 'sha256',
'hmac-sha2-512': 'sha512',
'hmac-sha2-512-96': 'sha512',
'hmac-md5-96': 'md5',
'hmac-md5': 'md5',
'hmac-ripemd160': 'ripemd160'
};
var BUGS = exports.BUGS = {
BAD_DHGEX: 1,
OLD_EXIT: 2,
DYN_RPORT_BUG: 4
};
exports.BUGGY_IMPLS = [
[ 'Cisco-1.25', BUGS.BAD_DHGEX ],
[ /^[0-9.]+$/, BUGS.OLD_EXIT ], // old SSH.com implementations
[ /^OpenSSH_5\.\d+/, BUGS.DYN_RPORT_BUG ]
];

1186
build/node_modules/ssh2-streams/lib/jsbn.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

239
build/node_modules/ssh2-streams/lib/keyParser.js generated vendored Normal file
View File

@@ -0,0 +1,239 @@
// TODO:
// * handle multi-line header values (OpenSSH)?
// * more thorough validation?
var utils;
var Ber = require('asn1').Ber;
var semver = require('semver');
var RE_PPK = /^PuTTY-User-Key-File-2: ssh-(rsa|dss)\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;
var RE_HEADER_OPENSSH_PRIV = /^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----$/i;
var RE_FOOTER_OPENSSH_PRIV = /^-----END (?:RSA|DSA|EC) PRIVATE KEY-----$/i;
var RE_HEADER_OPENSSH_PUB = /^((?:(?:ssh-(rsa|dss))|ecdsa-sha2-nistp(256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z\/+=]+)(?:$|\s+([\S].*)?)$/i;
var RE_HEADER_RFC4716_PUB = /^---- BEGIN SSH2 PUBLIC KEY ----$/i;
var RE_FOOTER_RFC4716_PUB = /^---- END SSH2 PUBLIC KEY ----$/i;
var RE_HEADER_OPENSSH = /^([^:]+):\s*([\S].*)?$/i;
var RE_HEADER_RFC4716 = /^([^:]+): (.*)?$/i;
module.exports = function(data) {
if (Buffer.isBuffer(data))
data = data.toString('utf8');
else if (typeof data !== 'string')
return new Error('Key data must be a Buffer or string');
var ret = {
fulltype: undefined,
type: undefined,
curve: undefined,
extra: undefined,
comment: undefined,
encryption: undefined,
private: undefined,
privateOrig: undefined,
public: undefined,
publicOrig: undefined
};
var m;
var i;
var len;
data = data.trim().split(/\r\n|\n/);
while (!data[0].length)
data.shift();
while (!data.slice(-1)[0].length)
data.pop();
var orig = data.join('\n');
if ((m = RE_HEADER_OPENSSH_PRIV.exec(data[0]))
&& RE_FOOTER_OPENSSH_PRIV.test(data.slice(-1))) {
// OpenSSH private key
var keyType = m[1].toLowerCase();
if (keyType === 'dsa')
keyType = 'dss';
if (keyType === 'ec' && semver.lt(process.version, '5.2.0')) {
return new Error(
'EC private keys are not supported in this version of node'
);
}
if (!RE_HEADER_OPENSSH.test(data[1])) {
// unencrypted, no headers
var privData = new Buffer(data.slice(1, -1).join(''), 'base64');
if (keyType !== 'ec') {
ret.fulltype = 'ssh-' + keyType;
} else {
// ECDSA
var asnReader = new Ber.Reader(privData);
asnReader.readSequence();
asnReader.readInt();
asnReader.readString(Ber.OctetString, true);
asnReader.readByte(); // Skip "complex" context type byte
var offset = asnReader.readLength(); // Skip context length
if (offset !== null) {
asnReader._offset = offset;
switch (asnReader.readOID()) {
case '1.2.840.10045.3.1.7':
// prime256v1/secp256r1
ret.fulltype = 'ecdsa-sha2-nistp256';
break;
case '1.3.132.0.34':
// secp384r1
ret.fulltype = 'ecdsa-sha2-nistp384';
break;
case '1.3.132.0.35':
// secp521r1
ret.fulltype = 'ecdsa-sha2-nistp521';
break;
}
}
if (ret.fulltype === undefined)
return new Error('Unsupported EC private key type');
}
ret.private = privData;
} else {
// possibly encrypted, headers
for (i = 1, len = data.length; i < len; ++i) {
m = RE_HEADER_OPENSSH.exec(data[i]);
if (m) {
m[1] = m[1].toLowerCase();
if (m[1] === 'dek-info') {
m[2] = m[2].split(',');
ret.encryption = m[2][0].toLowerCase();
if (m[2].length > 1)
ret.extra = m[2].slice(1);
}
} else if (data[i].length)
break;
}
ret.private = new Buffer(data.slice(i, -1).join(''), 'base64');
}
ret.type = keyType;
ret.privateOrig = new Buffer(orig);
} else if (m = RE_HEADER_OPENSSH_PUB.exec(data[0])) {
// OpenSSH public key
ret.fulltype = m[1];
ret.type = (m[2] || 'ec').toLowerCase();
ret.public = new Buffer(m[4], 'base64');
ret.publicOrig = new Buffer(orig);
ret.comment = m[5];
if (m[3]) // ECDSA only
ret.curve = 'nistp' + m[3];
} else if (RE_HEADER_RFC4716_PUB.test(data[0])
&& RE_FOOTER_RFC4716_PUB.test(data.slice(-1))) {
if (data[1].indexOf(': ') === -1) {
// no headers
ret.public = new Buffer(data.slice(1, -1).join(''), 'base64');
} else {
// headers
for (i = 1, len = data.length; i < len; ++i) {
if (data[i].indexOf(': ') === -1) {
if (data[i].length)
break; // start of key data
else
continue; // empty line
}
while (data[i].substr(-1) === '\\') {
if (i + 1 < len) {
data[i] = data[i].slice(0, -1) + data[i + 1];
data.splice(i + 1, 1);
--len;
} else
return new Error('RFC4716 public key missing header continuation line');
}
m = RE_HEADER_RFC4716.exec(data[i]);
if (m) {
m[1] = m[1].toLowerCase();
if (m[1] === 'comment') {
ret.comment = m[2] || '';
if (ret.comment[0] === '"' && ret.comment.substr(-1) === '"')
ret.comment = ret.comment.slice(1, -1);
}
} else
return new Error('RFC4716 public key invalid header line');
}
ret.public = new Buffer(data.slice(i, -1).join(''), 'base64');
}
len = ret.public.readUInt32BE(0, true);
var fulltype = ret.public.toString('ascii', 4, 4 + len);
ret.fulltype = fulltype;
if (fulltype === 'ssh-dss')
ret.type = 'dss';
else if (fulltype === 'ssh-rsa')
ret.type = 'rsa';
else
return new Error('Unsupported RFC4716 public key type: ' + fulltype);
ret.public = ret.public.slice(11);
ret.publicOrig = new Buffer(orig);
} else if (m = RE_PPK.exec(orig)) {
// m[1] = short type
// m[2] = encryption type
// m[3] = comment
// m[4] = base64-encoded public key data:
// for "ssh-rsa":
// string "ssh-rsa"
// mpint e (public exponent)
// mpint n (modulus)
// for "ssh-dss":
// string "ssh-dss"
// mpint p (modulus)
// mpint q (prime)
// mpint g (base number)
// mpint y (public key parameter: g^x mod p)
// m[5] = base64-encoded private key data:
// for "ssh-rsa":
// mpint d (private exponent)
// mpint p (prime 1)
// mpint q (prime 2)
// mpint iqmp ([inverse of q] mod p)
// for "ssh-dss":
// mpint x (private key parameter)
// m[6] = SHA1 HMAC over:
// string name of algorithm ("ssh-dss", "ssh-rsa")
// string encryption type
// string comment
// string public key data
// string private-plaintext (including the final padding)
// avoid cyclic require by requiring on first use
if (!utils)
utils = require('./utils');
ret.ppk = true;
ret.type = m[1];
ret.fulltype = 'ssh-' + m[1];
if (m[2] !== 'none')
ret.encryption = m[2];
ret.comment = m[3];
ret.public = new Buffer(m[4].replace(/\r?\n/g, ''), 'base64');
var privateKey = new Buffer(m[5].replace(/\r?\n/g, ''), 'base64');
ret.privateMAC = m[6].replace(/\r?\n/g, '');
// automatically verify private key MAC if we don't need to wait for
// decryption
if (!ret.encryption) {
var valid = utils.verifyPPKMAC(ret, undefined, privateKey);
if (!valid)
throw new Error('PPK MAC mismatch');
}
// generate a PEM encoded version of the public key
var pubkey = utils.genPublicKey(ret);
ret.public = pubkey.public;
ret.publicOrig = pubkey.publicOrig;
ret.private = privateKey;
// automatically convert private key data to OpenSSL format (including PEM)
// if we don't need to wait for decryption
if (!ret.encryption)
utils.convertPPKPrivate(ret);
} else
return new Error('Unsupported key format');
return ret;
};

2967
build/node_modules/ssh2-streams/lib/sftp.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

5403
build/node_modules/ssh2-streams/lib/ssh.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

817
build/node_modules/ssh2-streams/lib/utils.js generated vendored Normal file
View File

@@ -0,0 +1,817 @@
var crypto = require('crypto');
var Ber = require('asn1').Ber;
var BigInteger = require('./jsbn'); // only for converting PPK -> OpenSSL format
var SSH_TO_OPENSSL = require('./constants').SSH_TO_OPENSSL;
var RE_STREAM = /^arcfour/i;
var RE_KEY_LEN = /(.{64})/g;
// XXX the value of 2400 from dropbear is only for certain strings, not all
// strings. for example the list strings used during handshakes
var MAX_STRING_LEN = Infinity;//2400; // taken from dropbear
var PPK_IV = new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
module.exports = {
iv_inc: iv_inc,
isStreamCipher: isStreamCipher,
readInt: readInt,
readString: readString,
parseKey: require('./keyParser'),
genPublicKey: genPublicKey,
convertPPKPrivate: convertPPKPrivate,
verifyPPKMAC: verifyPPKMAC,
decryptKey: decryptKey,
DSASigBERToBare: DSASigBERToBare,
DSASigBareToBER: DSASigBareToBER,
ECDSASigASN1ToSSH: ECDSASigASN1ToSSH,
ECDSASigSSHToASN1: ECDSASigSSHToASN1,
RSAKeySSHToASN1: RSAKeySSHToASN1,
DSAKeySSHToASN1: DSAKeySSHToASN1,
ECDSAKeySSHToASN1: ECDSAKeySSHToASN1
};
function iv_inc(iv) {
var n = 12;
var c = 0;
do {
--n;
c = iv[n];
if (c === 255)
iv[n] = 0;
else {
iv[n] = ++c;
return;
}
} while (n > 4);
}
function isStreamCipher(name) {
return RE_STREAM.test(name);
}
function readInt(buffer, start, stream, cb) {
var bufferLen = buffer.length;
if (start < 0 || start >= bufferLen || (bufferLen - start) < 4) {
stream && stream._cleanup(cb);
return false;
}
return buffer.readUInt32BE(start, true);
}
function DSASigBERToBare(signature) {
if (signature.length <= 40)
return signature;
// This is a quick and dirty way to get from BER encoded r and s that
// OpenSSL gives us, to just the bare values back to back (40 bytes
// total) like OpenSSH (and possibly others) are expecting
var asnReader = new Ber.Reader(signature);
asnReader.readSequence();
var r = asnReader.readString(Ber.Integer, true);
var s = asnReader.readString(Ber.Integer, true);
var rOffset = 0;
var sOffset = 0;
if (r.length < 20) {
var rNew = new Buffer(20);
r.copy(rNew, 1);
r = rNew;
r[0] = 0;
}
if (s.length < 20) {
var sNew = new Buffer(20);
s.copy(sNew, 1);
s = sNew;
s[0] = 0;
}
if (r.length > 20 && r[0] === 0x00)
rOffset = 1;
if (s.length > 20 && s[0] === 0x00)
sOffset = 1;
var newSig = new Buffer((r.length - rOffset) + (s.length - sOffset));
r.copy(newSig, 0, rOffset);
s.copy(newSig, r.length - rOffset, sOffset);
return newSig;
}
function DSASigBareToBER(signature) {
if (signature.length > 40)
return signature;
// Change bare signature r and s values to ASN.1 BER values for OpenSSL
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
var r = signature.slice(0, 20);
var s = signature.slice(20);
if (r[0] & 0x80) {
var rNew = new Buffer(21);
rNew[0] = 0x00;
r.copy(rNew, 1);
r = rNew;
} else if (r[0] === 0x00 && !(r[1] & 0x80)) {
r = r.slice(1);
}
if (s[0] & 0x80) {
var sNew = new Buffer(21);
sNew[0] = 0x00;
s.copy(sNew, 1);
s = sNew;
} else if (s[0] === 0x00 && !(s[1] & 0x80)) {
s = s.slice(1);
}
asnWriter.writeBuffer(r, Ber.Integer);
asnWriter.writeBuffer(s, Ber.Integer);
asnWriter.endSequence();
return asnWriter.buffer;
}
function ECDSASigASN1ToSSH(signature) {
if (signature[0] === 0x00)
return signature;
// Convert SSH signature parameters to ASN.1 BER values for OpenSSL
var asnReader = new Ber.Reader(signature);
asnReader.readSequence();
var r = asnReader.readString(Ber.Integer, true);
var s = asnReader.readString(Ber.Integer, true);
if (r === null || s === null)
throw new Error('Invalid signature');
var newSig = new Buffer(4 + r.length + 4 + s.length);
newSig.writeUInt32BE(r.length, 0, true);
r.copy(newSig, 4);
newSig.writeUInt32BE(s.length, 4 + r.length, true);
s.copy(newSig, 4 + 4 + r.length);
return newSig;
}
function ECDSASigSSHToASN1(signature, self, callback) {
// Convert SSH signature parameters to ASN.1 BER values for OpenSSL
var r = readString(signature, 0, self, callback);
if (r === false)
return false;
var s = readString(signature, signature._pos, self, callback);
if (s === false)
return false;
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
asnWriter.writeBuffer(r, Ber.Integer);
asnWriter.writeBuffer(s, Ber.Integer);
asnWriter.endSequence();
return asnWriter.buffer;
}
function RSAKeySSHToASN1(key, self, callback) {
// Convert SSH key parameters to ASN.1 BER values for OpenSSL
var e = readString(key, key._pos, self, callback);
if (e === false)
return false;
var n = readString(key, key._pos, self, callback);
if (n === false)
return false;
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
// algorithm
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption
// algorithm parameters (RSA has none)
asnWriter.writeNull();
asnWriter.endSequence();
// subjectPublicKey
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.startSequence();
asnWriter.writeBuffer(n, Ber.Integer);
asnWriter.writeBuffer(e, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
asnWriter.endSequence();
return asnWriter.buffer;
}
function DSAKeySSHToASN1(key, self, callback) {
// Convert SSH key parameters to ASN.1 BER values for OpenSSL
var p = readString(key, key._pos, self, callback);
if (p === false)
return false;
var q = readString(key, key._pos, self, callback);
if (q === false)
return false;
var g = readString(key, key._pos, self, callback);
if (g === false)
return false;
var y = readString(key, key._pos, self, callback);
if (y === false)
return false;
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
// algorithm
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa
// algorithm parameters
asnWriter.startSequence();
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
// subjectPublicKey
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
return asnWriter.buffer;
}
function ECDSAKeySSHToASN1(key, self, callback) {
// Convert SSH key parameters to ASN.1 BER values for OpenSSL
var curve = readString(key, key._pos, self, callback);
if (curve === false)
return false;
var Q = readString(key, key._pos, self, callback);
if (Q === false)
return false;
var ecCurveOID;
switch (curve.toString('ascii')) {
case 'nistp256':
// prime256v1/secp256r1
ecCurveOID = '1.2.840.10045.3.1.7';
break;
case 'nistp384':
// secp384r1
ecCurveOID = '1.3.132.0.34';
break;
case 'nistp521':
// secp521r1
ecCurveOID = '1.3.132.0.35';
break;
default:
return false;
}
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
// algorithm
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10045.2.1'); // id-ecPublicKey
// algorithm parameters (namedCurve)
asnWriter.writeOID(ecCurveOID);
asnWriter.endSequence();
// subjectPublicKey
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
// XXX: hack to write a raw buffer without a tag -- yuck
asnWriter._ensure(Q.length);
Q.copy(asnWriter._buf, asnWriter._offset, 0, Q.length);
asnWriter._offset += Q.length;
// end hack
asnWriter.endSequence();
asnWriter.endSequence();
return asnWriter.buffer;
}
function decryptKey(keyInfo, passphrase) {
if (keyInfo._decrypted || !keyInfo.encryption)
return;
var keylen = 0;
var key;
var iv;
var dc;
keyInfo.encryption = (SSH_TO_OPENSSL[keyInfo.encryption]
|| keyInfo.encryption);
switch (keyInfo.encryption) {
case 'aes-256-cbc':
case 'aes-256-ctr':
keylen = 32;
break;
case 'des-ede3-cbc':
case 'des-ede3':
case 'aes-192-cbc':
case 'aes-192-ctr':
keylen = 24;
break;
case 'aes-128-cbc':
case 'aes-128-ctr':
case 'cast-cbc':
case 'bf-cbc':
keylen = 16;
break;
default:
throw new Error('Unsupported cipher for encrypted key: '
+ keyInfo.encryption);
}
if (keyInfo.ppk) {
iv = PPK_IV;
key = Buffer.concat([
crypto.createHash('sha1')
.update('\x00\x00\x00\x00' + passphrase, 'utf8')
.digest(),
crypto.createHash('sha1')
.update('\x00\x00\x00\x01' + passphrase, 'utf8')
.digest()
]);
key = key.slice(0, keylen);
} else {
iv = new Buffer(keyInfo.extra[0], 'hex');
key = crypto.createHash('md5')
.update(passphrase, 'utf8')
.update(iv.slice(0, 8))
.digest();
while (keylen > key.length) {
key = Buffer.concat([
key,
(crypto.createHash('md5')
.update(key)
.update(passphrase, 'utf8')
.update(iv)
.digest()).slice(0, 8)
]);
}
if (key.length > keylen)
key = key.slice(0, keylen);
}
dc = crypto.createDecipheriv(keyInfo.encryption, key, iv);
dc.setAutoPadding(false);
keyInfo.private = Buffer.concat([ dc.update(keyInfo.private), dc.final() ]);
keyInfo._decrypted = true;
if (keyInfo.privateOrig) {
// Update our original base64-encoded version of the private key
var orig = keyInfo.privateOrig.toString('utf8');
var newOrig = /^(.+(?:\r\n|\n))/.exec(orig)[1];
var b64key = keyInfo.private.toString('base64');
newOrig += b64key.match(/.{1,70}/g).join('\n');
newOrig += /((?:\r\n|\n).+)$/.exec(orig)[1];
keyInfo.privateOrig = newOrig;
} else if (keyInfo.ppk) {
var valid = verifyPPKMAC(keyInfo, passphrase, keyInfo.private);
if (!valid)
throw new Error('PPK MAC mismatch');
// Automatically convert private key data to OpenSSL format
// (including PEM)
convertPPKPrivate(keyInfo);
}
// Fill in full key type
// TODO: make DRY, we do this also in keyParser
if (keyInfo.type !== 'ec') {
keyInfo.fulltype = 'ssh-' + keyInfo.type;
} else {
// ECDSA
var asnReader = new Ber.Reader(keyInfo.private);
asnReader.readSequence();
asnReader.readInt();
asnReader.readString(Ber.OctetString, true);
asnReader.readByte(); // Skip "complex" context type byte
var offset = asnReader.readLength(); // Skip context length
if (offset !== null) {
asnReader._offset = offset;
switch (asnReader.readOID()) {
case '1.2.840.10045.3.1.7':
// prime256v1/secp256r1
keyInfo.fulltype = 'ecdsa-sha2-nistp256';
break;
case '1.3.132.0.34':
// secp384r1
keyInfo.fulltype = 'ecdsa-sha2-nistp384';
break;
case '1.3.132.0.35':
// secp521r1
keyInfo.fulltype = 'ecdsa-sha2-nistp521';
break;
}
}
if (keyInfo.fulltype === undefined)
return new Error('Unsupported EC private key type');
}
}
function genPublicKey(keyInfo) {
var publicKey;
var i;
// RSA
var n;
var e;
// DSA
var p;
var q;
var g;
var y;
// ECDSA
var d;
var Q;
var ecCurveOID;
var ecCurveName;
if (keyInfo.private) {
// parsing private key in ASN.1 format in order to generate a public key
var privKey = keyInfo.private;
var asnReader = new Ber.Reader(privKey);
var errMsg;
if (asnReader.readSequence() === null) {
errMsg = 'Malformed private key (expected sequence)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
// version (ignored)
if (asnReader.readInt() === null) {
errMsg = 'Malformed private key (expected version)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
if (keyInfo.type === 'rsa') {
// modulus (n) -- integer
n = asnReader.readString(Ber.Integer, true);
if (n === null) {
errMsg = 'Malformed private key (expected RSA n value)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
// public exponent (e) -- integer
e = asnReader.readString(Ber.Integer, true);
if (e === null) {
errMsg = 'Malformed private key (expected RSA e value)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
publicKey = new Buffer(4 + 7 // ssh-rsa
+ 4 + n.length
+ 4 + e.length);
publicKey.writeUInt32BE(7, 0, true);
publicKey.write('ssh-rsa', 4, 7, 'ascii');
i = 4 + 7;
publicKey.writeUInt32BE(e.length, i, true);
e.copy(publicKey, i += 4);
publicKey.writeUInt32BE(n.length, i += e.length, true);
n.copy(publicKey, i += 4);
} else if (keyInfo.type === 'dss') { // DSA
// prime (p) -- integer
p = asnReader.readString(Ber.Integer, true);
if (p === null) {
errMsg = 'Malformed private key (expected DSA p value)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
// group order (q) -- integer
q = asnReader.readString(Ber.Integer, true);
if (q === null) {
errMsg = 'Malformed private key (expected DSA q value)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
// group generator (g) -- integer
g = asnReader.readString(Ber.Integer, true);
if (g === null) {
errMsg = 'Malformed private key (expected DSA g value)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
// public key value (y) -- integer
y = asnReader.readString(Ber.Integer, true);
if (y === null) {
errMsg = 'Malformed private key (expected DSA y value)';
if (keyInfo._decrypted)
errMsg += '. Bad passphrase?';
throw new Error(errMsg);
}
publicKey = new Buffer(4 + 7 // ssh-dss
+ 4 + p.length
+ 4 + q.length
+ 4 + g.length
+ 4 + y.length);
publicKey.writeUInt32BE(7, 0, true);
publicKey.write('ssh-dss', 4, 7, 'ascii');
i = 4 + 7;
publicKey.writeUInt32BE(p.length, i, true);
p.copy(publicKey, i += 4);
publicKey.writeUInt32BE(q.length, i += p.length, true);
q.copy(publicKey, i += 4);
publicKey.writeUInt32BE(g.length, i += q.length, true);
g.copy(publicKey, i += 4);
publicKey.writeUInt32BE(y.length, i += g.length, true);
y.copy(publicKey, i += 4);
} else { // ECDSA
d = asnReader.readString(Ber.OctetString, true);
if (d === null)
throw new Error('Malformed private key (expected ECDSA private key)');
asnReader.readByte(); // Skip "complex" context type byte
var offset = asnReader.readLength(); // Skip context length
if (offset === null)
throw new Error('Malformed private key (expected ECDSA context value)');
asnReader._offset = offset;
ecCurveOID = asnReader.readOID();
if (ecCurveOID === null)
throw new Error('Malformed private key (expected ECDSA curve)');
var tempECDH;
switch (ecCurveOID) {
case '1.2.840.10045.3.1.7':
// prime256v1/secp256r1
keyInfo.curve = ecCurveName = 'nistp256';
tempECDH = crypto.createECDH('prime256v1');
break;
case '1.3.132.0.34':
// secp384r1
keyInfo.curve = ecCurveName = 'nistp384';
tempECDH = crypto.createECDH('secp384r1');
break;
case '1.3.132.0.35':
// secp521r1
keyInfo.curve = ecCurveName = 'nistp521';
tempECDH = crypto.createECDH('secp521r1');
break;
default:
throw new Error('Malformed private key (unsupported EC curve)');
}
tempECDH.setPrivateKey(d);
Q = tempECDH.getPublicKey();
publicKey = new Buffer(4 + 19 // ecdsa-sha2-<curve name>
+ 4 + 8 // <curve name>
+ 4 + Q.length);
publicKey.writeUInt32BE(19, 0, true);
publicKey.write('ecdsa-sha2-' + ecCurveName, 4, 19, 'ascii');
publicKey.writeUInt32BE(8, 23, true);
publicKey.write(ecCurveName, 27, 8, 'ascii');
publicKey.writeUInt32BE(Q.length, 35, true);
Q.copy(publicKey, 39);
}
} else if (keyInfo.public) {
publicKey = keyInfo.public;
if (keyInfo.type === 'ec') {
// TODO: support adding ecdsa-* prefix
ecCurveName = keyInfo.curve;
} else if (publicKey[0] !== 0
// check for missing ssh-{dsa,rsa} prefix
|| publicKey[1] !== 0
|| publicKey[2] !== 0
|| publicKey[3] !== 7
|| publicKey[4] !== 115
|| publicKey[5] !== 115
|| publicKey[6] !== 104
|| publicKey[7] !== 45
|| ((publicKey[8] !== 114
|| publicKey[9] !== 115
|| publicKey[10] !== 97)
&&
((publicKey[8] !== 100
|| publicKey[9] !== 115
|| publicKey[10] !== 115)))) {
var newPK = new Buffer(4 + 7 + publicKey.length);
publicKey.copy(newPK, 11);
newPK.writeUInt32BE(7, 0, true);
if (keyInfo.type === 'rsa')
newPK.write('ssh-rsa', 4, 7, 'ascii');
else
newPK.write('ssh-dss', 4, 7, 'ascii');
publicKey = newPK;
}
} else
throw new Error('Missing data generated by parseKey()');
// generate a public key format for use with OpenSSL
i = 4 + 7;
var fulltype;
var asn1KeyBuf;
if (keyInfo.type === 'rsa') {
fulltype = 'ssh-rsa';
asn1KeyBuf = RSAKeySSHToASN1(publicKey.slice(4 + 7));
} else if (keyInfo.type === 'dss') {
fulltype = 'ssh-dss';
asn1KeyBuf = DSAKeySSHToASN1(publicKey.slice(4 + 7));
} else { // ECDSA
fulltype = 'ecdsa-sha2-' + ecCurveName;
asn1KeyBuf = ECDSAKeySSHToASN1(publicKey.slice(4 + 19));
}
if (!asn1KeyBuf)
throw new Error('Invalid SSH-formatted public key');
var b64key = asn1KeyBuf.toString('base64').replace(RE_KEY_LEN, '$1\n');
var fullkey = '-----BEGIN PUBLIC KEY-----\n'
+ b64key
+ (b64key[b64key.length - 1] === '\n' ? '' : '\n')
+ '-----END PUBLIC KEY-----';
return {
type: keyInfo.type,
fulltype: fulltype,
curve: ecCurveName,
public: publicKey,
publicOrig: new Buffer(fullkey)
};
}
function verifyPPKMAC(keyInfo, passphrase, privateKey) {
if (keyInfo._macresult !== undefined)
return keyInfo._macresult;
else if (!keyInfo.ppk)
throw new Error("Key isn't a PPK");
else if (!keyInfo.privateMAC)
throw new Error('Missing MAC');
else if (!privateKey)
throw new Error('Missing raw private key data');
else if (keyInfo.encryption && typeof passphrase !== 'string')
throw new Error('Missing passphrase for encrypted PPK');
else if (keyInfo.encryption && !keyInfo._decrypted)
throw new Error('PPK must be decrypted before verifying MAC');
var mac = keyInfo.privateMAC;
var typelen = keyInfo.fulltype.length;
// encryption algorithm is converted at this point for use with OpenSSL,
// so we need to use the original value so that the MAC is calculated
// correctly
var enc = (keyInfo.encryption ? 'aes256-cbc' : 'none');
var enclen = enc.length;
var commlen = Buffer.byteLength(keyInfo.comment);
var pub = keyInfo.public;
var publen = pub.length;
var privlen = privateKey.length;
var macdata = new Buffer(4 + typelen
+ 4 + enclen
+ 4 + commlen
+ 4 + publen
+ 4 + privlen);
var p = 0;
macdata.writeUInt32BE(typelen, p, true);
macdata.write(keyInfo.fulltype, p += 4, typelen, 'ascii');
macdata.writeUInt32BE(enclen, p += typelen, true);
macdata.write(enc, p += 4, enclen, 'ascii');
macdata.writeUInt32BE(commlen, p += enclen, true);
macdata.write(keyInfo.comment, p += 4, commlen, 'utf8');
macdata.writeUInt32BE(publen, p += commlen, true);
pub.copy(macdata, p += 4);
macdata.writeUInt32BE(privlen, p += publen, true);
privateKey.copy(macdata, p += 4);
if (typeof passphrase !== 'string')
passphrase = '';
var mackey = crypto.createHash('sha1')
.update('putty-private-key-file-mac-key', 'ascii')
.update(passphrase, 'utf8')
.digest();
var calcMAC = crypto.createHmac('sha1', mackey)
.update(macdata)
.digest('hex');
return (keyInfo._macresult = (calcMAC === mac));
}
function convertPPKPrivate(keyInfo) {
if (!keyInfo.ppk || !keyInfo.public || !keyInfo.private)
throw new Error("Key isn't a PPK");
else if (keyInfo._converted)
return false;
var pub = keyInfo.public;
var priv = keyInfo.private;
var asnWriter = new Ber.Writer();
var p;
var q;
if (keyInfo.type === 'rsa') {
var e = readString(pub, 4 + 7);
var n = readString(pub, pub._pos);
var d = readString(priv, 0);
p = readString(priv, priv._pos);
q = readString(priv, priv._pos);
var iqmp = readString(priv, priv._pos);
var p1 = new BigInteger(p, 256);
var q1 = new BigInteger(q, 256);
var dmp1 = new BigInteger(d, 256);
var dmq1 = new BigInteger(d, 256);
dmp1 = new Buffer(dmp1.mod(p1.subtract(BigInteger.ONE)).toByteArray());
dmq1 = new Buffer(dmq1.mod(q1.subtract(BigInteger.ONE)).toByteArray());
asnWriter.startSequence();
asnWriter.writeInt(0x00, Ber.Integer);
asnWriter.writeBuffer(n, Ber.Integer);
asnWriter.writeBuffer(e, Ber.Integer);
asnWriter.writeBuffer(d, Ber.Integer);
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(dmp1, Ber.Integer);
asnWriter.writeBuffer(dmq1, Ber.Integer);
asnWriter.writeBuffer(iqmp, Ber.Integer);
asnWriter.endSequence();
} else {
p = readString(pub, 4 + 7);
q = readString(pub, pub._pos);
var g = readString(pub, pub._pos);
var y = readString(pub, pub._pos);
var x = readString(priv, 0);
asnWriter.startSequence();
asnWriter.writeInt(0x00, Ber.Integer);
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.writeBuffer(x, Ber.Integer);
asnWriter.endSequence();
}
var b64key = asnWriter.buffer.toString('base64').replace(RE_KEY_LEN, '$1\n');
var fullkey = '-----BEGIN '
+ (keyInfo.type === 'rsa' ? 'RSA' : 'DSA')
+ ' PRIVATE KEY-----\n'
+ b64key
+ (b64key[b64key.length - 1] === '\n' ? '' : '\n')
+ '-----END '
+ (keyInfo.type === 'rsa' ? 'RSA' : 'DSA')
+ ' PRIVATE KEY-----';
keyInfo.private = asnWriter.buffer;
keyInfo.privateOrig = new Buffer(fullkey);
keyInfo._converted = true;
return true;
}
function readString(buffer, start, encoding, stream, cb, maxLen) {
if (encoding && !Buffer.isBuffer(encoding) && typeof encoding !== 'string') {
if (typeof cb === 'number')
maxLen = cb;
cb = stream;
stream = encoding;
encoding = undefined;
}
start || (start = 0);
var bufferLen = buffer.length;
var left = (bufferLen - start);
var len;
var end;
if (start < 0 || start >= bufferLen || left < 4) {
stream && stream._cleanup(cb);
return false;
}
len = buffer.readUInt32BE(start, true);
if (len > (maxLen || MAX_STRING_LEN) || left < (4 + len)) {
stream && stream._cleanup(cb);
return false;
}
start += 4;
end = start + len;
buffer._pos = end;
if (encoding) {
if (Buffer.isBuffer(encoding)) {
buffer.copy(encoding, 0, start, end);
return encoding;
} else
return buffer.toString(encoding, start, end);
} else
return buffer.slice(start, end);
}

71
build/node_modules/ssh2-streams/package.json generated vendored Normal file
View File

@@ -0,0 +1,71 @@
{
"_from": "ssh2-streams@^0.1.8",
"_id": "ssh2-streams@0.1.20",
"_inBundle": false,
"_integrity": "sha1-URGNFUVV31Rp7h9n4M8efoosDjo=",
"_location": "/ssh2-streams",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "ssh2-streams@^0.1.8",
"name": "ssh2-streams",
"escapedName": "ssh2-streams",
"rawSpec": "^0.1.8",
"saveSpec": null,
"fetchSpec": "^0.1.8"
},
"_requiredBy": [
"/sftp-promises",
"/ssh2"
],
"_resolved": "https://registry.npmjs.org/ssh2-streams/-/ssh2-streams-0.1.20.tgz",
"_shasum": "51118d154555df5469ee1f67e0cf1e7e8a2c0e3a",
"_spec": "ssh2-streams@^0.1.8",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/sftp-promises",
"author": {
"name": "Brian White",
"email": "mscdex@mscdex.net"
},
"bugs": {
"url": "https://github.com/mscdex/ssh2-streams/issues"
},
"bundleDependencies": false,
"dependencies": {
"asn1": "~0.2.0",
"semver": "^5.1.0",
"streamsearch": "~0.1.2"
},
"deprecated": false,
"description": "SSH2 and SFTP(v3) client/server protocol streams for node.js",
"engines": {
"node": ">=0.10.0"
},
"homepage": "https://github.com/mscdex/ssh2-streams#readme",
"keywords": [
"ssh",
"ssh2",
"sftp",
"secure",
"protocol",
"streams",
"client",
"server"
],
"licenses": [
{
"type": "MIT",
"url": "http://github.com/mscdex/ssh2-streams/raw/master/LICENSE"
}
],
"main": "./index",
"name": "ssh2-streams",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/mscdex/ssh2-streams.git"
},
"scripts": {
"test": "node test/test.js"
},
"version": "0.1.20"
}

View File

@@ -0,0 +1,17 @@
PuTTY-User-Key-File-2: ssh-dss
Encryption: aes256-cbc
Comment: dsa-key-20141202
Public-Lines: 10
AAAAB3NzaC1kc3MAAACBAJn2I8YefRo3BsEeinQt8KQ4cEyArAs7Y/W733oRSYOI
zWF1Ju124ysKrmg2okv+05CYcjV3Yp4AzQeomYAlgmB/7xCEnWaEnxCwAxmrrJMm
PrkwNjHOIi7yM5QOE90IM/Q+IJA4EPBfSb+Xr8fYhrp53KNHVSnc2KkOqpo2FsIj
AAAAFQC4NlP50GqyUqq2B82Vh/w5j3TzwQAAAIAeSGom9LLNdzcwCHnGfxKNnEz3
55KITADTxiIpBvnQW+eDHwQvIw6V2Oc73bKCu5ZirZmIMW5w6KjQVwkuQBoF9Koq
/2u6VeevtL9pD6TBzSLMVw5pV3PmE4/C/eLiaUxZLIHdbzpqPkAvAUBrXKkj0ijz
cNzCp1fuF8H0pvR8yQAAAIAmvV+kqWhUgDYwNNz1qDaoS8XdsOponutZ/0stRQ66
mKAy8kNVNNQ6oUx1XFl1WUt4iyFY/2Rz2fZhLz5/TbZRK5ygo666WgnxB/Ud4GAx
/BPQTghOJJOL00vJk+8jVCGNDc942V6nFXznDMXwqxhRCW6dm+2lTh7ntrli8mCk
5g==
Private-Lines: 1
BytvbK+jNyMjiVxCO5lcE4YbW7q293oC+LZjkZ8Ajlw=
Private-MAC: c3da536ea28851fc32d5d1ff01498c8fcebc1170

View File

@@ -0,0 +1,18 @@
PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc
Comment: rsa-key-20141119
Public-Lines: 4
AAAAB3NzaC1yc2EAAAABJQAAAIBrBWETAVAyJmuNG53jwTNDlbIcH5lrEvcx6lx5
bM6EKg0XmOIH96VqUjS7eRRTTD9lpBA8hYhkrOjOx93/JWB/pcVN8/B3DYHshT9O
BW1DCkrNwut2pbJ2oZOBirhhAr+xqWFr3551FqbzaCIXpOKubr4EcIwCipBl6PxL
USfHgw==
Private-Lines: 8
8O3NrBePR4+4RHHys8wrRKCmgx3Gsdz1cKoRJJDgnnrQxuAxBTVUlVTC2vzSOXrP
jlKdRP9DbtrL5YF8g9HkMPpzzTdgpiEAGikpIc+L0sJhN+S9VvMoXRRKqyuB7o1C
xZhAeRaZ68izdUUbFd7ajUwBNpGoFppOznGXyf/3/Ao9FfoTKReZzeBd/e2/JFhc
nsYkSbtWfKQBVXF1Fhr10UwRWSMaVJSDkcSuk8ghICoKBBCgRBnZFap0SR77oIJh
DKgmNFktoKzEqh111vYPhQyEEyGNxpD0aEPaGUJEjPEd3C5a46n7mIiqrNX7QJoo
xxZtkueGdXWaoe5mBf1tFc+nCA1l72nUlghJZooQhnO9NPpieu6NNZ8X+tFQ1Rq/
xvOZHzpDOOeOgWdV7oAmRDbDjYPh0H67z2OKCFaP0Z9kgmnwqV2IJvTDrexj1VwY
6kFaPldnK+ohXl37oVIlWA==
Private-MAC: 9d09a15a122e48955682ba969d33c75ba8e4be2c

27
build/node_modules/ssh2-streams/test/fixtures/id_rsa generated vendored Normal file
View File

@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpgIBAAKCAQEAysX9gGx5CsLW3xHqOgnrbfCuXy1Y0OFpZBxWs6FNHxtqpxRD
Ii8vnWQw9Ltul5NhBb1QrS/3XlODu5rv8VWZy+ciXDaeaVYvzCR3fHmQyDXA+WLR
x8kkR4ZxHTQREj1yifGyHdZTMsMbSaW9Eh2+sgWIjZaBkLjF2NDT52HX0y+zr2WL
TYVCcYf9ugCJIfwXN4/SpR+cV3MSak+4HfFDRo7EwFbYL8QRpNZLVVas5SUpN3CR
e6u26zPNgcqSRmC81lA/e2t7qG1qvjFy9RgJpUJJsZan5yMYAob9p83Fo61ajLX1
DeqpZPauEfe9e/4bkjVbU8gW/cgb9Ct6v+59fQIDAQABAoIBAQCU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RAb7dPEkw2dmiCQQIDAQAB
AoGAMG+HOwoaLbR5aR64yrQNYBF6Vvii1iUdURr9o2r9kygpVUuZIcim5kMvPbnK
v+w+NaQt+q4XeJvCH1uG0W/69FwnphfaOVmCCUtsoJ6sU3fWr9x59MtKL2Llh8xR
50lz6R+eDXoYRDq245hG9BFn/bu0vtqQqx06mlZJcjaRocECQQDjdYFmr+DSww3x
VNx0G0DUkaQZZ+iqZiT3Zund2pcBB4aLiewOrqj0GFct4+YNzgxIXPejmS0eSokN
N2lC3NxZAkEA0UGjN5TG5/LEK3zcYtx2kpXryenrYORo1n2L/WPMZ0mjLQyd4LJr
ibfgVUfwX/kV3vgGYLwjpgcaTiMsecv4KQJAYMmMgZSPdz+WvD1e/WznXkyG5mSn
xXJngnrhQw0TulVodBIBR5IcxJli510VdIRcB6K/oXa5ky0mOmB8wv3WKQJBAKEF
PxE//KbzWhyUogm4180IbD4dMDCI0ltqlFRRfTJlqZi6wqnq4XFB+u/kwYU4aKoA
dPfvDgduI8HIsyqt17ECQDI/HC8PiYsDIOyVpQuQdIAsbGmoavK7X1MVEWR2nj9t
7BbUVFSnVKynL4TWIJZ6xP8WQwkDBQc5WjognHDaUTQ=
-----END RSA PRIVATE KEY-----

View File

@@ -0,0 +1,169 @@
var SSH2Stream = require('../lib/ssh');
var fs = require('fs');
var path = require('path');
var inspect = require('util').inspect;
var inherits = require('util').inherits;
var TransformStream = require('stream').Transform;
var assert = require('assert');
var t = -1;
var group = path.basename(__filename, '.js') + '/';
var fixturesdir = path.join(__dirname, 'fixtures');
var HOST_KEY_RSA = fs.readFileSync(path.join(fixturesdir, 'ssh_host_rsa_key'));
var SERVER_CONFIG = {
server: true,
hostKeys: { 'ssh-rsa': HOST_KEY_RSA }
};
function SimpleStream() {
TransformStream.call(this);
this.buffer = '';
}
inherits(SimpleStream, TransformStream);
SimpleStream.prototype._transform = function(chunk, encoding, cb) {
this.buffer += chunk.toString('binary');
cb();
};
var tests = [
{ run: function() {
var what = this.what;
var serverError = false;
var server = new SSH2Stream(SERVER_CONFIG);
var client = new SimpleStream();
client.pipe(server).pipe(client);
server.on('error', function(err) {
serverError = err;
assert(err.message === 'Protocol version not supported',
makeMsg(what, 'Wrong error message'));
}).on('end', function() {
assert(client.buffer === server.config.ident + '\r\n',
makeMsg(what, 'Wrong server ident: ' + inspect(client.buffer)));
assert(serverError, makeMsg(what, 'Expected server error'));
next();
});
client.push('SSH-1.0-aaa\r\n');
},
what: 'Incompatible client SSH protocol version'
},
{ run: function() {
var what = this.what;
var serverError = false;
var server = new SSH2Stream(SERVER_CONFIG);
var client = new SimpleStream();
client.pipe(server).pipe(client);
server.on('error', function(err) {
serverError = err;
assert(err.message === 'Bad identification start',
makeMsg(what, 'Wrong error message'));
}).on('end', function() {
assert(client.buffer === server.config.ident + '\r\n',
makeMsg(what, 'Wrong server ident: ' + inspect(client.buffer)));
assert(serverError, makeMsg(what, 'Expected server error'));
next();
});
client.push('LOL-2.0-asdf\r\n');
},
what: 'Malformed client protocol identification'
},
{ run: function() {
var what = this.what;
var serverError = false;
var server = new SSH2Stream(SERVER_CONFIG);
var client = new SimpleStream();
client.pipe(server).pipe(client);
server.on('error', function(err) {
serverError = err;
assert(err.message === 'Max identification string size exceeded',
makeMsg(what, 'Wrong error message'));
}).on('end', function() {
assert(client.buffer === server.config.ident + '\r\n',
makeMsg(what, 'Wrong server ident: ' + inspect(client.buffer)));
assert(serverError, makeMsg(what, 'Expected server error'));
next();
});
var ident = 'SSH-2.0-';
for (var i = 0; i < 30; ++i)
ident += 'foobarbaz';
ident += '\r\n';
client.push(ident);
},
what: 'SSH client protocol identification too long (> 255 characters)'
},
{ run: function() {
var what = this.what;
var serverError = false;
var server = new SSH2Stream(SERVER_CONFIG);
var client = new SimpleStream();
client.pipe(server).pipe(client);
server.on('error', function(err) {
serverError = err;
assert(err.message === 'Bad packet length',
makeMsg(what, 'Wrong error message'));
}).on('end', function() {
assert(client.buffer.length, makeMsg(what, 'Expected server data'));
assert(serverError, makeMsg(what, 'Expected server error'));
next();
});
client.push('SSH-2.0-asdf\r\n');
// 500,000 byte packet_length
client.push(new Buffer([0x00, 0x07, 0xA1, 0x20, 0x00, 0x00, 0x00, 0x00]));
},
what: 'Bad packet length (max)'
},
{ run: function() {
var what = this.what;
var serverError = false;
var server = new SSH2Stream(SERVER_CONFIG);
var client = new SimpleStream();
client.pipe(server).pipe(client);
server.on('error', function(err) {
serverError = err;
assert(err.message === 'Bad packet length',
makeMsg(what, 'Wrong error message'));
}).on('end', function() {
assert(client.buffer.length, makeMsg(what, 'Expected server data'));
assert(serverError, makeMsg(what, 'Expected server error'));
next();
});
client.push('SSH-2.0-asdf\r\n');
client.push(new Buffer([0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]));
},
what: 'Bad packet length (min)'
},
];
function next() {
if (Array.isArray(process._events.exit))
process._events.exit = process._events.exit[1];
if (++t === tests.length)
return;
var v = tests[t];
v.run.call(v);
}
function makeMsg(what, msg) {
return '[' + group + what + ']: ' + msg;
}
process.once('exit', function() {
assert(t === tests.length,
makeMsg('_exit',
'Only finished ' + t + '/' + tests.length + ' tests'));
});
next();

66
build/node_modules/ssh2-streams/test/test-kexdh.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
var SSH2Stream = require('../lib/ssh');
var parseKey = require('../lib/utils').parseKey;
var genPubKey = require('../lib/utils').genPublicKey;
var MESSAGE = require('../lib/constants').MESSAGE;
var assert = require('assert');
var fs = require('fs');
var SERVER_KEY = fs.readFileSync(__dirname + '/fixtures/ssh_host_rsa_key');
var SERVER_KEY_PRV = parseKey(SERVER_KEY);
var SERVER_KEY_PUB = genPubKey(SERVER_KEY_PRV);
var server = new SSH2Stream({
server: true,
hostKeys: {
'ssh-rsa': {
privateKey: SERVER_KEY_PRV,
publicKey: SERVER_KEY_PUB,
}
}
});
var client = new SSH2Stream();
var cliError;
var srvError;
server.on('error', function(err) {
assert(err);
assert(/unexpected/.test(err.message));
assert(!srvError);
srvError = err;
});
// Removed 'KEXDH_REPLY' listeners as it causes client to send 'NEWKEYS' which
// changes server's state.
client.removeAllListeners('KEXDH_REPLY');
// Removed 'NEWKEYS' listeners as server sends 'NEWKEYS' after receiving
// 'KEXDH_INIT' which causes errors on client if 'NEWKEYS' is processed
// without processing 'KEXDH_REPLY'
client.removeAllListeners('NEWKEYS');
// Added 'KEXDH_REPLY' which violates protocol and re-sends 'KEXDH_INIT'
// packet
client.on('KEXDH_REPLY', function(info) {
var state = client._state;
var outstate = state.outgoing;
var buf = new Buffer(1 + 4 + outstate.pubkey.length);
buf[0] = MESSAGE.KEXDH_INIT;
buf.writeUInt32BE(outstate.pubkey.length, 1, true);
outstate.pubkey.copy(buf, 5);
SSH2Stream._send(client, buf, undefined, true);
});
client.on('error', function(err) {
assert(!cliError);
assert(err);
assert.equal(
err.message,
'PROTOCOL_ERROR',
'Expected Error: PROTOCOL_ERROR Got Error: ' + err.message
);
cliError = err;
});
client.pipe(server).pipe(client);
process.on('exit', function() {
assert(cliError, 'Expected client error');
//assert(srvError, 'Expected server error');
});

2301
build/node_modules/ssh2-streams/test/test-keyparser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

256
build/node_modules/ssh2-streams/test/test-packet60.js generated vendored Normal file
View File

@@ -0,0 +1,256 @@
var SSH2Stream = require('../lib/ssh');
var parseKey = require('../lib/utils').parseKey;
var genPubKey = require('../lib/utils').genPublicKey;
var assert = require('assert');
var crypto = require('crypto');
var fs = require('fs');
var t = -1;
var SERVER_PRV_KEY = fs.readFileSync(__dirname + '/fixtures/ssh_host_rsa_key');
var PARSED_SERVER_PRV_KEY = parseKey(SERVER_PRV_KEY);
var PARSED_SERVER_PUB_KEY = genPubKey(PARSED_SERVER_PRV_KEY);
var CLIENT_PRV_KEY = fs.readFileSync(__dirname + '/fixtures/id_rsa');
var PARSED_CLIENT_PRV_KEY = parseKey(CLIENT_PRV_KEY);
var PARSED_CLIENT_PUB_KEY = genPubKey(PARSED_CLIENT_PRV_KEY);
function makePair(cb) {
var server = new SSH2Stream({
server: true,
hostKeys: {
'ssh-rsa': {
privateKey: PARSED_SERVER_PRV_KEY,
publicKey: PARSED_SERVER_PUB_KEY
}
}
});
var client = new SSH2Stream();
var done = [];
function tryDone(who) {
done.push(who);
if (done.length !== 2)
return;
cb(server, client);
}
server.on('NEWKEYS', function () { tryDone('server'); });
client.on('NEWKEYS', function () { tryDone('client'); });
server.pipe(client).pipe(server);
}
function signWithClientKey(blob, syncCb) {
var signType = (PARSED_CLIENT_PRV_KEY.type === 'rsa' ? 'R' : 'D') + 'SA-SHA1';
var signature = crypto.createSign(signType);
signature.update(blob);
signature = signature.sign(PARSED_CLIENT_PRV_KEY.privateOrig);
syncCb(signature);
}
function bufferEqual(a, b) {
if (a.length !== b.length)
return false;
for (var i = 0; i < a.length; ++i) {
if (a[i] !== b[i])
return false;
}
return true;
}
function publickey(server, client) {
server.on('USERAUTH_REQUEST', function(user, service, method, data) {
assert.equal(user, 'bob');
assert.equal(service, 'ssh-connection');
assert.equal(method, 'publickey');
assert.equal(data.keyAlgo, PARSED_CLIENT_PUB_KEY.fulltype);
assert.equal(true, bufferEqual(data.key, PARSED_CLIENT_PUB_KEY.public));
assert.equal(data.signature, undefined);
assert.equal(data.blob, undefined);
return server.authPKOK(data.keyAlgo, data.key);
});
client.on('USERAUTH_PK_OK', function() {
next();
}).authPK('bob', PARSED_CLIENT_PUB_KEY);
}
function keyboardInteractive(server, client) {
var infoReqsRxed = 0;
server.on('USERAUTH_REQUEST', function(user, service, method, data) {
assert.equal(user, 'bob');
assert.equal(service, 'ssh-connection');
assert.equal(method, 'keyboard-interactive');
assert.equal(data, '');
process.nextTick(function() {
server.authInfoReq('req 0', 'instructions', [
{ prompt: 'Say something to req 0', echo: true }
]);
});
}).on('USERAUTH_INFO_RESPONSE', function(responses) {
if (infoReqsRxed === 1) {
assert.equal(responses.length, 1);
assert.equal(responses[0], 'hello to req 0');
process.nextTick(function() {
server.authInfoReq('req 1', 'new instructions', [
{ prompt: 'Say something to req 1', echo: true },
{ prompt: 'Say something else', echo: false }
]);
});
} else if (infoReqsRxed === 2) {
assert.equal(responses.length, 2);
assert.equal(responses[0], 'hello to req 1');
assert.equal(responses[1], 'something else');
next();
} else {
throw new Error('Received too many info reqs: ' + infoReqsRxed);
}
});
client.on('USERAUTH_INFO_REQUEST', function (name, inst, lang, prompts) {
infoReqsRxed++;
if (infoReqsRxed === 1) {
assert.equal(name, 'req 0');
assert.equal(inst, 'instructions');
assert.equal(lang, '');
assert.deepEqual(prompts, [
{ prompt: 'Say something to req 0', echo: true }
]);
process.nextTick(function() {
client.authInfoRes([ 'hello to req 0' ]);
});
} else if (infoReqsRxed === 2) {
assert.equal(name, 'req 1');
assert.equal(inst, 'new instructions');
assert.equal(lang, '');
assert.deepEqual(prompts, [
{ prompt: 'Say something to req 1', echo: true },
{ prompt: 'Say something else', echo: false }
]);
process.nextTick(function() {
client.authInfoRes([ 'hello to req 1', 'something else' ]);
});
} else {
throw new Error('Received too many info reqs: ' + infoReqsRxed);
}
}).authKeyboard('bob');
}
function mixedMethods(server, client) {
var expectedStages = [
'SERVER_SEES_PK_CHECK',
'SERVER_SEES_PK_REQUEST',
'SERVER_SEES_PASSWORD',
'SERVER_SEES_KEYBOARD_INTERACTIVE',
'CLIENT_SEES_PK_OK',
'CLIENT_SEES_USERAUTH_FAILURE_PK',
'CLIENT_SEES_USERAUTH_FAILURE_PASSWORD',
'CLIENT_SEES_KEYBOARD_REQ',
'SERVER_SEES_KEYBOARD_RES',
'CLIENT_SEES_USERAUTH_SUCCESS',
];
server.on('USERAUTH_REQUEST', function(name, service, method, data) {
assert.equal(name, 'bob');
assert.equal(service, 'ssh-connection');
var expectedStage = expectedStages.shift();
switch (expectedStage) {
case 'SERVER_SEES_PK_CHECK':
assert.equal(method, 'publickey');
assert.equal(data.signature, undefined);
return process.nextTick(function() {
server.authPKOK(data.keyAlgo, data.key);
});
case 'SERVER_SEES_PK_REQUEST':
assert.equal(method, 'publickey');
assert.notEqual(data.signature, undefined);
return process.nextTick(function() {
server.authFailure(
['publickey', 'password', 'keyboard-interactive'],
false
);
});
case 'SERVER_SEES_PASSWORD':
assert.equal(method, 'password');
assert.equal(data, 'seekrit');
return process.nextTick(function() {
server.authFailure(
['publickey', 'password', 'keyboard-interactive'],
false
);
});
case 'SERVER_SEES_KEYBOARD_INTERACTIVE':
assert.equal(method, 'keyboard-interactive');
assert.equal(data, '');
return process.nextTick(function() {
server.authInfoReq('Password required', 'Password prompt', [
{ prompt: 'Password:', echo: false }
]);
});
default:
throw new Error('Server saw USERAUTH_REQUEST ' + method +
' but expected ' + expectedStage);
}
}).on('USERAUTH_INFO_RESPONSE', function(responses) {
assert.equal(expectedStages.shift(), 'SERVER_SEES_KEYBOARD_RES');
assert.deepEqual(responses, [ 'seekrit' ]);
process.nextTick(function() {
server.authSuccess();
});
});
client.on('USERAUTH_PK_OK', function() {
assert.equal(expectedStages.shift(), 'CLIENT_SEES_PK_OK');
}).on('USERAUTH_FAILURE', function() {
var expectedStage = expectedStages.shift();
if (expectedStage !== 'CLIENT_SEES_USERAUTH_FAILURE_PK' &&
expectedStage !== 'CLIENT_SEES_USERAUTH_FAILURE_PASSWORD') {
throw new Error('Client saw USERAUTH_FAILURE but expected ' +
expectedStage);
}
}).on('USERAUTH_INFO_REQUEST', function(name, inst, lang, prompts) {
assert.equal(expectedStages.shift(), 'CLIENT_SEES_KEYBOARD_REQ');
assert.equal(name, 'Password required');
assert.equal(inst, 'Password prompt');
assert.equal(lang, '');
assert.deepEqual(prompts, [ { prompt: 'Password:', echo: false } ]);
process.nextTick(function() {
client.authInfoRes([ 'seekrit' ]);
});
}).on('USERAUTH_SUCCESS', function() {
assert.equal(expectedStages.shift(), 'CLIENT_SEES_USERAUTH_SUCCESS');
assert.equal(expectedStages.shift(), undefined);
next();
});
// Silly to submit all these auths at once, but allowed by RFC4252
client.authPK('bob', PARSED_CLIENT_PUB_KEY);
client.authPK('bob', PARSED_CLIENT_PUB_KEY, signWithClientKey);
client.authPassword('bob', 'seekrit');
client.authKeyboard('bob');
}
var tests = [
publickey,
keyboardInteractive,
// password // ssh2-streams can't generate a password change request
mixedMethods
];
function next() {
if (Array.isArray(process._events.exit))
process._events.exit = process._events.exit[1];
if (++t === tests.length)
return;
var v = tests[t];
makePair(v);
}
process.once('exit', function() {
assert(t === tests.length,
'Only finished ' + t + '/' + tests.length + ' tests');
});
next();

1274
build/node_modules/ssh2-streams/test/test-sftp.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

143
build/node_modules/ssh2-streams/test/test-ssh.js generated vendored Normal file
View File

@@ -0,0 +1,143 @@
var SSH2Stream = require('../lib/ssh');
var utils = require('../lib/utils');
var parseKey = utils.parseKey;
var genPubKey = utils.genPublicKey;
var basename = require('path').basename;
var assert_ = require('assert');
var inherits = require('util').inherits;
var inspect = require('util').inspect;
var TransformStream = require('stream').Transform;
var fs = require('fs');
var group = basename(__filename, '.js') + '/';
var t = -1;
var SERVER_KEY = fs.readFileSync(__dirname + '/fixtures/ssh_host_rsa_key');
var HOST_KEYS = { 'ssh-rsa': makeServerKey(SERVER_KEY) };
function SimpleStream() {
TransformStream.call(this);
this.buffer = '';
}
inherits(SimpleStream, TransformStream);
SimpleStream.prototype._transform = function(chunk, encoding, cb) {
this.buffer += chunk.toString('binary');
cb(null, chunk);
};
var tests = [
// client-side tests
{ run: function() {
var algos = ['ssh-dss', 'ssh-rsa', 'ecdsa-sha2-nistp521'];
var client = new SSH2Stream({
algorithms: {
serverHostKey: algos
}
});
var clientBufStream = new SimpleStream();
var clientReady = false;
var server = new SSH2Stream({
server: true,
hostKeys: HOST_KEYS
});
var serverBufStream = new SimpleStream();
var serverReady = false;
function onNEWKEYS() {
if (this === client) {
assert(!clientReady, 'Already received client NEWKEYS event');
clientReady = true;
} else {
assert(!serverReady, 'Already received server NEWKEYS event');
serverReady = true;
}
if (clientReady && serverReady) {
var traffic = clientBufStream.buffer;
var algoList = algos.join(',');
var re = new RegExp('\x00\x00\x00'
+ hexByte(algoList.length)
+ algoList);
assert(re.test(traffic), 'Unexpected client algorithms');
traffic = serverBufStream.buffer;
assert(/\x00\x00\x00\x07ssh-rsa/.test(traffic),
'Unexpected server algorithms');
next();
}
}
client.on('NEWKEYS', onNEWKEYS);
server.on('NEWKEYS', onNEWKEYS);
client.pipe(clientBufStream)
.pipe(server)
.pipe(serverBufStream)
.pipe(client);
},
what: 'Custom algorithms'
},
{ run: function() {
var serverIdent = 'testing \t';
var expectedFullIdent = 'SSH-2.0-' + serverIdent;
var client = new SSH2Stream({});
client.on('header', function(header) {
assert(header.identRaw === expectedFullIdent,
'\nSaw: ' + inspect(header.identRaw) + '\n'
+ 'Expected: ' + inspect(expectedFullIdent));
next();
});
var server = new SSH2Stream({
server: true,
hostKeys: HOST_KEYS,
ident: serverIdent
});
client.pipe(server).pipe(client);
},
what: 'Remote ident is not trimmed'
}
];
function makeServerKey(raw) {
var privateKey = parseKey(raw);
return {
privateKey: privateKey,
publicKey: genPubKey(privateKey)
};
}
function hexByte(n) {
return String.fromCharCode(n);
}
function assert(expression, msg) {
msg || (msg = 'failed assertion');
assert_(expression, makeMsg(tests[t].what, msg));
}
function next() {
if (Array.isArray(process._events.exit))
process._events.exit = process._events.exit[1];
if (++t === tests.length)
return;
var v = tests[t];
v.run.call(v);
}
function makeMsg(what, msg) {
return '[' + group + what + ']: ' + msg;
}
process.once('exit', function() {
assert_(t === tests.length,
makeMsg('_exit',
'Only finished ' + t + '/' + tests.length + ' tests'));
});
next();

678
build/node_modules/ssh2-streams/test/test-utils.js generated vendored Normal file
View File

@@ -0,0 +1,678 @@
var utils = require('../lib/utils');
var fs = require('fs');
var path = require('path');
var assert = require('assert');
var t = -1;
var group = path.basename(__filename, '.js') + '/';
var fixturesdir = path.join(__dirname, 'fixtures');
var tests = [
{ run: function() {
var what = this.what;
var r;
assert.strictEqual(r = utils.readInt(new Buffer([0,0,0]), 0),
false,
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readInt - without stream callback - failure #1'
},
{ run: function() {
var what = this.what;
var r;
assert.strictEqual(r = utils.readInt(new Buffer([]), 0),
false,
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readInt - without stream callback - failure #2'
},
{ run: function() {
var what = this.what;
var r;
assert.strictEqual(r = utils.readInt(new Buffer([0,0,0,5]), 0),
5,
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readInt - without stream callback - success'
},
{ run: function() {
var what = this.what;
var callback = function() {};
var stream = {
_cleanup: function(cb) {
cleanupCalled = true;
assert(cb === callback, makeMsg(what, 'Wrong callback'));
}
};
var cleanupCalled = false;
var r;
assert.strictEqual(r = utils.readInt(new Buffer([]), 0, stream, callback),
false,
makeMsg(what, 'Wrong result: ' + r));
assert(cleanupCalled, makeMsg(what, 'Cleanup not called'));
next();
},
what: 'readInt - with stream callback'
},
{ run: function() {
var what = this.what;
var r;
assert.strictEqual(r = utils.readString(new Buffer([0,0,0]), 0),
false,
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readString - without stream callback - bad length #1'
},
{ run: function() {
var what = this.what;
var r;
assert.strictEqual(r = utils.readString(new Buffer([]), 0),
false,
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readString - without stream callback - bad length #2'
},
{ run: function() {
var what = this.what;
var r;
assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1,5]), 0),
new Buffer([5]),
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readString - without stream callback - success'
},
{ run: function() {
var what = this.what;
var r;
assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1,33]), 0, 'ascii'),
'!',
makeMsg(what, 'Wrong result: ' + r));
next();
},
what: 'readString - without stream callback - encoding'
},
{ run: function() {
var what = this.what;
var callback = function() {};
var stream = {
_cleanup: function(cb) {
cleanupCalled = true;
assert(cb === callback, makeMsg(what, 'Wrong callback'));
}
};
var cleanupCalled = false;
var r;
assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1]),
0,
stream,
callback),
false,
makeMsg(what, 'Wrong result: ' + r));
assert(cleanupCalled, makeMsg(what, 'Cleanup not called'));
next();
},
what: 'readString - with stream callback - no encoding'
},
{ run: function() {
var what = this.what;
var callback = function() {};
var stream = {
_cleanup: function(cb) {
cleanupCalled = true;
assert(cb === callback, makeMsg(what, 'Wrong callback'));
}
};
var cleanupCalled = false;
var r;
assert.deepEqual(r = utils.readString(new Buffer([0,0,0,1]),
0,
'ascii',
stream,
callback),
false,
makeMsg(what, 'Wrong result: ' + r));
assert(cleanupCalled, makeMsg(what, 'Cleanup not called'));
next();
},
what: 'readString - with stream callback - encoding'
},
{ run: function() {
var what = this.what;
var filepath = fixturesdir + '/encrypted-rsa.ppk';
var passphrase = 'node.js';
var keyInfo = utils.parseKey(fs.readFileSync(filepath));
utils.decryptKey(keyInfo, passphrase);
var expPrivOrig = new Buffer([
45,45,45,45,45,66,69,71,73,78,32,82,83,65,32,80,82,73,86,65,84,69,32,75,
69,89,45,45,45,45,45,10,77,73,73,67,87,81,73,66,65,65,75,66,103,71,115,
70,89,82,77,66,85,68,73,109,97,52,48,98,110,101,80,66,77,48,79,86,115,
104,119,102,109,87,115,83,57,122,72,113,88,72,108,115,122,111,81,113,68,
82,101,89,52,103,102,51,10,112,87,112,83,78,76,116,53,70,70,78,77,80,50,
87,107,69,68,121,70,105,71,83,115,54,77,55,72,51,102,56,108,89,72,43,108,
120,85,51,122,56,72,99,78,103,101,121,70,80,48,52,70,98,85,77,75,83,115,
51,67,54,51,97,108,10,115,110,97,104,107,52,71,75,117,71,69,67,118,55,71,
112,89,87,118,102,110,110,85,87,112,118,78,111,73,104,101,107,52,113,53,
117,118,103,82,119,106,65,75,75,107,71,88,111,47,69,116,82,74,56,101,68,
65,103,69,108,65,111,71,65,10,85,43,71,102,72,76,118,88,69,111,122,81,49,
109,72,65,56,77,102,99,69,109,67,83,104,76,55,83,77,86,81,78,50,119,80,
76,56,72,102,103,73,109,89,108,55,43,97,72,112,87,69,56,100,101,49,110,
109,100,116,119,121,54,112,50,10,52,80,89,50,80,85,89,81,57,80,89,53,55,
105,51,122,76,56,78,90,100,56,87,81,55,82,103,48,82,66,72,68,108,110,100,
97,70,101,70,52,69,102,48,117,76,98,111,113,89,100,47,120,78,48,114,122,
102,121,53,53,122,55,104,87,10,79,76,43,56,86,104,111,120,84,114,66,85,
118,118,101,79,104,90,119,66,80,107,79,101,72,102,120,109,107,86,122,51,
120,98,98,114,103,51,107,78,108,111,48,67,81,81,68,74,89,80,75,116,67,
115,47,108,52,54,75,74,109,78,51,108,10,85,65,78,100,73,52,81,73,117,87,
81,43,90,108,108,122,55,112,57,52,70,102,100,111,116,110,107,118,113,71,
43,43,66,112,49,119,79,113,74,83,67,105,104,54,85,86,105,119,76,102,118,
112,78,90,116,71,77,67,116,107,52,54,87,78,10,104,99,48,122,65,107,69,65,
105,65,121,78,52,87,85,115,47,48,120,52,87,111,118,71,57,53,54,74,49,65,
43,117,83,69,75,101,87,122,117,113,102,112,71,71,98,87,103,90,57,88,102,
110,80,110,107,43,49,65,108,56,70,79,87,49,10,116,117,57,87,87,114,77,80,
73,97,118,81,110,90,87,47,100,88,120,104,107,101,78,87,84,72,55,56,99,81,
74,66,65,76,107,77,43,113,122,90,103,77,86,112,90,79,48,107,115,68,113,
65,52,72,56,90,116,53,108,81,97,102,81,109,10,115,120,67,87,70,102,43,
108,101,53,67,110,114,97,70,113,87,78,103,104,119,82,115,70,99,112,67,84,
116,110,52,56,54,98,97,109,121,56,57,104,115,85,100,113,105,76,50,83,54,
121,103,97,70,111,69,67,81,70,68,107,51,114,49,101,10,119,77,56,109,106,
77,65,51,98,50,76,77,43,65,71,77,121,72,51,43,71,80,102,53,57,113,119,
102,76,86,88,80,77,103,101,84,90,117,98,103,84,116,55,119,52,102,54,87,
98,65,118,111,81,83,56,67,114,119,48,97,68,86,98,72,10,118,102,76,85,86,
98,67,119,114,57,112,49,66,77,48,67,81,70,83,66,106,67,97,47,102,122,101,
73,67,86,107,80,70,66,97,75,81,85,109,88,106,81,51,73,99,80,84,79,114,57,
48,109,83,65,105,80,110,65,65,112,112,83,119,84,10,106,53,83,89,83,102,
69,57,114,83,86,98,43,69,104,81,48,104,107,50,86,75,87,73,102,111,99,78,
72,66,68,49,77,65,78,57,122,98,52,61,10,45,45,45,45,45,69,78,68,32,82,83,
65,32,80,82,73,86,65,84,69,32,75,69,89,45,45,45,45,45
]);
assert(keyInfo.ppk === true, makeMsg(what, 'Expected PPK flag'));
assert(keyInfo._converted === true,
makeMsg(what, 'Expected automatic private PEM generation'));
assert(keyInfo._macresult === true,
makeMsg(what, 'Expected successful MAC verification'));
assert(keyInfo._decrypted === true,
makeMsg(what, 'Expected decrypted flag'));
assert.deepEqual(keyInfo.privateOrig,
expPrivOrig,
makeMsg(what, 'Decrypted private PEM data mismatch'));
next();
},
what: 'decryptKey - with encrypted RSA PPK'
},
{ run: function() {
var what = this.what;
var filepath = fixturesdir + '/encrypted-dsa.ppk';
var passphrase = 'node.js';
var keyInfo = utils.parseKey(fs.readFileSync(filepath));
utils.decryptKey(keyInfo, passphrase);
var expPrivOrig = new Buffer([
45,45,45,45,45,66,69,71,73,78,32,68,83,65,32,80,82,73,86,65,84,69,32,75,
69,89,45,45,45,45,45,10,77,73,73,66,117,103,73,66,65,65,75,66,103,81,67,
90,57,105,80,71,72,110,48,97,78,119,98,66,72,111,112,48,76,102,67,107,
79,72,66,77,103,75,119,76,79,50,80,49,117,57,57,54,69,85,109,68,105,77,
49,104,100,83,98,116,10,100,117,77,114,67,113,53,111,78,113,74,76,47,116,
79,81,109,72,73,49,100,50,75,101,65,77,48,72,113,74,109,65,74,89,74,103,
102,43,56,81,104,74,49,109,104,74,56,81,115,65,77,90,113,54,121,84,74,
106,54,53,77,68,89,120,10,122,105,73,117,56,106,79,85,68,104,80,100,67,
68,80,48,80,105,67,81,79,66,68,119,88,48,109,47,108,54,47,72,50,73,97,54,
101,100,121,106,82,49,85,112,51,78,105,112,68,113,113,97,78,104,98,67,73,
119,73,86,65,76,103,50,10,85,47,110,81,97,114,74,83,113,114,89,72,122,90,
87,72,47,68,109,80,100,80,80,66,65,111,71,65,72,107,104,113,74,118,83,
121,122,88,99,51,77,65,104,53,120,110,56,83,106,90,120,77,57,43,101,83,
105,69,119,65,48,56,89,105,10,75,81,98,53,48,70,118,110,103,120,56,69,76,
121,77,79,108,100,106,110,79,57,50,121,103,114,117,87,89,113,50,90,105,
68,70,117,99,79,105,111,48,70,99,74,76,107,65,97,66,102,83,113,75,118,57,
114,117,108,88,110,114,55,83,47,10,97,81,43,107,119,99,48,105,122,70,99,
79,97,86,100,122,53,104,79,80,119,118,51,105,52,109,108,77,87,83,121,66,
51,87,56,54,97,106,53,65,76,119,70,65,97,49,121,112,73,57,73,111,56,51,
68,99,119,113,100,88,55,104,102,66,10,57,75,98,48,102,77,107,67,103,89,
65,109,118,86,43,107,113,87,104,85,103,68,89,119,78,78,122,49,113,68,97,
111,83,56,88,100,115,79,112,111,110,117,116,90,47,48,115,116,82,81,54,54,
109,75,65,121,56,107,78,86,78,78,81,54,10,111,85,120,49,88,70,108,49,87,
85,116,52,105,121,70,89,47,50,82,122,50,102,90,104,76,122,53,47,84,98,90,
82,75,53,121,103,111,54,54,54,87,103,110,120,66,47,85,100,52,71,65,120,
47,66,80,81,84,103,104,79,74,74,79,76,10,48,48,118,74,107,43,56,106,86,
67,71,78,68,99,57,52,50,86,54,110,70,88,122,110,68,77,88,119,113,120,104,
82,67,87,54,100,109,43,50,108,84,104,55,110,116,114,108,105,56,109,67,
107,53,103,73,85,67,74,90,75,65,77,65,122,10,107,121,114,50,118,108,50,
80,101,52,56,97,100,105,56,86,115,57,115,61,10,45,45,45,45,45,69,78,68,
32,68,83,65,32,80,82,73,86,65,84,69,32,75,69,89,45,45,45,45,45,
]);
assert(keyInfo.ppk === true, makeMsg(what, 'Expected PPK flag'));
assert(keyInfo._converted === true,
makeMsg(what, 'Expected automatic private PEM generation'));
assert(keyInfo._macresult === true,
makeMsg(what, 'Expected successful MAC verification'));
assert(keyInfo._decrypted === true,
makeMsg(what, 'Expected decrypted flag'));
assert.deepEqual(keyInfo.privateOrig,
expPrivOrig,
makeMsg(what, 'Decrypted private PEM data mismatch'));
next();
},
what: 'decryptKey - with encrypted DSA PPK'
},
{ run: function() {
var what = this.what;
var filepath = fixturesdir + '/id_rsa_enc';
var passphrase = 'foobarbaz';
var keyInfo = utils.parseKey(fs.readFileSync(filepath));
utils.decryptKey(keyInfo, passphrase);
var expPriv = new Buffer([
0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
0xec, 0x9f, 0xd7, 0x6e, 0x17, 0xfa, 0xe4, 0xc5, 0xff, 0xac, 0x83, 0x6e,
0xbe, 0x60, 0x66, 0xb2, 0xf2, 0x6a, 0x34, 0xfa, 0x4f, 0xe2, 0x49, 0xcd,
0x54, 0x29, 0x34, 0x95, 0x3b, 0x55, 0xc1, 0xf5, 0x1f, 0x16, 0x3f, 0x6a,
0x9f, 0xe5, 0x93, 0x7c, 0x25, 0xe0, 0x92, 0xdb, 0x63, 0x8d, 0xbb, 0xb4,
0xc2, 0x24, 0x7c, 0x9c, 0x69, 0x4c, 0xe0, 0xa7, 0x21, 0xac, 0xfc, 0xd3,
0x44, 0x3b, 0x1a, 0xaf, 0x9e, 0x60, 0x93, 0x09, 0xd3, 0xac, 0xb4, 0x65,
0x88, 0x39, 0x85, 0x8c, 0xd2, 0x04, 0x2c, 0xaf, 0x85, 0x27, 0x92, 0x59,
0x1b, 0x28, 0x73, 0x99, 0xf9, 0xc1, 0x6c, 0x37, 0x08, 0xa2, 0x77, 0x58,
0x5a, 0x8c, 0xb0, 0x96, 0xc0, 0x63, 0x8a, 0x10, 0x10, 0x84, 0xd8, 0xfa,
0x1e, 0xb7, 0x27, 0x58, 0xc1, 0x6b, 0x34, 0xb4, 0xe6, 0xa1, 0x05, 0x68,
0x82, 0xc9, 0xe3, 0x6a, 0x6f, 0x0b, 0xb5, 0xf7, 0x13, 0xa8, 0x8b, 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0xb3, 0xd7, 0x90, 0xe7,
0x08, 0x60, 0x52, 0x26, 0xee, 0x93, 0x40, 0x80, 0xd1, 0xaf, 0xaf, 0x74,
0x4d, 0x3b, 0x6f, 0x4e, 0x42, 0x91, 0x02, 0x81, 0x81, 0x00, 0xfe, 0x26,
0x9d, 0x81, 0xa1, 0xf3, 0xe2, 0x48, 0xad, 0x22, 0x4d, 0xf4, 0x1c, 0x68,
0x4d, 0xe1, 0xe2, 0xff, 0x09, 0xbf, 0xa6, 0x12, 0x0a, 0x16, 0xce, 0xd6,
0x34, 0x73, 0x7d, 0x55, 0xd3, 0x35, 0x6f, 0xb2, 0x4d, 0x64, 0xcb, 0x5e,
0x5e, 0x1a, 0xc8, 0xcf, 0x29, 0x58, 0x28, 0x30, 0xec, 0x29, 0x95, 0x09,
0x1b, 0x11, 0x80, 0xba, 0xe0, 0x16, 0x99, 0x49, 0x76, 0xb3, 0x42, 0x72,
0x05, 0x10, 0xf2, 0xf5, 0xa8, 0x36, 0x84, 0xf1, 0x83, 0x57, 0x5d, 0x27,
0xae, 0xe9, 0xae, 0x13, 0x47, 0xf3, 0xda, 0xb1, 0x42, 0xde, 0xa1, 0x25,
0xc7, 0x72, 0xee, 0x2e, 0x34, 0x78, 0x64, 0x6a, 0xed, 0x91, 0x81, 0xaf,
0x1e, 0xd3, 0xed, 0x68, 0x91, 0x37, 0x2f, 0xdd, 0x57, 0x5d, 0x2a, 0x3a,
0x21, 0x86, 0x74, 0x6d, 0xff, 0x0b, 0x56, 0xac, 0xc2, 0x65, 0x3a, 0x88,
0x91, 0x5e, 0x3c, 0x10, 0x7e, 0x53, 0x02, 0x81, 0x81, 0x00, 0xee, 0x58,
0x94, 0xcc, 0x96, 0x1b, 0x9a, 0x63, 0x84, 0x45, 0x7c, 0x92, 0x78, 0x35,
0x17, 0x7e, 0x7f, 0x7d, 0x6f, 0x06, 0x77, 0x69, 0x5c, 0xc4, 0xe8, 0xc7,
0x19, 0xd2, 0x5e, 0x58, 0xd2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QD+IEQf3RZDsi1NKIvMhV5f/O7R',
'mkK2kedFZFOnUdUK/bN2fmoXts/6dkVxqpBQIYgY6cvJ/i/FjHBaQLrqEvuKCjiiP55oQ0',
'qxCRLnk09eLKjNsCgYEAjp7Jwt/3Nu9uKjbr16RSQyeNqlItqMFm9J/GeJ4xZOZWyW2FeS',
'pcylMrGkb0FmD+Qc/HdFfQBvTJ+kecosvghcWVnzXdTBV62jTEgSB9VYXuJKemywrsqBNK',
'xKpaTPkywEtlR2W6OFcXDN3haNFPPbkO3T9T5pEOM7p3wgP1kGAHBwcHBwcH',
'-----END RSA PRIVATE KEY-----'
].join('\n');
assert(keyInfo.ppk === undefined, makeMsg(what, 'Unexpected PPK flag'));
assert(keyInfo._converted === undefined,
makeMsg(what, 'Unexpected automatic private PEM generation'));
assert(keyInfo._macresult === undefined,
makeMsg(what, 'Unexpected MAC verification'));
assert(keyInfo._decrypted === true,
makeMsg(what, 'Expected decrypted flag'));
assert.deepEqual(keyInfo.private,
expPriv,
makeMsg(what, 'Decrypted private data mismatch'));
assert.deepEqual(keyInfo.privateOrig,
expPrivOrig,
makeMsg(what, 'Decrypted private PEM data mismatch'));
next();
},
what: 'decryptKey - with encrypted RSA'
},
{ run: function() {
var pubkey = [
'---- BEGIN SSH2 PUBLIC KEY ----',
'Comment: "dsa-key-20151028"',
'AAAAB3NzaC1kc3MAAAEBAJ0Gth9JHw/a8RmY3Y0UFqBWVWkzWxkzG+DR2oqHwTIq',
'jAi9Xr06oSbdmXd3Jl3bHsbd2gVq4+/j32s0uIf6FEW7mFooSiDOcRWARJSAAmkI',
'T9ep//ag+gNUmwhtPebliCqcAn9VWE7wq2v0FJsG3trFW/pvi/hVsBOrkz4Qieqb',
'KbwNwZc/MI+h9KAQPV7tWN2y5aG3jlVD9PERyeFPlmYkD1P+IqytxvL3thUFKeru',
'N8w+hjKIGGonEcVzWRJ9UUBQqAaNNH4/9mzedpS8CivfnUvsIw9rSTB4N+Wf70jb',
'6a2qD1mHs1DqOkX136UOn5HkFldBnny0NSmlR/LewQkAAAAVAMu94kPPMR0Ew6Zh',
'mAoJJc0RjisBAAABAGkOU/b/I0opGITGCx9qFEcqiJ/VJHVsYhQgM/jCkydEc9kW',
'yjY+wKulGWpmA8wGmYm9j4IAgMGEXjBR8dyYJNZVXK0JOJmWrqUj5Q1GCUS5hCyU',
'iA7nmVQ4syhGE49aFBLFdyKS6t7//swEEEV+6Hw9qcQWB98zoD8qdPGz3W/9kNXB',
'OgVHWyqfWsbA/7MW2vjjF/u2EJe8YRKIJnodLOSNwPf0iCmj1HdaIm5N2Nl1k/6/',
'9MwlY6tjn4hinrEN/pOiC1ci/1ADmTq4L9upi1Paix51zD8Yp7q3SxOgZqFU0ELF',
'VP/XHokm278t1mE9hxDwkepv7XgBda8uamWzwSoAAAEAYl2bjiCjIB68+DNuRgtf',
'lvVk00nOH3dYXSslwKIFTivYDczjz0splaLsEhrdTRiOXyVsCEDhYtlvWlTw34rg',
's2QoutpqISOiq26XwPdOlejD7Hy7gtw3yRyrhbXHYHE0nOvx0/SP7il4ub//QRTd',
'7cUPao2f359cGpap84anqKJjF3m4oRGdZGhTAQPqtGMkchZvItKyZe6pJ9HhsE7h',
'NMsxPHAUon8QwNL1v+JkHg7i+Oe8rEZx/51m/qGVtXLN+z885lsqzuwe9KhY5I8C',
'C3f8nR+Mivfp1ce9pSMKCpdRASzOBuykZKYZmns6SA0UqAp7ZLDKubbhk9ZLVyAO',
'dA==',
'---- END SSH2 PUBLIC KEY ----'
].join('\n');
assert.doesNotThrow(function() {
var res = utils.genPublicKey(utils.parseKey(pubkey));
assert.deepEqual(
res,
{ type: 'dss',
fulltype: 'ssh-dss',
curve: undefined,
public: new Buffer([
0x00, 0x00, 0x00, 0x07, 0x73, 0x73, 0x68, 0x2d, 0x64, 0x73, 0x73,
0x00, 0x00, 0x01, 0x01, 0x00, 0x9d, 0x06, 0xb6, 0x1f, 0x49, 0x1f,
0x0f, 0xda, 0xf1, 0x19, 0x98, 0xdd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 0x7e, 0x3f, 0xf6, 0x6c, 0xde, 0x76,
0x94, 0xbc, 0x0a, 0x2b, 0xdf, 0x9d, 0x4b, 0xec, 0x23, 0x0f, 0x6b,
0x49, 0x30, 0x78, 0x37, 0xe5, 0x9f, 0xef, 0x48, 0xdb, 0xe9, 0xad,
0xaa, 0x0f, 0x59, 0x87, 0xb3, 0x50, 0xea, 0x3a, 0x45, 0xf5, 0xdf,
0xa5, 0x0e, 0x9f, 0x91, 0xe4, 0x16, 0x57, 0x41, 0x9e, 0x7c, 0xb4,
0x35, 0x29, 0xa5, 0x47, 0xf2, 0xde, 0xc1, 0x09, 0x00, 0x00, 0x00,
0x15, 0x00, 0xcb, 0xbd, 0xe2, 0x43, 0xcf, 0x31, 0x1d, 0x04, 0xc3,
0xa6, 0x61, 0x98, 0x0a, 0x09, 0x25, 0xcd, 0x11, 0x8e, 0x2b, 0x01,
0x00, 0x00, 0x01, 0x00, 0x69, 0x0e, 0x53, 0xf6, 0xff, 0x23, 0x4a,
0x29, 0x18, 0x84, 0xc6, 0x0b, 0x1f, 0x6a, 0x14, 0x47, 0x2a, 0x88,
0x9f, 0xd5, 0x24, 0x75, 0x6c, 0x62, 0x14, 0x20, 0x33, 0xf8, 0xc2,
0x93, 0x27, 0x44, 0x73, 0xd9, 0x16, 0xca, 0x36, 0x3e, 0xc0, 0xab,
0xa5, 0x19, 0x6a, 0x66, 0x03, 0xcc, 0x06, 0x99, 0x89, 0xbd, 0x8f,
0x82, 0x00, 0x80, 0xc1, 0x84, 0x5e, 0x30, 0x51, 0xf1, 0xdc, 0x98,
0x24, 0xd6, 0x55, 0x5c, 0xad, 0x09, 0x38, 0x99, 0x96, 0xae, 0xa5,
0x23, 0xe5, 0x0d, 0x46, 0x09, 0x44, 0xb9, 0x84, 0x2c, 0x94, 0x88,
0x0e, 0xe7, 0x99, 0x54, 0x38, 0xb3, 0x28, 0x46, 0x13, 0x8f, 0x5a,
0x14, 0x12, 0xc5, 0x77, 0x22, 0x92, 0x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x77,
0xfc, 0x9d, 0x1f, 0x8c, 0x8a, 0xf7, 0xe9, 0xd5, 0xc7, 0xbd, 0xa5,
0x23, 0x0a, 0x0a, 0x97, 0x51, 0x01, 0x2c, 0xce, 0x06, 0xec, 0xa4,
0x64, 0xa6, 0x19, 0x9a, 0x7b, 0x3a, 0x48, 0x0d, 0x14, 0xa8, 0x0a,
0x7b, 0x64, 0xb0, 0xca, 0xb9, 0xb6, 0xe1, 0x93, 0xd6, 0x4b, 0x57,
0x20, 0x0e, 0x74,
]),
publicOrig: new Buffer([
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20,
0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x44, 0x4f, 0x6a,
0x43, 0x43, 0x41, 0x69, 0x30, 0x47, 0x42, 0x79, 0x71, 0x47, 0x53,
0x4d, 0x34, 0x34, 0x42, 0x41, 0x45, 0x77, 0x67, 0x67, 0x49, 0x67,
0x41, 0x6f, 0x49, 0x42, 0x41, 0x51, 0x43, 0x64, 0x42, 0x72, 0x59,
0x66, 0x53, 0x52, 0x38, 0x50, 0x32, 0x76, 0x45, 0x5a, 0x6d, 0x4e,
0x32, 0x4e, 0x46, 0x42, 0x61, 0x67, 0x56, 0x6c, 0x56, 0x70, 0x4d,
0x31, 0x73, 0x5a, 0x0a, 0x4d, 0x78, 0x76, 0x67, 0x30, 0x64, 0x71,
0x4b, 0x68, 0x38, 0x45, 0x79, 0x4b, 0x6f, 0x77, 0x49, 0x76, 0x56,
0x36, 0x39, 0x4f, 0x71, 0x45, 0x6d, 0x33, 0x5a, 0x6c, 0x33, 0x64,
0x79, 0x5a, 0x64, 0x32, 0x78, 0x37, 0x47, 0x33, 0x64, 0x6f, 0x46,
0x61, 0x75, 0x50, 0x76, 0x34, 0x39, 0x39, 0x72, 0x4e, 0x4c, 0x69,
0x48, 0x2b, 0x68, 0x52, 0x46, 0x75, 0x35, 0x68, 0x61, 0x4b, 0x45,
0x6f, 0x67, 0x0a, 0x7a, 0x6e, 0x45, 0x56, 0x67, 0x45, 0x53, 0x55,
0x67, 0x41, 0x4a, 0x70, 0x43, 0x45, 0x2f, 0x58, 0x71, 0x66, 0x2f,
0x32, 0x6f, 0x50, 0x6f, 0x44, 0x56, 0x4a, 0x73, 0x49, 0x62, 0x54,
0x33, 0x6d, 0x35, 0x59, 0x67, 0x71, 0x6e, 0x41, 0x4a, 0x2f, 0x56,
0x56, 0x68, 0x4f, 0x38, 0x4b, 0x74, 0x72, 0x39, 0x42, 0x53, 0x62,
0x42, 0x74, 0x37, 0x61, 0x78, 0x56, 0x76, 0x36, 0x62, 0x34, 0x76,
0x34, 0x0a, 0x56, 0x62, 0x41, 0x54, 0x71, 0x35, 0x4d, 0x2b, 0x45,
0x49, 0x6e, 0x71, 0x6d, 0x79, 0x6d, 0x38, 0x44, 0x63, 0x47, 0x58,
0x50, 0x7a, 0x43, 0x50, 0x6f, 0x66, 0x53, 0x67, 0x45, 0x44, 0x31,
0x65, 0x37, 0x56, 0x6a, 0x64, 0x73, 0x75, 0x57, 0x68, 0x74, 0x34,
0x35, 0x56, 0x51, 0x2f, 0x54, 0x78, 0x45, 0x63, 0x6e, 0x68, 0x54,
0x35, 0x5a, 0x6d, 0x4a, 0x41, 0x39, 0x54, 0x2f, 0x69, 0x4b, 0x73,
0x0a, 0x72, 0x63, 0x62, 0x79, 0x39, 0x37, 0x59, 0x56, 0x42, 0x53,
0x6e, 0x71, 0x37, 0x6a, 0x66, 0x4d, 0x50, 0x6f, 0x59, 0x79, 0x69,
0x42, 0x68, 0x71, 0x4a, 0x78, 0x48, 0x46, 0x63, 0x31, 0x6b, 0x53,
0x66, 0x56, 0x46, 0x41, 0x55, 0x4b, 0x67, 0x47, 0x6a, 0x54, 0x52,
0x2b, 0x50, 0x2f, 0x5a, 0x73, 0x33, 0x6e, 0x61, 0x55, 0x76, 0x41,
0x6f, 0x72, 0x33, 0x35, 0x31, 0x4c, 0x37, 0x43, 0x4d, 0x50, 0x0a,
0x61, 0x30, 0x6b, 0x77, 0x65, 0x44, 0x66, 0x6c, 0x6e, 0x2b, 0x39,
0x49, 0x32, 0x2b, 0x6d, 0x74, 0x71, 0x67, 0x39, 0x5a, 0x68, 0x37,
0x4e, 0x51, 0x36, 0x6a, 0x70, 0x46, 0x39, 0x64, 0x2b, 0x6c, 0x44,
0x70, 0x2b, 0x52, 0x35, 0x42, 0x5a, 0x58, 0x51, 0x5a, 0x35, 0x38,
0x74, 0x44, 0x55, 0x70, 0x70, 0x55, 0x66, 0x79, 0x33, 0x73, 0x45,
0x4a, 0x41, 0x68, 0x55, 0x41, 0x79, 0x37, 0x33, 0x69, 0x0a, 0x51,
0x38, 0x38, 0x78, 0x48, 0x51, 0x54, 0x44, 0x70, 0x6d, 0x47, 0x59,
0x43, 0x67, 0x6b, 0x6c, 0x7a, 0x52, 0x47, 0x4f, 0x4b, 0x77, 0x45,
0x43, 0x67, 0x67, 0x45, 0x41, 0x61, 0x51, 0x35, 0x54, 0x39, 0x76,
0x38, 0x6a, 0x53, 0x69, 0x6b, 0x59, 0x68, 0x4d, 0x59, 0x4c, 0x48,
0x32, 0x6f, 0x55, 0x52, 0x79, 0x71, 0x49, 0x6e, 0x39, 0x55, 0x6b,
0x64, 0x57, 0x78, 0x69, 0x46, 0x43, 0x41, 0x7a, 0x0a, 0x2b, 0x4d,
0x4b, 0x54, 0x4a, 0x30, 0x52, 0x7a, 0x32, 0x52, 0x62, 0x4b, 0x4e,
0x6a, 0x37, 0x41, 0x71, 0x36, 0x55, 0x5a, 0x61, 0x6d, 0x59, 0x44,
0x7a, 0x41, 0x61, 0x5a, 0x69, 0x62, 0x32, 0x50, 0x67, 0x67, 0x43,
0x41, 0x77, 0x59, 0x52, 0x65, 0x4d, 0x46, 0x48, 0x78, 0x33, 0x4a,
0x67, 0x6b, 0x31, 0x6c, 0x56, 0x63, 0x72, 0x51, 0x6b, 0x34, 0x6d,
0x5a, 0x61, 0x75, 0x70, 0x53, 0x50, 0x6c, 0x0a, 0x44, 0x55, 0x59,
0x4a, 0x52, 0x4c, 0x6d, 0x45, 0x4c, 0x4a, 0x53, 0x49, 0x44, 0x75,
0x65, 0x5a, 0x56, 0x44, 0x69, 0x7a, 0x4b, 0x45, 0x59, 0x54, 0x6a,
0x31, 0x6f, 0x55, 0x45, 0x73, 0x56, 0x33, 0x49, 0x70, 0x4c, 0x71,
0x33, 0x76, 0x2f, 0x2b, 0x7a, 0x41, 0x51, 0x51, 0x52, 0x58, 0x37,
0x6f, 0x66, 0x44, 0x32, 0x70, 0x78, 0x42, 0x59, 0x48, 0x33, 0x7a,
0x4f, 0x67, 0x50, 0x79, 0x70, 0x30, 0x0a, 0x38, 0x62, 0x50, 0x64,
0x62, 0x2f, 0x32, 0x51, 0x31, 0x63, 0x45, 0x36, 0x42, 0x55, 0x64,
0x62, 0x4b, 0x70, 0x39, 0x61, 0x78, 0x73, 0x44, 0x2f, 0x73, 0x78,
0x62, 0x61, 0x2b, 0x4f, 0x4d, 0x58, 0x2b, 0x37, 0x59, 0x51, 0x6c,
0x37, 0x78, 0x68, 0x45, 0x6f, 0x67, 0x6d, 0x65, 0x68, 0x30, 0x73,
0x35, 0x49, 0x33, 0x41, 0x39, 0x2f, 0x53, 0x49, 0x4b, 0x61, 0x50,
0x55, 0x64, 0x31, 0x6f, 0x69, 0x0a, 0x62, 0x6b, 0x33, 0x59, 0x32,
0x58, 0x57, 0x54, 0x2f, 0x72, 0x2f, 0x30, 0x7a, 0x43, 0x56, 0x6a,
0x71, 0x32, 0x4f, 0x66, 0x69, 0x47, 0x4b, 0x65, 0x73, 0x51, 0x33,
0x2b, 0x6b, 0x36, 0x49, 0x4c, 0x56, 0x79, 0x4c, 0x2f, 0x55, 0x41,
0x4f, 0x5a, 0x4f, 0x72, 0x67, 0x76, 0x32, 0x36, 0x6d, 0x4c, 0x55,
0x39, 0x71, 0x4c, 0x48, 0x6e, 0x58, 0x4d, 0x50, 0x78, 0x69, 0x6e,
0x75, 0x72, 0x64, 0x4c, 0x0a, 0x45, 0x36, 0x42, 0x6d, 0x6f, 0x56,
0x54, 0x51, 0x51, 0x73, 0x56, 0x55, 0x2f, 0x39, 0x63, 0x65, 0x69,
0x53, 0x62, 0x62, 0x76, 0x79, 0x33, 0x57, 0x59, 0x54, 0x32, 0x48,
0x45, 0x50, 0x43, 0x52, 0x36, 0x6d, 0x2f, 0x74, 0x65, 0x41, 0x46,
0x31, 0x72, 0x79, 0x35, 0x71, 0x5a, 0x62, 0x50, 0x42, 0x4b, 0x67,
0x4f, 0x43, 0x41, 0x51, 0x55, 0x41, 0x41, 0x6f, 0x49, 0x42, 0x41,
0x47, 0x4a, 0x64, 0x0a, 0x6d, 0x34, 0x34, 0x67, 0x6f, 0x79, 0x41,
0x65, 0x76, 0x50, 0x67, 0x7a, 0x62, 0x6b, 0x59, 0x4c, 0x58, 0x35,
0x62, 0x31, 0x5a, 0x4e, 0x4e, 0x4a, 0x7a, 0x68, 0x39, 0x33, 0x57,
0x46, 0x30, 0x72, 0x4a, 0x63, 0x43, 0x69, 0x42, 0x55, 0x34, 0x72,
0x32, 0x41, 0x33, 0x4d, 0x34, 0x38, 0x39, 0x4c, 0x4b, 0x5a, 0x57,
0x69, 0x37, 0x42, 0x49, 0x61, 0x33, 0x55, 0x30, 0x59, 0x6a, 0x6c,
0x38, 0x6c, 0x0a, 0x62, 0x41, 0x68, 0x41, 0x34, 0x57, 0x4c, 0x5a,
0x62, 0x31, 0x70, 0x55, 0x38, 0x4e, 0x2b, 0x4b, 0x34, 0x4c, 0x4e,
0x6b, 0x4b, 0x4c, 0x72, 0x61, 0x61, 0x69, 0x45, 0x6a, 0x6f, 0x71,
0x74, 0x75, 0x6c, 0x38, 0x44, 0x33, 0x54, 0x70, 0x58, 0x6f, 0x77,
0x2b, 0x78, 0x38, 0x75, 0x34, 0x4c, 0x63, 0x4e, 0x38, 0x6b, 0x63,
0x71, 0x34, 0x57, 0x31, 0x78, 0x32, 0x42, 0x78, 0x4e, 0x4a, 0x7a,
0x72, 0x0a, 0x38, 0x64, 0x50, 0x30, 0x6a, 0x2b, 0x34, 0x70, 0x65,
0x4c, 0x6d, 0x2f, 0x2f, 0x30, 0x45, 0x55, 0x33, 0x65, 0x33, 0x46,
0x44, 0x32, 0x71, 0x4e, 0x6e, 0x39, 0x2b, 0x66, 0x58, 0x42, 0x71,
0x57, 0x71, 0x66, 0x4f, 0x47, 0x70, 0x36, 0x69, 0x69, 0x59, 0x78,
0x64, 0x35, 0x75, 0x4b, 0x45, 0x52, 0x6e, 0x57, 0x52, 0x6f, 0x55,
0x77, 0x45, 0x44, 0x36, 0x72, 0x52, 0x6a, 0x4a, 0x48, 0x49, 0x57,
0x0a, 0x62, 0x79, 0x4c, 0x53, 0x73, 0x6d, 0x58, 0x75, 0x71, 0x53,
0x66, 0x52, 0x34, 0x62, 0x42, 0x4f, 0x34, 0x54, 0x54, 0x4c, 0x4d,
0x54, 0x78, 0x77, 0x46, 0x4b, 0x4a, 0x2f, 0x45, 0x4d, 0x44, 0x53,
0x39, 0x62, 0x2f, 0x69, 0x5a, 0x42, 0x34, 0x4f, 0x34, 0x76, 0x6a,
0x6e, 0x76, 0x4b, 0x78, 0x47, 0x63, 0x66, 0x2b, 0x64, 0x5a, 0x76,
0x36, 0x68, 0x6c, 0x62, 0x56, 0x79, 0x7a, 0x66, 0x73, 0x2f, 0x0a,
0x50, 0x4f, 0x5a, 0x62, 0x4b, 0x73, 0x37, 0x73, 0x48, 0x76, 0x53,
0x6f, 0x57, 0x4f, 0x53, 0x50, 0x41, 0x67, 0x74, 0x33, 0x2f, 0x4a,
0x30, 0x66, 0x6a, 0x49, 0x72, 0x33, 0x36, 0x64, 0x58, 0x48, 0x76,
0x61, 0x55, 0x6a, 0x43, 0x67, 0x71, 0x58, 0x55, 0x51, 0x45, 0x73,
0x7a, 0x67, 0x62, 0x73, 0x70, 0x47, 0x53, 0x6d, 0x47, 0x5a, 0x70,
0x37, 0x4f, 0x6b, 0x67, 0x4e, 0x46, 0x4b, 0x67, 0x4b, 0x0a, 0x65,
0x32, 0x53, 0x77, 0x79, 0x72, 0x6d, 0x32, 0x34, 0x5a, 0x50, 0x57,
0x53, 0x31, 0x63, 0x67, 0x44, 0x6e, 0x51, 0x3d, 0x0a, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x50, 0x55, 0x42, 0x4c,
0x49, 0x43, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
])
}
);
next();
});
},
what: 'Generate public key from parsed public key'
},
];
function next() {
if (Array.isArray(process._events.exit))
process._events.exit = process._events.exit[1];
if (++t === tests.length)
return;
var v = tests[t];
process.nextTick(function() {
v.run.call(v);
});
}
function makeMsg(what, msg) {
return '[' + group + what + ']: ' + msg;
}
process.once('exit', function() {
assert(t === tests.length,
makeMsg('_exit',
'Only finished ' + t + '/' + tests.length + ' tests'));
});
next();

22
build/node_modules/ssh2-streams/test/test.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
var spawn = require('child_process').spawn,
join = require('path').join;
var files = require('fs').readdirSync(__dirname).filter(function(f) {
return (f.substr(0, 5) === 'test-');
}).map(function(f) {
return join(__dirname, f);
}),
f = -1;
function next() {
if (++f < files.length) {
spawn(process.argv[0], [ files[f] ], { stdio: 'inherit' })
.on('exit', function(code) {
if (code === 0)
process.nextTick(next);
else
process.exit(code);
});
}
}
next();