node-ikev2 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1013 @@
1
+ import { Proposal } from "./proposal";
2
+ import { Attribute } from "./attribute";
3
+ import { TrafficSelector } from "./selector";
4
+ /**
5
+ * IKEv2 Payload Types: \
6
+ Next Payload Type Notation Value
7
+ --------------------------------------------------
8
+ No Next Payload 0 \
9
+ Security Association SA 33 \
10
+ Key Exchange KE 34 \
11
+ Identification - Initiator IDi 35 \
12
+ Identification - Responder IDr 36 \
13
+ Certificate CERT 37 \
14
+ Certificate Request CERTREQ 38 \
15
+ Authentication AUTH 39 \
16
+ Nonce Ni, Nr 40 \
17
+ Notify N 41 \
18
+ Delete D 42 \
19
+ Vendor ID V 43 \
20
+ Traffic Selector - Initiator TSi 44 \
21
+ Traffic Selector - Responder TSr 45 \
22
+ Encrypted and Authenticated SK 46 \
23
+ Configuration CP 47 \
24
+ Extensible Authentication EAP 48
25
+ */
26
+ export declare enum payloadType {
27
+ NONE = 0,
28
+ SA = 33,
29
+ KE = 34,
30
+ IDi = 35,
31
+ IDr = 36,
32
+ CERT = 37,
33
+ CERTREQ = 38,
34
+ AUTH = 39,
35
+ NONCE = 40,
36
+ NOTIFY = 41,
37
+ DELETE = 42,
38
+ VENDOR = 43,
39
+ TSi = 44,
40
+ TSr = 45,
41
+ SK = 46,
42
+ CP = 47,
43
+ EAP = 48
44
+ }
45
+ /**
46
+ * IKEv2 Generic Payload Header
47
+ * @class
48
+ * @property {payloadType}
49
+ * @property {payloadType} nextPayload - 1 byte
50
+ * @property {boolean} critical - 1 bit
51
+ * @property {number} length - 2 bytes
52
+ */
53
+ export declare class Payload {
54
+ type: payloadType;
55
+ nextPayload: payloadType;
56
+ critical: boolean;
57
+ length: number;
58
+ constructor(type: payloadType, nextPayload: payloadType, critical: boolean | undefined, // default to false for all defined payloads in IKEv2
59
+ length: number);
60
+ /**
61
+ * Parses a payload generic header from a buffer
62
+ * @param buffer
63
+ * @static
64
+ * @public
65
+ * @returns
66
+ */
67
+ static parse(buffer: Buffer): Payload;
68
+ /**
69
+ * Serialize a JSON payload to a buffer
70
+ * @param json
71
+ * @static
72
+ * @public
73
+ * @returns {Buffer}
74
+ */
75
+ static serializeJSON(json: Record<string, any>): Buffer;
76
+ /**
77
+ * Serializes the payload to a buffer
78
+ * @public
79
+ * @returns {Buffer}
80
+ */
81
+ serialize(): Buffer;
82
+ /**
83
+ * Returns a JSON representation of the payload
84
+ * @public
85
+ * @returns {Record<string, any>}
86
+ */
87
+ toJSON(): Record<string, any>;
88
+ /**
89
+ * Returns a string representation of the payload
90
+ * @public
91
+ * @returns {string}
92
+ */
93
+ genToJSON(): Record<string, any>;
94
+ /**
95
+ * Returns a string representation of the payload
96
+ * @public
97
+ * @returns {string}
98
+ */
99
+ genToString(): string;
100
+ }
101
+ /**
102
+ * IKEv2 Security Association Payload
103
+ * @class
104
+ * @extends Payload
105
+ */
106
+ export declare class PayloadSA extends Payload {
107
+ nextPayload: payloadType;
108
+ proposals: Proposal[];
109
+ critical: boolean;
110
+ length: number;
111
+ constructor(nextPayload: payloadType, proposals: Proposal[], critical?: boolean, length?: number);
112
+ /**
113
+ * Parses a Security Association Payload from a buffer
114
+ * @param buffer
115
+ * @static
116
+ * @public
117
+ * @returns {PayloadSA}
118
+ */
119
+ static parse(buffer: Buffer): PayloadSA;
120
+ /**
121
+ * Serializes a JSON representation of the SA payload to a buffer
122
+ * @param json
123
+ * @static
124
+ * @public
125
+ * @returns {Buffer}
126
+ */
127
+ static serializeJSON(json: Record<string, any>): Buffer;
128
+ /**
129
+ * Serializes the SA payload to a buffer
130
+ * @public
131
+ * @returns {Buffer}
132
+ */
133
+ serialize(): Buffer;
134
+ /**
135
+ * Returns a JSON representation of the SA payload
136
+ * @public
137
+ * @returns {Record<string, any>}
138
+ */
139
+ toJSON(): Record<string, any>;
140
+ /**
141
+ * Returns a string representation of the SA payload
142
+ * @public
143
+ * @returns {string}
144
+ */
145
+ toString(): string;
146
+ }
147
+ /**
148
+ * IKEv2 Key Exchange Payload
149
+ * @class
150
+ * @extends Payload
151
+ */
152
+ export declare class PayloadKE extends Payload {
153
+ nextPayload: payloadType;
154
+ dhGroup: number;
155
+ keyData: Buffer;
156
+ critical: boolean;
157
+ length: number;
158
+ constructor(nextPayload: payloadType, dhGroup: number, keyData: Buffer, critical?: boolean, length?: number);
159
+ /**
160
+ * Parses a Key Exchange Payload from a buffer
161
+ * @param buffer
162
+ * @static
163
+ * @public
164
+ * @returns {PayloadKE}
165
+ */
166
+ static parse(buffer: Buffer): PayloadKE;
167
+ /**
168
+ * Serializes a JSON representation of the KE payload to a buffer
169
+ * @param json
170
+ * @static
171
+ * @public
172
+ * @returns {Buffer}
173
+ */
174
+ static serializeJSON(json: Record<string, any>): Buffer;
175
+ /**
176
+ * Serializes the KE payload to a buffer
177
+ * @public
178
+ * @returns {Buffer}
179
+ */
180
+ serialize(): Buffer;
181
+ /**
182
+ * Returns a JSON representation of the KE payload
183
+ * @public
184
+ * @returns {Record<string, any>}
185
+ */
186
+ toJSON(): Record<string, any>;
187
+ /**
188
+ * Returns a string representation of the KE payload
189
+ * @public
190
+ * @returns {string}
191
+ */
192
+ toString(): string;
193
+ }
194
+ /**
195
+ * IKEv2 Identification Payload
196
+ * @enum
197
+ */
198
+ export declare enum IDType {
199
+ ID_IPV4_ADDR = 1,
200
+ ID_FQDN = 2,
201
+ ID_RFC822_ADDR = 3,
202
+ ID_IPV6_ADDR = 5,
203
+ ID_DER_ASN1_DN = 9,
204
+ ID_DER_ASN1_GN = 10,
205
+ ID_KEY_ID = 11
206
+ }
207
+ /**
208
+ * IKEv2 Identification Payload
209
+ * @class
210
+ * @extends Payload
211
+ */
212
+ export declare class PayloadID extends Payload {
213
+ nextPayload: payloadType;
214
+ idType: number;
215
+ idData: Buffer;
216
+ critical: boolean;
217
+ length: number;
218
+ constructor(nextPayload: payloadType, idType: number, idData: Buffer, critical?: boolean, length?: number);
219
+ /**
220
+ * Parses an Identification Payload from a buffer
221
+ * @param buffer
222
+ * @static
223
+ * @public
224
+ * @returns {PayloadID}
225
+ */
226
+ static parse(buffer: Buffer): PayloadID;
227
+ /**
228
+ * Serializes a JSON representation of the ID payload to a buffer
229
+ * @param json
230
+ * @static
231
+ * @public
232
+ * @returns {Buffer}
233
+ */
234
+ static serializeJSON(json: Record<string, any>): Buffer;
235
+ /**
236
+ * Serializes the ID payload to a buffer
237
+ * @public
238
+ * @returns {Buffer}
239
+ */
240
+ serialize(): Buffer;
241
+ /**
242
+ * Returns a JSON representation of the ID payload
243
+ * @public
244
+ * @returns {Record<string, any>}
245
+ */
246
+ toJSON(): Record<string, any>;
247
+ /**
248
+ * Returns a string representation of the ID payload
249
+ * @public
250
+ * @returns {string}
251
+ */
252
+ toString(): string;
253
+ }
254
+ /**
255
+ * IKEv2 Identification - Initiator Payload
256
+ * @class
257
+ * @extends PayloadID
258
+ */
259
+ export declare class PayloadIDi extends PayloadID {
260
+ nextPayload: payloadType;
261
+ idType: number;
262
+ idData: Buffer;
263
+ critical: boolean;
264
+ length: number;
265
+ constructor(nextPayload: payloadType, idType: number, idData: Buffer, critical?: boolean, length?: number);
266
+ }
267
+ /**
268
+ * IKEv2 Identification - Responder Payload
269
+ * @class
270
+ * @extends PayloadID
271
+ */
272
+ export declare class PayloadIDr extends PayloadID {
273
+ nextPayload: payloadType;
274
+ idType: number;
275
+ idData: Buffer;
276
+ critical: boolean;
277
+ length: number;
278
+ constructor(nextPayload: payloadType, idType: number, idData: Buffer, critical: boolean, length: number);
279
+ }
280
+ /**
281
+ * IKEv2 Notify Message Types
282
+ * @enum
283
+ */
284
+ export declare enum CertificateType {
285
+ RESERVED = 0,
286
+ PKCS7_X509_CERTIFICATE = 1,
287
+ PGP_CERTIFICATE = 2,
288
+ DNS_SIGNED_KEY = 3,
289
+ X509_CERTIFICATE_SIGNATURE = 4,
290
+ UNDEFINED = 5,// Undefined by any document
291
+ KERBEROS_TOKENS = 6,
292
+ CRL = 7,// Certificate Revocation List (CRL)
293
+ ARL = 8,// Authority Revocation List (ARL)
294
+ SPKI_CERTIFICATE = 9,
295
+ X509_CERTIFICATE_ATTRIBUTE = 10,
296
+ RAW_RSA_KEY = 11,
297
+ HASH_AND_URL_X509_CERTIFICATE = 12,
298
+ HASH_AND_URL_X509_BUNDLE = 13,
299
+ OCSP_CONTENT = 14
300
+ }
301
+ /**
302
+ * IKEv2 Certificate Payload
303
+ * @class
304
+ * @extends Payload
305
+ */
306
+ export declare class PayloadCERT extends Payload {
307
+ nextPayload: payloadType;
308
+ certEncoding: number;
309
+ certData: Buffer;
310
+ critical: boolean;
311
+ length: number;
312
+ constructor(nextPayload: payloadType, certEncoding: number, certData: Buffer, critical?: boolean, length?: number);
313
+ /**
314
+ * Parses a Certificate Payload from a buffer
315
+ * @param buffer
316
+ * @static
317
+ * @public
318
+ * @returns {PayloadCERT}
319
+ */
320
+ static parse(buffer: Buffer): PayloadCERT;
321
+ /**
322
+ * Serializes a JSON representation of the CERT payload to a buffer
323
+ * @param json
324
+ * @static
325
+ * @public
326
+ * @returns {Buffer}
327
+ */
328
+ static serializeJSON(json: Record<string, any>): Buffer;
329
+ /**
330
+ * Serializes the CERT payload to a buffer
331
+ * @public
332
+ * @returns {Buffer}
333
+ */
334
+ serialize(): Buffer;
335
+ /**
336
+ * Returns a JSON representation of the CERT payload
337
+ * @public
338
+ * @returns {Record<string, any>}
339
+ */
340
+ toJSON(): Record<string, any>;
341
+ /**
342
+ * Returns a string representation of the CERT payload
343
+ * @public
344
+ * @returns {string}
345
+ */
346
+ toString(): string;
347
+ }
348
+ /**
349
+ * IKEv2 Certificate Request Payload
350
+ * @class
351
+ * @extends Payload
352
+ */
353
+ export declare class PayloadCERTREQ extends Payload {
354
+ nextPayload: payloadType;
355
+ certEncoding: number;
356
+ certAuthority: Buffer;
357
+ critical: boolean;
358
+ length: number;
359
+ constructor(nextPayload: payloadType, certEncoding: number, certAuthority: Buffer, critical?: boolean, length?: number);
360
+ /**
361
+ * Parses a Certificate Request Payload from a buffer
362
+ * @param buffer
363
+ * @static
364
+ * @public
365
+ * @returns {PayloadCERTREQ}
366
+ */
367
+ static parse(buffer: Buffer): PayloadCERTREQ;
368
+ /**
369
+ * Serializes a JSON representation of the CERTREQ payload to a buffer
370
+ * @param json
371
+ * @static
372
+ * @public
373
+ * @returns {Buffer}
374
+ */
375
+ static serializeJSON(json: Record<string, any>): Buffer;
376
+ /**
377
+ * Serializes the CERTREQ payload to a buffer
378
+ * @public
379
+ * @returns {Buffer}
380
+ */
381
+ serialize(): Buffer;
382
+ /**
383
+ * Returns a JSON representation of the CERTREQ payload
384
+ * @public
385
+ * @returns {Record<string, any>}
386
+ */
387
+ toJSON(): Record<string, any>;
388
+ /**
389
+ * Returns a string representation of the CERTREQ payload
390
+ * @public
391
+ * @returns {string}
392
+ */
393
+ toString(): string;
394
+ }
395
+ /**
396
+ * IKEv2 Authentication Payload
397
+ * @class
398
+ * @extends Payload
399
+ */
400
+ export declare class PayloadAUTH extends Payload {
401
+ nextPayload: payloadType;
402
+ authMethod: number;
403
+ authData: Buffer;
404
+ critical: boolean;
405
+ length: number;
406
+ constructor(nextPayload: payloadType, authMethod: number, authData: Buffer, critical?: boolean, length?: number);
407
+ /**
408
+ * Parses an Authentication Payload from a buffer
409
+ * @param buffer
410
+ * @static
411
+ * @public
412
+ * @returns {PayloadAUTH}
413
+ */
414
+ static parse(buffer: Buffer): PayloadAUTH;
415
+ /**
416
+ * Serializes a JSON representation of the AUTH payload to a buffer
417
+ * @param json
418
+ * @static
419
+ * @public
420
+ * @returns {Buffer}
421
+ */
422
+ static serializeJSON(json: Record<string, any>): Buffer;
423
+ /**
424
+ * Serializes the AUTH payload to a buffer
425
+ * @public
426
+ * @returns {Buffer}
427
+ */
428
+ serialize(): Buffer;
429
+ /**
430
+ * Returns a JSON representation of the AUTH payload
431
+ * @public
432
+ * @returns {Record<string, any>}
433
+ */
434
+ toJSON(): Record<string, any>;
435
+ /**
436
+ * Returns a string representation of the AUTH payload
437
+ * @public
438
+ * @returns {string}
439
+ */
440
+ toString(): string;
441
+ }
442
+ /**
443
+ * IKEv2 Nonce Payload
444
+ * @class
445
+ * @extends Payload
446
+ */
447
+ export declare class PayloadNONCE extends Payload {
448
+ nextPayload: payloadType;
449
+ nonceData: Buffer;
450
+ critical: boolean;
451
+ length: number;
452
+ constructor(nextPayload: payloadType, nonceData: Buffer, critical?: boolean, length?: number);
453
+ /**
454
+ * Parses a Nonce Payload from a buffer
455
+ * @param buffer
456
+ * @static
457
+ * @public
458
+ * @returns {PayloadNONCE}
459
+ */
460
+ static parse(buffer: Buffer): PayloadNONCE;
461
+ /**
462
+ * Serializes a JSON representation of the NONCE payload to a buffer
463
+ * @param json
464
+ * @static
465
+ * @public
466
+ * @returns {Buffer}
467
+ */
468
+ static serializeJSON(json: Record<string, any>): Buffer;
469
+ /**
470
+ * Serializes the NONCE payload to a buffer
471
+ * @public
472
+ * @returns {Buffer}
473
+ */
474
+ serialize(): Buffer;
475
+ /**
476
+ * Returns a JSON representation of the NONCE payload
477
+ * @public
478
+ * @returns {Record<string, any>}
479
+ */
480
+ toJSON(): Record<string, any>;
481
+ /**
482
+ * Returns a string representation of the NONCE payload
483
+ * @public
484
+ * @returns {string}
485
+ */
486
+ toString(): string;
487
+ }
488
+ /**
489
+ * IKEv2 Protocol Id
490
+ * @enum
491
+ */
492
+ export declare enum securityProtocolId {
493
+ NONE = 0,// Used for example in Notify payloads, when that doesn't apply to any SA
494
+ IKE = 1,// Internet Key Exchange (RFC 7296)
495
+ AH = 2,// Authentication Header (RFC 7296)
496
+ ESP = 3,// Encapsulating Security Payload (RFC 7296)
497
+ FC_ESP_HEADER = 4,// RFC 4595
498
+ FC_CT_AUTHENTICATION = 5,// RFC 4595
499
+ GIKE_UPDATE = 6
500
+ }
501
+ /**
502
+ * IKEv2 Notify Message Types
503
+ * @enum
504
+ */
505
+ export declare enum notifyMessageType {
506
+ UNSUPPORTED_CRITICAL_PAYLOAD = 1,
507
+ INVALID_IKE_SPI = 4,
508
+ INVALID_MAJOR_VERSION = 5,
509
+ INVALID_SYNTAX = 7,
510
+ INVALID_MESSAGE_ID = 9,
511
+ INVALID_SPI = 11,
512
+ NO_PROPOSAL_CHOSEN = 14,
513
+ INVALID_KE_PAYLOAD = 17,
514
+ AUTHENTICATION_FAILED = 24,
515
+ SINGLE_PAIR_REQUIRED = 34,
516
+ NO_ADDITIONAL_SAS = 35,
517
+ INTERNAL_ADDRESS_FAILURE = 36,
518
+ FAILED_CP_REQUIRED = 37,
519
+ TS_UNACCEPTABLE = 38,
520
+ INVALID_SELECTORS = 39,
521
+ TEMPORARY_FAILURE = 43,
522
+ CHILD_SA_NOT_FOUND = 44,
523
+ INITIAL_CONTACT = 16384,
524
+ SET_WINDOW_SIZE = 16385,
525
+ ADDITIONAL_TS_POSSIBLE = 16386,
526
+ IPCOMP_SUPPORTED = 16387,
527
+ NAT_DETECTION_SOURCE_IP = 16388,
528
+ NAT_DETECTION_DESTINATION_IP = 16389,
529
+ COOKIE = 16390,
530
+ USE_TRANSPORT_MODE = 16391,
531
+ HTTP_CERT_LOOKUP_SUPPORTED = 16392,
532
+ REKEY_SA = 16393,
533
+ ESP_TFC_PADDING_NOT_SUPPORTED = 16394,
534
+ NON_FIRST_FRAGMENTS_ALSO = 16395,
535
+ MOBIKE_SUPPORTED = 16396,// RFC4555
536
+ ADDITIONAL_IP4_ADDRESS = 16397,// RFC4555
537
+ ADDITIONAL_IP6_ADDRESS = 16398,// RFC4555
538
+ NO_ADDITIONAL_ADDRESSES = 16399,// RFC4555
539
+ UPDATE_SA_ADDRESSES = 16400,// RFC4555
540
+ COOKIE2 = 16401,// RFC4555
541
+ NO_NATS_ALLOWED = 16402,// RFC4555
542
+ AUTH_LIFETIME = 16403,// RFC4478
543
+ MULTIPLE_AUTH_SUPPORTED = 16404,// RFC4739
544
+ ANOTHER_AUTH_FOLLOWS = 16405,// RFC4739
545
+ REDIRECT_SUPPORTED = 16406,// RFC5685
546
+ REDIRECT = 16407,// RFC5685
547
+ REDIRECTED_FROM = 16408,// RFC5685
548
+ TICKET_LT_OPAQUE = 16409,// RFC5723
549
+ TICKET_REQUEST = 16410,// RFC5723
550
+ TICKET_ACK = 16411,// RFC5723
551
+ TICKET_NACK = 16412,// RFC5723
552
+ TICKET_OPAQUE = 16413,// RFC5723
553
+ LINK_ID = 16414,// RFC5739
554
+ USE_WESP_MODE = 16415,// RFC5840
555
+ ROHC_SUPPORTED = 16416,// RFC5857
556
+ EAP_ONLY_AUTHENTICATION = 16417,// RFC5998
557
+ CHILDLESS_IKEV2_SUPPORTED = 16418,// RFC6023
558
+ QUICK_CRASH_DETECTION = 16419,// RFC6290
559
+ IKEV2_MESSAGE_ID_SYNC_SUPPORTED = 16420,// RFC6311
560
+ IPSEC_REPLAY_COUNTER_SYNC_SUPPORTED = 16421,// RFC6311
561
+ IKEV2_MESSAGE_ID_SYNC = 16422,// RFC6311
562
+ IPSEC_REPLAY_COUNTER_SYNC = 16423,// RFC6311
563
+ SECURE_PASSWORD_METHODS = 16424,// RFC6467
564
+ PSK_PERSIST = 16425,// RFC6631
565
+ PSK_CONFIRM = 16426,// RFC6631
566
+ ERX_SUPPORTED = 16427,// RFC6867
567
+ IFOM_CAPABILITY = 16428,// 3GPP TS 24.303 v10.6.0 annex B.2
568
+ SENDER_REQUEST_ID = 16429,// draft-yeung-g-ikev2
569
+ IKEV2_FRAGMENTATION_SUPPORTED = 16430,// RFC7383
570
+ SIGNATURE_HASH_ALGORITHMS = 16431,// RFC7427
571
+ CLONE_IKE_SA_SUPPORTED = 16432,// RFC7791
572
+ CLONE_IKE_SA = 16433,// RFC7791
573
+ PUZZLE = 16434,// RFC8019
574
+ USE_PPK = 16435,// RFC8784
575
+ PPK_IDENTITY = 16436,// RFC8784
576
+ NO_PPK_AUTH = 16437,
577
+ INTERMEDIATE_EXCHANGE_SUPPORTED = 16438,// RFC9242
578
+ IP4_ALLOWED_1 = 16439,// RFC8983
579
+ IP4_ALLOWED_2 = 16440,// RFC8983
580
+ ADDITIONAL_KEY_EXCHANGE = 16441,// RFC9370
581
+ USE_AGGFRAG = 16442,// RFC9347
582
+ RESERVED_TO_IANA_STATUS_TYPES = 16443
583
+ }
584
+ /**
585
+ * IKEv2 Notify Payload
586
+ * @class
587
+ * @extends Payload
588
+ */
589
+ export declare class PayloadNOTIFY extends Payload {
590
+ nextPayload: payloadType;
591
+ protocolId: securityProtocolId;
592
+ spiSize: number;
593
+ notifyType: number;
594
+ spi: Buffer;
595
+ notifyData: Buffer;
596
+ critical: boolean;
597
+ length: number;
598
+ constructor(nextPayload: payloadType, protocolId: securityProtocolId, spiSize: number, notifyType: number, spi: Buffer, notifyData: Buffer, critical?: boolean, length?: number);
599
+ /**
600
+ * Parses a Notify Payload from a buffer
601
+ * @param buffer
602
+ * @static
603
+ * @public
604
+ * @returns {PayloadNOTIFY}
605
+ */
606
+ static parse(buffer: Buffer): PayloadNOTIFY;
607
+ /**
608
+ * Serializes a JSON representation of the NOTIFY payload to a buffer
609
+ * @param json
610
+ * @static
611
+ * @public
612
+ * @returns {Buffer}
613
+ */
614
+ static serializeJSON(json: Record<string, any>): Buffer;
615
+ /**
616
+ * Serializes the NOTIFY payload to a buffer
617
+ * @public
618
+ * @returns {Buffer}
619
+ */
620
+ serialize(): Buffer;
621
+ /**
622
+ * Returns a JSON representation of the NOTIFY payload
623
+ * @public
624
+ * @returns {Record<string, any>}
625
+ */
626
+ toJSON(): Record<string, any>;
627
+ /**
628
+ * Returns a string representation of the NOTIFY payload
629
+ * @public
630
+ * @returns {string}
631
+ */
632
+ toString(): string;
633
+ }
634
+ /**
635
+ * IKEv2 Delete Payload
636
+ * @class
637
+ * @extends Payload
638
+ */
639
+ export declare class PayloadDELETE extends Payload {
640
+ nextPayload: payloadType;
641
+ protocolId: number;
642
+ spiSize: number;
643
+ numSpi: number;
644
+ spis: Buffer[];
645
+ critical: boolean;
646
+ length: number;
647
+ constructor(nextPayload: payloadType, protocolId: number, spiSize: number, numSpi: number, spis: Buffer[], critical?: boolean, length?: number);
648
+ /**
649
+ * Parses a Delete Payload from a buffer
650
+ * @param buffer
651
+ * @static
652
+ * @public
653
+ * @returns {PayloadDELETE}
654
+ */
655
+ static parse(buffer: Buffer): PayloadDELETE;
656
+ /**
657
+ * Serializes a JSON representation of the DELETE payload to a buffer
658
+ * @param json
659
+ * @static
660
+ * @public
661
+ * @returns {Buffer}
662
+ */
663
+ static serializeJSON(json: Record<string, any>): Buffer;
664
+ /**
665
+ * Serializes the DELETE payload to a buffer
666
+ * @public
667
+ * @returns {Buffer}
668
+ */
669
+ serialize(): Buffer;
670
+ /**
671
+ * Returns a JSON representation of the DELETE payload
672
+ * @public
673
+ * @returns {Record<string, any>}
674
+ */
675
+ toJSON(): Record<string, any>;
676
+ /**
677
+ * Returns a string representation of the DELETE payload
678
+ * @public
679
+ * @returns {string}
680
+ */
681
+ toString(): string;
682
+ }
683
+ /**
684
+ * IKEv2 Vendor ID Payload
685
+ * @class
686
+ * @extends Payload
687
+ */
688
+ export declare class PayloadVENDOR extends Payload {
689
+ nextPayload: payloadType;
690
+ vendorId: Buffer;
691
+ critical: boolean;
692
+ length: number;
693
+ constructor(nextPayload: payloadType, vendorId: Buffer, critical?: boolean, length?: number);
694
+ /**
695
+ * Parses a Vendor ID Payload from a buffer
696
+ * @param buffer
697
+ * @static
698
+ * @public
699
+ * @returns {PayloadVENDOR}
700
+ */
701
+ static parse(buffer: Buffer): PayloadVENDOR;
702
+ /**
703
+ * Serializes a JSON representation of the VENDOR payload to a buffer
704
+ * @param json
705
+ * @static
706
+ * @public
707
+ * @returns {Buffer}
708
+ */
709
+ static serializeJSON(json: Record<string, any>): Buffer;
710
+ /**
711
+ * Serializes the VENDOR payload to a buffer
712
+ * @public
713
+ * @returns {Buffer}
714
+ */
715
+ serialize(): Buffer;
716
+ /**
717
+ * Returns a JSON representation of the VENDOR payload
718
+ * @public
719
+ * @returns {Record<string, any>}
720
+ */
721
+ toJSON(): Record<string, any>;
722
+ /**
723
+ * Returns a string representation of the VENDOR payload
724
+ * @public
725
+ * @returns {string}
726
+ */
727
+ toString(): string;
728
+ }
729
+ /**
730
+ * IKEv2 Traffic Selector
731
+ * @class
732
+ * @extends Payload
733
+ */
734
+ export declare class PayloadTS extends Payload {
735
+ nextPayload: payloadType;
736
+ numTs: number;
737
+ tsList: TrafficSelector[];
738
+ critical: boolean;
739
+ length: number;
740
+ constructor(nextPayload: payloadType, numTs: number, tsList: TrafficSelector[], critical?: boolean, length?: number);
741
+ /**
742
+ * Parses a Traffic Selector Payload from a buffer
743
+ * @param buffer
744
+ * @static
745
+ * @public
746
+ * @returns {PayloadTS}
747
+ */
748
+ static parse(buffer: Buffer): PayloadTS;
749
+ /**
750
+ * Serializes a JSON representation of the TS payload to a buffer
751
+ * @param json
752
+ * @static
753
+ * @public
754
+ * @returns {Buffer}
755
+ */
756
+ static serializeJSON(json: Record<string, any>): Buffer;
757
+ /**
758
+ * Serializes the TS payload to a buffer
759
+ * @public
760
+ * @returns {Buffer}
761
+ */
762
+ serialize(): Buffer;
763
+ /**
764
+ * Returns a JSON representation of the TS payload
765
+ * @public
766
+ * @returns {Record<string, any>}
767
+ */
768
+ toJSON(): Record<string, any>;
769
+ /**
770
+ * Returns a string representation of the TS payload
771
+ * @public
772
+ * @returns {string}
773
+ */
774
+ toString(): string;
775
+ }
776
+ /**
777
+ * IKEv2 Traffic Selector - Initiator Payload
778
+ * @class
779
+ * @extends Payload
780
+ */
781
+ export declare class PayloadTSi extends PayloadTS {
782
+ nextPayload: payloadType;
783
+ numTs: number;
784
+ tsList: TrafficSelector[];
785
+ critical: boolean;
786
+ length: number;
787
+ constructor(nextPayload: payloadType, numTs: number, tsList: TrafficSelector[], critical?: boolean, length?: number);
788
+ }
789
+ /**
790
+ * IKEv2 Traffic Selector - Responder Payload
791
+ * @class
792
+ * @extends Payload
793
+ */
794
+ export declare class PayloadTSr extends PayloadTS {
795
+ nextPayload: payloadType;
796
+ numTs: number;
797
+ tsList: TrafficSelector[];
798
+ critical: boolean;
799
+ length: number;
800
+ constructor(nextPayload: payloadType, numTs: number, tsList: TrafficSelector[], critical?: boolean, length?: number);
801
+ }
802
+ /**
803
+ * IKEv2 Encrypted and Authenticated Payload
804
+ * @class
805
+ * @extends Payload
806
+ */
807
+ export declare class PayloadSK extends Payload {
808
+ nextPayload: payloadType;
809
+ encryptedData: Buffer;
810
+ critical: boolean;
811
+ length: number;
812
+ constructor(nextPayload: payloadType, encryptedData: Buffer, critical?: boolean, length?: number);
813
+ /**
814
+ * Parses an SK Payload from a buffer
815
+ * @param buffer
816
+ * @static
817
+ * @public
818
+ * @returns {PayloadSK}
819
+ */
820
+ static parse(buffer: Buffer): PayloadSK;
821
+ /**
822
+ * Serializes a JSON representation of the SK payload to a buffer
823
+ * @param json
824
+ * @static
825
+ * @public
826
+ * @returns {Buffer}
827
+ */
828
+ static serializeJSON(json: Record<string, any>): Buffer;
829
+ /**
830
+ * Serializes the SK payload to a buffer
831
+ * @public
832
+ * @returns {Buffer}
833
+ */
834
+ serialize(): Buffer;
835
+ /**
836
+ * Returns a JSON representation of the SK payload
837
+ * @public
838
+ * @returns {Record<string, any>}
839
+ */
840
+ toJSON(): Record<string, any>;
841
+ /**
842
+ * Returns a string representation of the SK payload
843
+ * @public
844
+ * @returns {string}
845
+ */
846
+ toString(): string;
847
+ /**
848
+ * Decrypts the encrypted data in the SK payload.
849
+ *
850
+ * The decryptFunction should handle removing the IV, Padding and Integrity Checksum Data.
851
+ *
852
+ * This should be called after checking the Integrity Checksum Data (except for AEAD algorithms, which are
853
+ * self-checking).
854
+ *
855
+ * @param aad Additional Authenticated Data to include in the Integrity Checksum Data calculation - include here
856
+ * the entire IKE header and the SK payload header (first 4 bytes of the SK payload), so everything before the IV
857
+ * inside the SK payload. This is needed for AEAD algorithms, which include integrity protection in the encryption
858
+ * process (they output inClearData is shorter than the encryptedData).
859
+ * @param decryptFunction Function that takes a Buffer and returns a decrypted Buffer
860
+ * @returns {Payload[]} Array of decrypted Payloads
861
+ * @public
862
+ */
863
+ decrypt(decryptFunction: (data: Buffer, aad?: Buffer) => {
864
+ inClearData: Buffer;
865
+ iv: Buffer;
866
+ }, aad?: Buffer): {
867
+ firstPayload: payloadType;
868
+ inClearPayloads: Payload[];
869
+ iv: Buffer;
870
+ };
871
+ /**
872
+ * Encrypts data and sets it as the encrypted data in the SK payload. Should be called before serializing the IKE
873
+ * message, when the SK payload is included and is the last one in the message.
874
+ *
875
+ * Also sets the nextPayload in the SK payload as the type of the first payload inside the encrypted data. This is
876
+ * an exception to the rule, but the SK payload is always the last one in the message, to compensate.
877
+ *
878
+ * The encryptFunction should include pre-pending the IV, appending Padding and space for the Integrity Checksum Data.
879
+ *
880
+ * The Integrity Checksum Data bytes will have to be updated after the entire IKE message is serialized. The IV is
881
+ * needed then, so it is returned by this function.
882
+ *
883
+ * @param inClearPayloads Array of Payloads to encrypt
884
+ * @param aad Additional Authenticated Data to include in the Integrity Checksum Data calculation - include here
885
+ * the entire IKE header and the SK payload header (first 4 bytes of the SK payload), so everything before the IV
886
+ * inside the SK payload. This is needed for AEAD algorithms, which include integrity protection in the encryption
887
+ * process (they would also produce more data than the plaintext payloads data).
888
+ * @param encryptFunction Function that takes a Buffer and returns an encrypted Buffer
889
+ * @returns The IV used for encryption, to be used in the message.updateIntegrityChecksumData function
890
+ */
891
+ encrypt(inClearPayloads: Payload[], encryptFunction: (data: Buffer, aad?: Buffer) => {
892
+ skPayloadData: Buffer;
893
+ iv: Buffer;
894
+ }, aad?: Buffer): {
895
+ iv: Buffer;
896
+ };
897
+ }
898
+ /**
899
+ * IKEv2 Configuration Payload - Types
900
+ * @enum
901
+ */
902
+ export declare enum cfgType {
903
+ CFG_REQUEST = 1,
904
+ CFG_REPLY = 2,
905
+ CFG_SET = 3,
906
+ CFG_ACK = 4
907
+ }
908
+ /**
909
+ * IKEv2 Configuration Payload
910
+ * @class
911
+ * @extends Payload
912
+ */
913
+ export declare class PayloadCP extends Payload {
914
+ nextPayload: payloadType;
915
+ cfgType: number;
916
+ cfgData: Buffer;
917
+ critical: boolean;
918
+ length: number;
919
+ constructor(nextPayload: payloadType, cfgType: number, cfgData: Buffer, critical?: boolean, length?: number);
920
+ /**
921
+ * Parses a Configuration Payload from a buffer
922
+ * @param buffer
923
+ * @static
924
+ * @public
925
+ * @returns {PayloadCP}
926
+ */
927
+ static parse(buffer: Buffer): PayloadCP;
928
+ /**
929
+ * Serializes a JSON representation of the CP payload to a buffer
930
+ * @param json
931
+ * @static
932
+ * @public
933
+ * @returns {Buffer}
934
+ */
935
+ static serializeJSON(json: Record<string, any>): Buffer;
936
+ /**
937
+ * Serializes the CP payload to a buffer
938
+ * @public
939
+ * @returns {Buffer}
940
+ */
941
+ serialize(): Buffer;
942
+ /**
943
+ * Returns a JSON representation of the CP payload
944
+ * @public
945
+ * @returns {Record<string, any>}
946
+ */
947
+ toJSON(): Record<string, any>;
948
+ /**
949
+ * Returns a string representation of the CP payload
950
+ * @public
951
+ * @returns {string}
952
+ */
953
+ toString(): string;
954
+ }
955
+ /**
956
+ * IKEv2 Extensible Authentication Payload
957
+ * @class
958
+ * @extends Payload
959
+ */
960
+ export declare class PayloadEAP extends Payload {
961
+ nextPayload: payloadType;
962
+ tlvData: Attribute;
963
+ critical: boolean;
964
+ length: number;
965
+ constructor(nextPayload: payloadType, tlvData: Attribute, critical?: boolean, length?: number);
966
+ /**
967
+ * Parses an EAP Payload from a buffer
968
+ * @param buffer
969
+ * @static
970
+ * @public
971
+ * @returns {PayloadEAP}
972
+ */
973
+ static parse(buffer: Buffer): PayloadEAP;
974
+ /**
975
+ * Serializes a JSON representation of the EAP payload to a buffer
976
+ * @param json
977
+ * @static
978
+ * @public
979
+ * @returns {Buffer}
980
+ */
981
+ static serializeJSON(json: Record<string, any>): Buffer;
982
+ /**
983
+ * Serializes the EAP payload to a buffer
984
+ * @public
985
+ * @returns {Buffer}
986
+ */
987
+ serialize(): Buffer;
988
+ /**
989
+ * Returns a JSON representation of the EAP payload
990
+ * @public
991
+ * @returns {Record<string, any>}
992
+ */
993
+ toJSON(): Record<string, any>;
994
+ /**
995
+ * Returns a string representation of the EAP payload
996
+ * @public
997
+ * @returns {string}
998
+ */
999
+ toString(): string;
1000
+ }
1001
+ /**
1002
+ * Base interface for all payload classes
1003
+ */
1004
+ interface PayloadClass {
1005
+ new (...args: any[]): Payload;
1006
+ parse(buffer: Buffer): Payload;
1007
+ serializeJSON(json: Record<string, any>): Buffer;
1008
+ }
1009
+ /**
1010
+ * Payload Type to its class mapping for IKEv2 payloads
1011
+ */
1012
+ export declare const payloadTypeMapping: Record<payloadType, PayloadClass>;
1013
+ export {};