1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | declare class SshPK {}
|
9 |
|
10 | declare namespace SshPK {
|
11 | class Algo {
|
12 | parts: string[];
|
13 | sizePart?: string;
|
14 | normalize?: boolean;
|
15 | }
|
16 |
|
17 | class algInfo {
|
18 | dsa: Algo;
|
19 | rsa: Algo;
|
20 | ecdsa: Algo;
|
21 | ed25519: Algo;
|
22 | curve25519: Algo;
|
23 | }
|
24 |
|
25 | class algPrivInfo {
|
26 | dsa: Algo;
|
27 | rsa: Algo;
|
28 | ecdsa: Algo;
|
29 | ed25519: Algo;
|
30 | curve25519: Algo;
|
31 | }
|
32 |
|
33 | class hashAlgs {
|
34 | md5: boolean;
|
35 | sha1: boolean;
|
36 | sha256: boolean;
|
37 | sha384: boolean;
|
38 | sha512: boolean;
|
39 | }
|
40 |
|
41 | class Curve {
|
42 | size: number;
|
43 | pkcs8oid: string;
|
44 | p: Buffer;
|
45 | a: Buffer;
|
46 | b: Buffer;
|
47 | s: Buffer;
|
48 | n: Buffer;
|
49 | G: Buffer;
|
50 | }
|
51 |
|
52 | class curves {
|
53 | nistp256: Curve;
|
54 | nistp384: Curve;
|
55 | nistp512: Curve;
|
56 | }
|
57 |
|
58 | class algs {
|
59 | info: algInfo;
|
60 | privInfo: algPrivInfo;
|
61 | hashAlgs: hashAlgs;
|
62 | curves: curves;
|
63 | }
|
64 |
|
65 | class Certificate {
|
66 | subjects: Identity[];
|
67 | issuer: string;
|
68 | subjectKey: string;
|
69 | issuerKey: string;
|
70 | signatures: string;
|
71 | serial: string;
|
72 | validFrom: string;
|
73 | validUntil: string;
|
74 | static formats: Formats;
|
75 | constructor(opts: any);
|
76 |
|
77 | toBuffer(format: string, options?: any): Buffer;
|
78 |
|
79 | toString(format: string, options?: any): string;
|
80 |
|
81 | fingerprint(algo: string): Fingerprint;
|
82 |
|
83 | hash(algo: string): string;
|
84 |
|
85 | isExpired(when: Date): boolean;
|
86 |
|
87 | isSignedBy(issuerCert: Certificate): boolean;
|
88 |
|
89 | isSignedByKey(issuerKey: Key): boolean;
|
90 |
|
91 | signWith(key: Key): void;
|
92 |
|
93 | static createSelfSigned(subjectOrSubjects: string, key: Key, options: any): Certificate;
|
94 |
|
95 | static create(subjectOrSubjects: string, key: Key, issuer: string, issuerKey: PrivateKey, options: any): Certificate;
|
96 |
|
97 | static parse(data: string|Buffer, format: string, options: any): Certificate;
|
98 |
|
99 | static isCertificate(data: string|Buffer, ver: string): boolean;
|
100 | }
|
101 |
|
102 | class DiffieHellman {
|
103 | constructor(key: Key);
|
104 |
|
105 | getPublicKey(): Key;
|
106 | getPrivateKey(): PrivateKey;
|
107 | getKey(): PrivateKey;
|
108 | setKey(key: PrivateKey): void;
|
109 | setPrivateKey(key: PrivateKey): void;
|
110 |
|
111 | computeSecret(otherpk: PrivateKey): Buffer;
|
112 |
|
113 | generateKey(): PrivateKey;
|
114 | generateKeys(): PrivateKey;
|
115 | }
|
116 |
|
117 | class X9ECParameters {
|
118 | G: any;
|
119 | g: any;
|
120 | n: any;
|
121 | h: any;
|
122 | }
|
123 |
|
124 | class ECPublic {
|
125 | constructor(params: X9ECParameters, buffer: Buffer);
|
126 | }
|
127 |
|
128 | class ECPrivate {
|
129 | constructor(params: X9ECParameters, buffer: Buffer);
|
130 | deriveSharedSecret(pk: Key): Buffer;
|
131 | }
|
132 |
|
133 | class Verifier {
|
134 | constructor(key: Key, hashAlgo: string);
|
135 |
|
136 | update(chunk: string|Buffer): void;
|
137 |
|
138 | verify(signature: string): boolean;
|
139 | }
|
140 |
|
141 | class Signer {
|
142 | constructor(key: Key, hashAlgo: string);
|
143 |
|
144 | update(chunk: string|Buffer): void;
|
145 | sign(): Signature;
|
146 | }
|
147 |
|
148 | class FingerprintFormatError implements Error {
|
149 | name: string;
|
150 | message: string;
|
151 | constructor(fp: Fingerprint, format: string);
|
152 | }
|
153 |
|
154 | class InvalidAlgorithmError implements Error {
|
155 | name: string;
|
156 | message: string;
|
157 | constructor(algo: string);
|
158 | }
|
159 |
|
160 | class KeyParseError implements Error {
|
161 | name: string;
|
162 | message: string;
|
163 | constructor(name: string, format: string, innerErr: any);
|
164 | }
|
165 |
|
166 | class SignatureParseError implements Error {
|
167 | name: string;
|
168 | message: string;
|
169 | constructor(type: string, format: string, innerErr: any);
|
170 | }
|
171 |
|
172 | class CertificateParseError implements Error {
|
173 | name: string;
|
174 | message: string;
|
175 | constructor(name: string, format: string, innerErr: any);
|
176 | }
|
177 |
|
178 | class KeyEncryptedError implements Error {
|
179 | name: string;
|
180 | message: string;
|
181 | constructor(name: string, format: string);
|
182 | }
|
183 |
|
184 | class Fingerprint {
|
185 | algorithm: string;
|
186 | hash: string;
|
187 | type: string;
|
188 | constructor(opts: any);
|
189 |
|
190 | toString(format?: string): string;
|
191 | matches(other: Fingerprint): boolean;
|
192 | addColons(fp: string): string;
|
193 | base64Strip(fp: string): string;
|
194 | sshBase64Format(alg: string, h: string): string;
|
195 | isFingerprint(obj: string|Buffer, ver: string): boolean;
|
196 |
|
197 | static parse(fp: string, options: any): Fingerprint;
|
198 | }
|
199 |
|
200 | class Identity {
|
201 | cn: string;
|
202 | components: string[];
|
203 | componentLookup: any;
|
204 | type: string;
|
205 | hostname: string;
|
206 | uid: string;
|
207 | email: string;
|
208 | constructor(opts: any);
|
209 |
|
210 | toString(): string;
|
211 |
|
212 | toAsn1(der: Buffer|string, tag: string): void;
|
213 |
|
214 | equals(other: Identity): boolean;
|
215 |
|
216 | static forHost(hostname: string): Identity;
|
217 | static forUser(uid: string): Identity;
|
218 | static forEmail(email: string): Identity;
|
219 | static parseDN(dn: string): Identity;
|
220 | static parseAsn1(dn: Buffer|string, top: string): Identity;
|
221 | static isIdentity(dn: Buffer|string, ver: string): boolean;
|
222 | }
|
223 |
|
224 | class Format {
|
225 | read: (buf: Buffer, options?: any) => Buffer;
|
226 | write: (key: Key, options?: any) => Buffer;
|
227 | }
|
228 |
|
229 | class Formats {
|
230 | auto: Format;
|
231 | pem: Format;
|
232 | pkcs1: Format;
|
233 | pkcs8: Format;
|
234 | rfc4253: Format;
|
235 | ssh: Format;
|
236 | "ssh-private": Format;
|
237 | openssh: Format;
|
238 | }
|
239 |
|
240 | class Verify {
|
241 | verify(data: string, fmt: string): boolean;
|
242 | }
|
243 |
|
244 | class Key {
|
245 | type: string;
|
246 | parts: string;
|
247 | part: string;
|
248 | comment?: string;
|
249 | source?: string;
|
250 | curve?: string;
|
251 | size: number;
|
252 | constructor(opts: any);
|
253 |
|
254 | static formats: Formats;
|
255 |
|
256 | toBuffer(format: string, options?: any): Buffer;
|
257 | toString(format: string, options?: any): string;
|
258 | hash(algo: string): Buffer;
|
259 | fingerprint(algo: string): Fingerprint;
|
260 | defaultHashAlgorithm(): string;
|
261 | createVerify(algo: string): Verify;
|
262 | createDiffieHellman(): DiffieHellman;
|
263 | createDH(): DiffieHellman;
|
264 |
|
265 | static parse(data: string|Buffer, format: string, options: any): Key;
|
266 |
|
267 | static isKey(obj: string|Buffer, ver: string): boolean;
|
268 | }
|
269 |
|
270 | class PrivateKey {
|
271 | comment?: string;
|
272 | constructor(opts: any);
|
273 |
|
274 | static formats: Formats;
|
275 |
|
276 | toBuffer(format: string, options: any): Buffer;
|
277 | hash(algo: string): Buffer;
|
278 | toPublic(): Key;
|
279 | derive(newType: string, newSize: number): PrivateKey;
|
280 | createVerify(hashAlgo: string): Key;
|
281 | createSign(hashAlgo: string): Signer;
|
282 |
|
283 | static parse(data: string|Buffer, format: string, options: any): PrivateKey;
|
284 | static isPrivateKey(data: string|Buffer, ver: string): boolean;
|
285 | }
|
286 |
|
287 | class Signature {
|
288 | constructor(opts: any);
|
289 | toBuffer(format: string): Buffer;
|
290 | toString(format: string): string;
|
291 |
|
292 | static parse(data: string|Buffer, type: string, format: string): Signature;
|
293 |
|
294 | static isSignature(obj: string|Buffer, ver: string): boolean;
|
295 | }
|
296 |
|
297 | class SSHPart {
|
298 | data: Buffer;
|
299 | }
|
300 |
|
301 | class SSHBuffer {
|
302 | constructor(opts: any);
|
303 | toBuffer(): Buffer;
|
304 | atEnd(): boolean;
|
305 | remainder(): Buffer;
|
306 | skip(n: number): void;
|
307 | expand(): void;
|
308 | readPart(): SSHPart;
|
309 | readBuffer(): Buffer;
|
310 | readString(): string;
|
311 | readInt(): number;
|
312 | readInt64(): Buffer;
|
313 | readChar(): string;
|
314 | writeBuffer(buf: Buffer): void;
|
315 | writeString(buf: string): void;
|
316 | writeCString(buf: string): void;
|
317 | writeInt(buf: number): void;
|
318 | writeInt64(buf: Buffer): void;
|
319 | writeChar(buf: string): void;
|
320 | writePart(buf: SSHPart): void;
|
321 | write(buf: Buffer): void;
|
322 | }
|
323 |
|
324 | function bufferSplit(buf: Buffer, chr: string): Buffer[];
|
325 | function addRSAMissing(key: PrivateKey): void;
|
326 | function calculateDSAPublic(g: Buffer, p: Buffer, x: Buffer): Buffer;
|
327 | function mpNormalize(buf: Buffer): Buffer;
|
328 | function ecNormalize(buf: Buffer, addZero: boolean): Buffer;
|
329 | function countZeros(buf: Buffer): number;
|
330 | function assertCompatible(obj: any, klass: any, needVer: string, name: string): void;
|
331 | function isCompatible(obj: any, klass: any, needVer: string): boolean;
|
332 | class OpenSllKeyDeriv {
|
333 | key: Buffer;
|
334 | iv: Buffer;
|
335 | }
|
336 | function opensslKeyDeriv(cipher: string, salt: string, passphrase: string, count: number): OpenSllKeyDeriv;
|
337 |
|
338 | class OpensshCipherInfo {
|
339 | keySize: number;
|
340 | blockSize: number;
|
341 | opensslName: string;
|
342 | }
|
343 | function opensshCipherInfo(cipber: string): OpensshCipherInfo;
|
344 |
|
345 | function parseKey(data: string|Buffer, format: string, options?: any): Key;
|
346 | function parseFingerprint(fp: string, options?: any): Fingerprint;
|
347 | function parseSignature(data: string|Buffer, type: string, format: string): Signature;
|
348 | function parsePrivateKey(data: string|Buffer, format: string, options?: any): PrivateKey;
|
349 |
|
350 | function parseCertificate(data: string|Buffer, format: string, options?: any): Certificate;
|
351 | function createSelfSignedCertificate(subjectOrSubjects: string, key: Key, options?: any): Certificate;
|
352 | function createCertificate(
|
353 | subjectOrSubjects: string, key: Key, issuer: string,
|
354 | issuerKey: PrivateKey, options?: any): Certificate;
|
355 |
|
356 | function identityFromDN(dn: string): Identity;
|
357 | function identityForHost(hostname: string): Identity;
|
358 | function identityForUser(uid: string): Identity;
|
359 | function identityForEmail(email: string): Identity;
|
360 | }
|
361 |
|
362 | export = SshPK;
|