netkitty 0.0.20 → 0.0.22

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.
Files changed (75) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.idea/inspectionProfiles/Project_Default.xml +2 -1
  3. package/.idea/netkitty.iml +0 -1
  4. package/cpp/nodepcap/deps/include/Packet32.h +429 -429
  5. package/cpp/nodepcap/deps/include/pcap/bluetooth.h +56 -56
  6. package/cpp/nodepcap/deps/include/pcap/bpf.h +292 -292
  7. package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +56 -56
  8. package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +163 -163
  9. package/cpp/nodepcap/deps/include/pcap/dlt.h +1514 -1514
  10. package/cpp/nodepcap/deps/include/pcap/funcattrs.h +325 -325
  11. package/cpp/nodepcap/deps/include/pcap/ipnet.h +43 -43
  12. package/cpp/nodepcap/deps/include/pcap/namedb.h +84 -84
  13. package/cpp/nodepcap/deps/include/pcap/nflog.h +94 -94
  14. package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +101 -101
  15. package/cpp/nodepcap/deps/include/pcap/pcap.h +1219 -1219
  16. package/cpp/nodepcap/deps/include/pcap/sll.h +149 -149
  17. package/cpp/nodepcap/deps/include/pcap/socket.h +84 -84
  18. package/cpp/nodepcap/deps/include/pcap/usb.h +143 -143
  19. package/cpp/nodepcap/deps/include/pcap/vlan.h +46 -46
  20. package/cpp/nodepcap/deps/include/pcap-bpf.h +45 -45
  21. package/cpp/nodepcap/deps/include/pcap-namedb.h +40 -40
  22. package/cpp/nodepcap/deps/include/pcap.h +43 -43
  23. package/dist/PcapExports.d.ts +13 -0
  24. package/dist/PcapExports.d.ts.map +1 -1
  25. package/dist/PcapExports.js +16 -1
  26. package/dist/lib/codec/Codec.js +1 -1
  27. package/dist/lib/codec/PacketHeaders.d.ts +5 -0
  28. package/dist/lib/codec/PacketHeaders.d.ts.map +1 -1
  29. package/dist/lib/codec/PacketHeaders.js +13 -1
  30. package/dist/lib/codec/abstracts/BaseHeader.d.ts +2 -2
  31. package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +1 -1
  32. package/dist/lib/codec/abstracts/BaseHeader.js +4 -4
  33. package/dist/lib/codec/headers/EthernetII.js +1 -1
  34. package/dist/lib/codec/headers/Goose.js +5 -5
  35. package/dist/lib/codec/headers/IEC61850SampledValues.js +1 -1
  36. package/dist/lib/codec/headers/IPv4.js +2 -2
  37. package/dist/lib/codec/headers/TLS_Alert.d.ts +10 -0
  38. package/dist/lib/codec/headers/TLS_Alert.d.ts.map +1 -0
  39. package/dist/lib/codec/headers/TLS_Alert.js +624 -0
  40. package/dist/lib/codec/headers/TLS_ApplicationData.d.ts +10 -0
  41. package/dist/lib/codec/headers/TLS_ApplicationData.d.ts.map +1 -0
  42. package/dist/lib/codec/headers/TLS_ApplicationData.js +155 -0
  43. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts +10 -0
  44. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts.map +1 -0
  45. package/dist/lib/codec/headers/TLS_ChangeCipherSpec.js +154 -0
  46. package/dist/lib/codec/headers/TLS_Handshake.d.ts +10 -0
  47. package/dist/lib/codec/headers/TLS_Handshake.d.ts.map +1 -0
  48. package/dist/lib/codec/headers/TLS_Handshake.js +339 -0
  49. package/dist/lib/codec/headers/TLS_Heartbeat.d.ts +10 -0
  50. package/dist/lib/codec/headers/TLS_Heartbeat.d.ts.map +1 -0
  51. package/dist/lib/codec/headers/TLS_Heartbeat.js +206 -0
  52. package/dist/lib/codec/headers/VLAN_802dot1Q.js +1 -1
  53. package/dist/lib/pcap/PCAPGenerator.d.ts +2 -2
  54. package/dist/lib/pcap/PCAPGenerator.d.ts.map +1 -1
  55. package/dist/lib/pcap/PCAPGenerator.js +7 -1
  56. package/package.json +1 -1
  57. package/src/PcapExports.ts +16 -0
  58. package/src/lib/codec/Codec.ts +1 -1
  59. package/src/lib/codec/PacketHeaders.ts +7 -0
  60. package/src/lib/codec/abstracts/BaseHeader.ts +4 -4
  61. package/src/lib/codec/headers/EthernetII.ts +1 -1
  62. package/src/lib/codec/headers/Goose.ts +5 -5
  63. package/src/lib/codec/headers/IEC61850SampledValues.ts +1 -1
  64. package/src/lib/codec/headers/IPv4.ts +2 -2
  65. package/src/lib/codec/headers/TLS_Alert.ts +539 -0
  66. package/src/lib/codec/headers/TLS_ApplicationData.ts +145 -0
  67. package/src/lib/codec/headers/TLS_ChangeCipherSpec.ts +146 -0
  68. package/src/lib/codec/headers/TLS_Handshake.ts +313 -0
  69. package/src/lib/codec/headers/TLS_Heartbeat.ts +188 -0
  70. package/src/lib/codec/headers/VLAN_802dot1Q.ts +1 -1
  71. package/src/lib/pcap/PCAPGenerator.ts +8 -3
  72. package/dist/NetKitty.d.ts +0 -1
  73. package/dist/NetKitty.d.ts.map +0 -1
  74. package/dist/NetKitty.js +0 -90
  75. package/src/NetKitty.ts +0 -91
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TLS_ApplicationData = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToNumber_1 = require("../../helper/BufferToNumber");
6
+ const BufferToHex_1 = require("../../helper/BufferToHex");
7
+ const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
8
+ const HexToBuffer_1 = require("../../helper/HexToBuffer");
9
+ var TLSver;
10
+ (function (TLSver) {
11
+ TLSver["SSL_3_0"] = "SSL3.0";
12
+ TLSver["TLS_1_0"] = "TLS1.0";
13
+ TLSver["TLS_1_1"] = "TLS1.1";
14
+ TLSver["TLS_1_2"] = "TLS1.2";
15
+ TLSver["TLS_1_3"] = "TLS1.3";
16
+ })(TLSver || (TLSver = {}));
17
+ class TLS_ApplicationData extends BaseHeader_1.BaseHeader {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.SCHEMA = {
21
+ type: 'object',
22
+ properties: {
23
+ contentType: {
24
+ type: 'integer',
25
+ label: 'Content Type',
26
+ minimum: 0,
27
+ maximum: 255,
28
+ decode: () => {
29
+ this.instance.contentType.setValue((0, BufferToNumber_1.BufferToInt8)(this.readBytes(0, 1)));
30
+ },
31
+ encode: () => {
32
+ const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
33
+ this.writeBytes(0, contentType);
34
+ }
35
+ },
36
+ version: {
37
+ type: 'string',
38
+ label: 'Legacy Version',
39
+ minimum: 0,
40
+ maximum: 65535,
41
+ decode: () => {
42
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
43
+ switch (version) {
44
+ case 768:
45
+ {
46
+ this.instance.version.setValue(TLSver.SSL_3_0);
47
+ }
48
+ break;
49
+ case 769:
50
+ {
51
+ this.instance.version.setValue(TLSver.TLS_1_0);
52
+ }
53
+ break;
54
+ case 770:
55
+ {
56
+ this.instance.version.setValue(TLSver.TLS_1_1);
57
+ }
58
+ break;
59
+ case 771:
60
+ {
61
+ this.instance.version.setValue(TLSver.TLS_1_2);
62
+ }
63
+ break;
64
+ case 772:
65
+ {
66
+ this.instance.version.setValue(TLSver.TLS_1_3);
67
+ }
68
+ break;
69
+ default: {
70
+ this.instance.version.setValue('0');
71
+ }
72
+ }
73
+ },
74
+ encode: () => {
75
+ const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not found'));
76
+ switch (version) {
77
+ case TLSver.SSL_3_0:
78
+ {
79
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(768);
80
+ this.writeBytes(1, version);
81
+ }
82
+ break;
83
+ case TLSver.TLS_1_0:
84
+ {
85
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(769);
86
+ this.writeBytes(1, version);
87
+ }
88
+ break;
89
+ case TLSver.TLS_1_1:
90
+ {
91
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(770);
92
+ this.writeBytes(1, version);
93
+ }
94
+ break;
95
+ case TLSver.TLS_1_2:
96
+ {
97
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(771);
98
+ this.writeBytes(1, version);
99
+ }
100
+ break;
101
+ case TLSver.TLS_1_3:
102
+ {
103
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(772);
104
+ this.writeBytes(1, version);
105
+ }
106
+ break;
107
+ default: {
108
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
109
+ }
110
+ }
111
+ }
112
+ },
113
+ length: {
114
+ type: 'integer',
115
+ label: 'Length',
116
+ minimum: 0,
117
+ maximum: 65535,
118
+ decode: () => {
119
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
120
+ },
121
+ encode: () => {
122
+ const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
123
+ this.writeBytes(3, length);
124
+ }
125
+ },
126
+ appData: {
127
+ type: 'string',
128
+ label: 'Encrypted Application Data',
129
+ minimum: 0,
130
+ maximum: 65535,
131
+ decode: () => {
132
+ this.instance.appData.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(5, this.instance.length.getValue())));
133
+ },
134
+ encode: () => {
135
+ const appData = (0, HexToBuffer_1.HexToBuffer)(this.instance.appData.getValue('0', (nodePath) => this.recordError(nodePath, 'Not found')));
136
+ this.writeBytes(5, appData);
137
+ }
138
+ }
139
+ }
140
+ };
141
+ this.id = 'tls-appdata';
142
+ this.name = 'Transport Layer Security(Application Data Protocol)';
143
+ this.nickname = 'TLS';
144
+ }
145
+ match() {
146
+ if (!this.prevCodecModule)
147
+ return false;
148
+ if ((0, BufferToHex_1.BufferToHex)(this.readBytes(0, 1)) != '17')
149
+ return false;
150
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
151
+ const validVersions = [768, 769, 770, 771, 772];
152
+ return validVersions.includes(version);
153
+ }
154
+ }
155
+ exports.TLS_ApplicationData = TLS_ApplicationData;
@@ -0,0 +1,10 @@
1
+ import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ export declare class TLS_ChangeCipherSpec extends BaseHeader {
4
+ SCHEMA: ProtocolJSONSchema;
5
+ id: string;
6
+ name: string;
7
+ nickname: string;
8
+ match(): boolean;
9
+ }
10
+ //# sourceMappingURL=TLS_ChangeCipherSpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TLS_ChangeCipherSpec.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/TLS_ChangeCipherSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAclD,qBAAa,oBAAqB,SAAQ,UAAU;IACzC,MAAM,EAAE,kBAAkB,CAoHhC;IACM,EAAE,EAAE,MAAM,CAAa;IACvB,IAAI,EAAE,MAAM,CAAwD;IACpE,QAAQ,EAAE,MAAM,CAAQ;IAExB,KAAK,IAAI,OAAO;CAQ1B"}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TLS_ChangeCipherSpec = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToNumber_1 = require("../../helper/BufferToNumber");
6
+ const BufferToHex_1 = require("../../helper/BufferToHex");
7
+ const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
8
+ const HexToBuffer_1 = require("../../helper/HexToBuffer");
9
+ var TLSver;
10
+ (function (TLSver) {
11
+ TLSver["SSL_3_0"] = "SSL3.0";
12
+ TLSver["TLS_1_0"] = "TLS1.0";
13
+ TLSver["TLS_1_1"] = "TLS1.1";
14
+ TLSver["TLS_1_2"] = "TLS1.2";
15
+ TLSver["TLS_1_3"] = "TLS1.3";
16
+ })(TLSver || (TLSver = {}));
17
+ class TLS_ChangeCipherSpec extends BaseHeader_1.BaseHeader {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.SCHEMA = {
21
+ type: 'object',
22
+ properties: {
23
+ contentType: {
24
+ type: 'integer',
25
+ label: 'Content Type',
26
+ minimum: 0,
27
+ maximum: 255,
28
+ decode: () => {
29
+ this.instance.contentType.setValue((0, BufferToNumber_1.BufferToInt8)(this.readBytes(0, 1)));
30
+ },
31
+ encode: () => {
32
+ const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
33
+ this.writeBytes(0, contentType);
34
+ }
35
+ },
36
+ version: {
37
+ type: 'string',
38
+ label: 'Legacy Version',
39
+ minimum: 0,
40
+ maximum: 65535,
41
+ decode: () => {
42
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
43
+ switch (version) {
44
+ case 768:
45
+ {
46
+ this.instance.version.setValue(TLSver.SSL_3_0);
47
+ }
48
+ break;
49
+ case 769:
50
+ {
51
+ this.instance.version.setValue(TLSver.TLS_1_0);
52
+ }
53
+ break;
54
+ case 770:
55
+ {
56
+ this.instance.version.setValue(TLSver.TLS_1_1);
57
+ }
58
+ break;
59
+ case 771:
60
+ {
61
+ this.instance.version.setValue(TLSver.TLS_1_2);
62
+ }
63
+ break;
64
+ case 772:
65
+ {
66
+ this.instance.version.setValue(TLSver.TLS_1_3);
67
+ }
68
+ break;
69
+ default: {
70
+ this.instance.version.setValue('0');
71
+ }
72
+ }
73
+ },
74
+ encode: () => {
75
+ const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not found'));
76
+ switch (version) {
77
+ case TLSver.SSL_3_0:
78
+ {
79
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(768);
80
+ this.writeBytes(1, version);
81
+ }
82
+ break;
83
+ case TLSver.TLS_1_0:
84
+ {
85
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(769);
86
+ this.writeBytes(1, version);
87
+ }
88
+ break;
89
+ case TLSver.TLS_1_1:
90
+ {
91
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(770);
92
+ this.writeBytes(1, version);
93
+ }
94
+ break;
95
+ case TLSver.TLS_1_2:
96
+ {
97
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(771);
98
+ this.writeBytes(1, version);
99
+ }
100
+ break;
101
+ case TLSver.TLS_1_3:
102
+ {
103
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(772);
104
+ this.writeBytes(1, version);
105
+ }
106
+ break;
107
+ default: {
108
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
109
+ }
110
+ }
111
+ }
112
+ },
113
+ length: {
114
+ type: 'integer',
115
+ label: 'Length',
116
+ minimum: 0,
117
+ maximum: 65535,
118
+ decode: () => {
119
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
120
+ },
121
+ encode: () => {
122
+ const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
123
+ this.writeBytes(3, length);
124
+ }
125
+ },
126
+ change_cipher_spec_message: {
127
+ type: 'string',
128
+ label: 'Change Cipher Spec Message',
129
+ decode: () => {
130
+ const length = this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found'));
131
+ this.instance.change_cipher_spec_message.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(5, length)));
132
+ },
133
+ encode: () => {
134
+ const message = (0, HexToBuffer_1.HexToBuffer)(this.instance.change_cipher_spec_message.getValue('0', (nodePath) => this.recordError(nodePath, 'Not found')));
135
+ this.writeBytes(5, message);
136
+ }
137
+ }
138
+ }
139
+ };
140
+ this.id = 'tls-ccsp';
141
+ this.name = 'Transport Layer Security(ChangeCipherSpec Protocol)';
142
+ this.nickname = 'TLS';
143
+ }
144
+ match() {
145
+ if (!this.prevCodecModule)
146
+ return false;
147
+ if ((0, BufferToHex_1.BufferToHex)(this.readBytes(0, 1)) != '14')
148
+ return false;
149
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
150
+ const validVersions = [768, 769, 770, 771, 772];
151
+ return validVersions.includes(version);
152
+ }
153
+ }
154
+ exports.TLS_ChangeCipherSpec = TLS_ChangeCipherSpec;
@@ -0,0 +1,10 @@
1
+ import { ProtocolJSONSchema } from '../../schema/ProtocolJSONSchema';
2
+ import { BaseHeader } from '../abstracts/BaseHeader';
3
+ export declare class TLS_Handshake extends BaseHeader {
4
+ SCHEMA: ProtocolJSONSchema;
5
+ id: string;
6
+ name: string;
7
+ nickname: string;
8
+ match(): boolean;
9
+ }
10
+ //# sourceMappingURL=TLS_Handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TLS_Handshake.d.ts","sourceRoot":"","sources":["../../../../src/lib/codec/headers/TLS_Handshake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAA;AAkClD,qBAAa,aAAc,SAAQ,UAAU;IAClC,MAAM,EAAE,kBAAkB,CAuQhC;IACM,EAAE,EAAE,MAAM,CAAkB;IAC5B,IAAI,EAAE,MAAM,CAAiD;IAC7D,QAAQ,EAAE,MAAM,CAAQ;IAExB,KAAK,IAAI,OAAO;CAQ1B"}
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TLS_Handshake = void 0;
4
+ const BaseHeader_1 = require("../abstracts/BaseHeader");
5
+ const BufferToNumber_1 = require("../../helper/BufferToNumber");
6
+ const BufferToHex_1 = require("../../helper/BufferToHex");
7
+ const NumberToBuffer_1 = require("../../helper/NumberToBuffer");
8
+ const HexToBuffer_1 = require("../../helper/HexToBuffer");
9
+ var TLSver;
10
+ (function (TLSver) {
11
+ TLSver["SSL_3_0"] = "SSL3.0";
12
+ TLSver["TLS_1_0"] = "TLS1.0";
13
+ TLSver["TLS_1_1"] = "TLS1.1";
14
+ TLSver["TLS_1_2"] = "TLS1.2";
15
+ TLSver["TLS_1_3"] = "TLS1.3";
16
+ })(TLSver || (TLSver = {}));
17
+ var HandshakeType;
18
+ (function (HandshakeType) {
19
+ HandshakeType["Handshake_1"] = "HelloRequest";
20
+ HandshakeType["Handshake_2"] = "ClientHello";
21
+ HandshakeType["Handshake_3"] = "ServerHello";
22
+ HandshakeType["Handshake_4"] = "NewSessionTicket";
23
+ HandshakeType["Handshake_5"] = "EncryptedExtensions";
24
+ HandshakeType["Handshake_6"] = "Certificate";
25
+ HandshakeType["Handshake_7"] = "ServerKeyExchange";
26
+ HandshakeType["Handshake_8"] = "CertificateRequest";
27
+ HandshakeType["Handshake_9"] = "ServerHelloDone";
28
+ HandshakeType["Handshake_10"] = "CertificateVerify";
29
+ HandshakeType["Handshake_11"] = "ClientKeyExchange";
30
+ HandshakeType["Handshake_12"] = "Finished";
31
+ })(HandshakeType || (HandshakeType = {}));
32
+ class TLS_Handshake extends BaseHeader_1.BaseHeader {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.SCHEMA = {
36
+ type: 'object',
37
+ properties: {
38
+ contentType: {
39
+ type: 'integer',
40
+ label: 'Content Type',
41
+ minimum: 0,
42
+ maximum: 255,
43
+ decode: () => {
44
+ this.instance.contentType.setValue((0, BufferToNumber_1.BufferToInt8)(this.readBytes(0, 1)));
45
+ },
46
+ encode: () => {
47
+ const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
48
+ this.writeBytes(0, contentType);
49
+ }
50
+ },
51
+ version: {
52
+ type: 'string',
53
+ label: 'Legacy Version',
54
+ minimum: 0,
55
+ maximum: 65535,
56
+ decode: () => {
57
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
58
+ switch (version) {
59
+ case 768:
60
+ {
61
+ this.instance.version.setValue(TLSver.SSL_3_0);
62
+ }
63
+ break;
64
+ case 769:
65
+ {
66
+ this.instance.version.setValue(TLSver.TLS_1_0);
67
+ }
68
+ break;
69
+ case 770:
70
+ {
71
+ this.instance.version.setValue(TLSver.TLS_1_1);
72
+ }
73
+ break;
74
+ case 771:
75
+ {
76
+ this.instance.version.setValue(TLSver.TLS_1_2);
77
+ }
78
+ break;
79
+ case 772:
80
+ {
81
+ this.instance.version.setValue(TLSver.TLS_1_3);
82
+ }
83
+ break;
84
+ default: {
85
+ this.instance.version.setValue('0');
86
+ }
87
+ }
88
+ },
89
+ encode: () => {
90
+ const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not found'));
91
+ switch (version) {
92
+ case TLSver.SSL_3_0:
93
+ {
94
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(768);
95
+ this.writeBytes(1, version);
96
+ }
97
+ break;
98
+ case TLSver.TLS_1_0:
99
+ {
100
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(769);
101
+ this.writeBytes(1, version);
102
+ }
103
+ break;
104
+ case TLSver.TLS_1_1:
105
+ {
106
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(770);
107
+ this.writeBytes(1, version);
108
+ }
109
+ break;
110
+ case TLSver.TLS_1_2:
111
+ {
112
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(771);
113
+ this.writeBytes(1, version);
114
+ }
115
+ break;
116
+ case TLSver.TLS_1_3:
117
+ {
118
+ const version = (0, NumberToBuffer_1.UInt16ToBuffer)(772);
119
+ this.writeBytes(1, version);
120
+ }
121
+ break;
122
+ default: {
123
+ this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
124
+ }
125
+ }
126
+ }
127
+ },
128
+ length: {
129
+ type: 'integer',
130
+ label: 'Length',
131
+ minimum: 0,
132
+ maximum: 65535,
133
+ decode: () => {
134
+ this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
135
+ },
136
+ encode: () => {
137
+ const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
138
+ this.writeBytes(3, length);
139
+ }
140
+ },
141
+ handshakeType: {
142
+ type: 'string',
143
+ label: 'Handshake Type',
144
+ minimum: 0,
145
+ maximum: 65535,
146
+ decode: () => {
147
+ const handshakeType = (0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1));
148
+ switch (handshakeType) {
149
+ case 0:
150
+ {
151
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_1);
152
+ }
153
+ break;
154
+ case 1:
155
+ {
156
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_2);
157
+ }
158
+ break;
159
+ case 2:
160
+ {
161
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_3);
162
+ }
163
+ break;
164
+ case 4:
165
+ {
166
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_4);
167
+ }
168
+ break;
169
+ case 8:
170
+ {
171
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_5);
172
+ }
173
+ break;
174
+ case 11:
175
+ {
176
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_6);
177
+ }
178
+ break;
179
+ case 12:
180
+ {
181
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_7);
182
+ }
183
+ break;
184
+ case 13:
185
+ {
186
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_8);
187
+ }
188
+ break;
189
+ case 14:
190
+ {
191
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_9);
192
+ }
193
+ break;
194
+ case 15:
195
+ {
196
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_10);
197
+ }
198
+ break;
199
+ case 16:
200
+ {
201
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_11);
202
+ }
203
+ break;
204
+ case 20:
205
+ {
206
+ this.instance.handshakeType.setValue(HandshakeType.Handshake_12);
207
+ }
208
+ break;
209
+ default: {
210
+ this.instance.handshakeType.setValue((0, BufferToNumber_1.BufferToUInt8)(this.readBytes(5, 1)));
211
+ }
212
+ }
213
+ },
214
+ encode: () => {
215
+ const handshakeType = this.instance.handshakeType.getValue('0');
216
+ switch (handshakeType) {
217
+ case HandshakeType.Handshake_1:
218
+ {
219
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(0);
220
+ this.writeBytes(5, handshakeType);
221
+ }
222
+ break;
223
+ case HandshakeType.Handshake_2:
224
+ {
225
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(1);
226
+ this.writeBytes(5, handshakeType);
227
+ }
228
+ break;
229
+ case HandshakeType.Handshake_3:
230
+ {
231
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(2);
232
+ this.writeBytes(5, handshakeType);
233
+ }
234
+ break;
235
+ case HandshakeType.Handshake_4:
236
+ {
237
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(4);
238
+ this.writeBytes(5, handshakeType);
239
+ }
240
+ break;
241
+ case HandshakeType.Handshake_5:
242
+ {
243
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(8);
244
+ this.writeBytes(5, handshakeType);
245
+ }
246
+ break;
247
+ case HandshakeType.Handshake_6:
248
+ {
249
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(11);
250
+ this.writeBytes(5, handshakeType);
251
+ }
252
+ break;
253
+ case HandshakeType.Handshake_7:
254
+ {
255
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(12);
256
+ this.writeBytes(5, handshakeType);
257
+ }
258
+ break;
259
+ case HandshakeType.Handshake_8:
260
+ {
261
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(13);
262
+ this.writeBytes(5, handshakeType);
263
+ }
264
+ break;
265
+ case HandshakeType.Handshake_9:
266
+ {
267
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(14);
268
+ this.writeBytes(5, handshakeType);
269
+ }
270
+ break;
271
+ case HandshakeType.Handshake_10:
272
+ {
273
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(15);
274
+ this.writeBytes(5, handshakeType);
275
+ }
276
+ break;
277
+ case HandshakeType.Handshake_11:
278
+ {
279
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(16);
280
+ this.writeBytes(5, handshakeType);
281
+ }
282
+ break;
283
+ case HandshakeType.Handshake_12:
284
+ {
285
+ const handshakeType = (0, NumberToBuffer_1.UInt8ToBuffer)(20);
286
+ this.writeBytes(5, handshakeType);
287
+ }
288
+ break;
289
+ default: {
290
+ const handshakeType1 = parseInt(handshakeType);
291
+ this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(handshakeType1));
292
+ }
293
+ }
294
+ }
295
+ },
296
+ handshakeLength: {
297
+ type: 'integer',
298
+ label: 'Length',
299
+ minimum: 0,
300
+ maximum: 1118481,
301
+ decode: () => {
302
+ this.instance.handshakeLength.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(6, 3)));
303
+ },
304
+ encode: () => {
305
+ const length1 = (this.instance.handshakeLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
306
+ const length2 = length1.toString(16).padStart(6, '0');
307
+ const length3 = (0, HexToBuffer_1.HexToBuffer)(length2);
308
+ this.writeBytes(6, length3);
309
+ }
310
+ },
311
+ messagedata: {
312
+ type: 'string',
313
+ label: 'Messagedata',
314
+ decode: () => {
315
+ const length = (this.instance.handshakeLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not found')));
316
+ this.instance.messagedata.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(9, length)));
317
+ },
318
+ encode: () => {
319
+ const message = (0, HexToBuffer_1.HexToBuffer)(this.instance.messagedata.getValue('0', (nodePath) => this.recordError(nodePath, 'Not found')));
320
+ this.writeBytes(9, message);
321
+ }
322
+ }
323
+ }
324
+ };
325
+ this.id = 'tls-handshake';
326
+ this.name = 'Transport Layer Security(Handshake Protocol)';
327
+ this.nickname = 'TLS';
328
+ }
329
+ match() {
330
+ if (!this.prevCodecModule)
331
+ return false;
332
+ if ((0, BufferToHex_1.BufferToHex)(this.readBytes(0, 1)) != '16')
333
+ return false;
334
+ const version = (0, BufferToNumber_1.BufferToUInt16)(this.readBytes(1, 2));
335
+ const validVersions = [768, 769, 770, 771, 772];
336
+ return validVersions.includes(version);
337
+ }
338
+ }
339
+ exports.TLS_Handshake = TLS_Handshake;