mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Merge pull request #33167 from jeffrson/master
@types/ssh2-streams: utils.parseKey now conforms to current API
This commit is contained in:
commit
85dafa1108
18
types/ssh2-streams/index.d.ts
vendored
18
types/ssh2-streams/index.d.ts
vendored
@ -1686,23 +1686,17 @@ export interface Stats extends Attributes {
|
||||
}
|
||||
|
||||
export namespace utils {
|
||||
export function parseKey(keyData: string | Buffer): ParsedKey | Error;
|
||||
export function genPublicKey(privKeyInfo: ParsedKey): ParsedKey;
|
||||
export function decryptKey(privKeyInfo: ParsedKey, passphrase: string): void;
|
||||
export function parseKey(keyData: string | Buffer, passphrase?: string): ParsedKey | {}[];
|
||||
}
|
||||
|
||||
export interface ParsedKey {
|
||||
fulltype: string;
|
||||
type: string;
|
||||
extra: string;
|
||||
comment: string;
|
||||
encryption: string;
|
||||
private: Buffer;
|
||||
privateOrig: Buffer;
|
||||
public: Buffer;
|
||||
publicOrig: Buffer;
|
||||
ppk?: boolean;
|
||||
privateMAC?: string;
|
||||
getPrivatePEM(): string;
|
||||
getPublicPEM(): string;
|
||||
getPublicSSH(): string;
|
||||
sign(data: string | Buffer): Buffer | Error;
|
||||
verify(data: string | Buffer, signature: Buffer): boolean | Error;
|
||||
}
|
||||
|
||||
export interface ReadFileOptions {
|
||||
|
||||
@ -87,9 +87,7 @@ server.forwardedTcpip(0, 0, 0, { bindAddr: "bindAddr", bindPort: 8080, remoteAdd
|
||||
server.x11(0, 0, 0, { originAddr: "originAddr", originPort: 0 });
|
||||
server.openssh_forwardedStreamLocal(0, 0, 0, { socketPath: "socketPath" });
|
||||
|
||||
const maybeParsedKey = ssh2.utils.parseKey("keyData");
|
||||
ssh2.utils.decryptKey(parsedKey, "passphrase");
|
||||
const publicKey = ssh2.utils.genPublicKey(parsedKey);
|
||||
const maybeParsedKey = ssh2.utils.parseKey("keyData", "passphrase");
|
||||
|
||||
|
||||
declare const attrs: ssh2.Attributes;
|
||||
|
||||
@ -313,7 +313,8 @@ var buffersEqual = require('buffer-equal-constant-time'),
|
||||
//ssh2 = require('ssh2'),
|
||||
utils = ssh2.utils;
|
||||
|
||||
var pubKey = utils.genPublicKey(utils.parseKey(fs.readFileSync('user.pub')) as ssh2_streams.ParsedKey);
|
||||
var pubKey = utils.parseKey(fs.readFileSync('user.pub')) as ssh2_streams.ParsedKey;
|
||||
var pubKeySSH = Buffer.from(pubKey.getPublicSSH());
|
||||
|
||||
new ssh2.Server({
|
||||
hostKeys: [fs.readFileSync('host.key')]
|
||||
@ -326,15 +327,14 @@ new ssh2.Server({
|
||||
&& ctx.password === 'bar')
|
||||
ctx.accept();
|
||||
else if (ctx.method === 'publickey'
|
||||
&& ctx.key.algo === pubKey.fulltype
|
||||
&& buffersEqual(ctx.key.data, pubKey.public)) {
|
||||
&& ctx.key.algo === pubKey.type
|
||||
&& buffersEqual(ctx.key.data, pubKeySSH)) {
|
||||
if (ctx.signature) {
|
||||
var verifier = crypto.createVerify(ctx.sigAlgo);
|
||||
verifier.update(ctx.blob);
|
||||
if (verifier.verify(pubKey.publicOrig.toString("utf8"), ctx.signature))
|
||||
if (pubKey.verify(ctx.blob, ctx.signature)) {
|
||||
ctx.accept();
|
||||
else
|
||||
} else {
|
||||
ctx.reject();
|
||||
}
|
||||
} else {
|
||||
// if no signature present, that means the client is just checking
|
||||
// the validity of the given public key
|
||||
|
||||
Loading…
Reference in New Issue
Block a user