/src/wireshark/epan/dissectors/packet-nist-csor.c
Line | Count | Source |
1 | | /* Do not modify this file. Changes will be overwritten. */ |
2 | | /* Generated automatically by the ASN.1 to Wireshark dissector compiler */ |
3 | | /* packet-nist-csor.c */ |
4 | | /* asn2wrs.py -b -q -L -p nist-csor -c ./nist-csor.cnf -s ./packet-nist-csor-template -D . -O ../.. aes1.asn */ |
5 | | |
6 | | /* packet-nist-csor.c |
7 | | * |
8 | | * Wireshark - Network traffic analyzer |
9 | | * By Gerald Combs <gerald@wireshark.org> |
10 | | * Copyright 1998 Gerald Combs |
11 | | * |
12 | | * SPDX-License-Identifier: GPL-2.0-or-later |
13 | | */ |
14 | | |
15 | | #include "config.h" |
16 | | |
17 | | #include <epan/packet.h> |
18 | | #include <epan/oids.h> |
19 | | #include <epan/asn1.h> |
20 | | #include <wsutil/array.h> |
21 | | |
22 | | #include "packet-nist-csor.h" |
23 | | #include "packet-ber.h" |
24 | | #include "packet-pkix1explicit.h" |
25 | | #include "packet-pkix1implicit.h" |
26 | | |
27 | 14 | #define PNAME "NIST_CSOR" |
28 | 14 | #define PSNAME "NIST_CSOR" |
29 | 14 | #define PFNAME "nist_csor" |
30 | | |
31 | | void proto_register_nist_csor(void); |
32 | | void proto_reg_handoff_nist_csor(void); |
33 | | |
34 | | /* Initialize the protocol and registered fields */ |
35 | | static int proto_nist_csor; |
36 | | static int hf_nist_csor_CFBParameters_PDU; /* CFBParameters */ |
37 | | static int hf_nist_csor_AES_IV_PDU; /* AES_IV */ |
38 | | static int hf_nist_csor_ShakeOutputLen_PDU; /* ShakeOutputLen */ |
39 | | static int hf_nist_csor_aes_IV; /* AES_IV */ |
40 | | static int hf_nist_csor_numberOfBits; /* NumberOfBits */ |
41 | | |
42 | | /* Initialize the subtree pointers */ |
43 | | static int ett_nist_csor_CFBParameters; |
44 | | |
45 | | |
46 | | unsigned |
47 | 0 | dissect_nist_csor_AES_IV(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
48 | 0 | offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset, |
49 | 0 | 16, 16, hf_index, NULL); |
50 | |
|
51 | 0 | return offset; |
52 | 0 | } |
53 | | |
54 | | |
55 | | |
56 | | unsigned |
57 | 0 | dissect_nist_csor_NumberOfBits(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
58 | 0 | offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset, |
59 | 0 | 1U, 128U, hf_index, NULL); |
60 | |
|
61 | 0 | return offset; |
62 | 0 | } |
63 | | |
64 | | |
65 | | static const ber_sequence_t CFBParameters_sequence[] = { |
66 | | { &hf_nist_csor_aes_IV , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_nist_csor_AES_IV }, |
67 | | { &hf_nist_csor_numberOfBits, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_nist_csor_NumberOfBits }, |
68 | | { NULL, 0, 0, 0, NULL } |
69 | | }; |
70 | | |
71 | | unsigned |
72 | 0 | dissect_nist_csor_CFBParameters(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
73 | 0 | offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, |
74 | 0 | CFBParameters_sequence, hf_index, ett_nist_csor_CFBParameters); |
75 | |
|
76 | 0 | return offset; |
77 | 0 | } |
78 | | |
79 | | |
80 | | |
81 | | unsigned |
82 | 0 | dissect_nist_csor_ShakeOutputLen(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
83 | 0 | offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, |
84 | 0 | NULL); |
85 | |
|
86 | 0 | return offset; |
87 | 0 | } |
88 | | |
89 | | /*--- PDUs ---*/ |
90 | | |
91 | 0 | static int dissect_CFBParameters_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
92 | 0 | unsigned offset = 0; |
93 | 0 | asn1_ctx_t asn1_ctx; |
94 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
95 | 0 | offset = dissect_nist_csor_CFBParameters(false, tvb, offset, &asn1_ctx, tree, hf_nist_csor_CFBParameters_PDU); |
96 | 0 | return offset; |
97 | 0 | } |
98 | 0 | static int dissect_AES_IV_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
99 | 0 | unsigned offset = 0; |
100 | 0 | asn1_ctx_t asn1_ctx; |
101 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
102 | 0 | offset = dissect_nist_csor_AES_IV(false, tvb, offset, &asn1_ctx, tree, hf_nist_csor_AES_IV_PDU); |
103 | 0 | return offset; |
104 | 0 | } |
105 | 0 | static int dissect_ShakeOutputLen_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
106 | 0 | unsigned offset = 0; |
107 | 0 | asn1_ctx_t asn1_ctx; |
108 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
109 | 0 | offset = dissect_nist_csor_ShakeOutputLen(false, tvb, offset, &asn1_ctx, tree, hf_nist_csor_ShakeOutputLen_PDU); |
110 | 0 | return offset; |
111 | 0 | } |
112 | | |
113 | | |
114 | | |
115 | | /*--- proto_register_nist-csor ----------------------------------------------*/ |
116 | 14 | void proto_register_nist_csor(void) { |
117 | | |
118 | | /* List of fields */ |
119 | 14 | static hf_register_info hf[] = { |
120 | 14 | { &hf_nist_csor_CFBParameters_PDU, |
121 | 14 | { "CFBParameters", "nist-csor.CFBParameters_element", |
122 | 14 | FT_NONE, BASE_NONE, NULL, 0, |
123 | 14 | NULL, HFILL }}, |
124 | 14 | { &hf_nist_csor_AES_IV_PDU, |
125 | 14 | { "AES-IV", "nist-csor.AES_IV", |
126 | 14 | FT_BYTES, BASE_NONE, NULL, 0, |
127 | 14 | NULL, HFILL }}, |
128 | 14 | { &hf_nist_csor_ShakeOutputLen_PDU, |
129 | 14 | { "ShakeOutputLen", "nist-csor.ShakeOutputLen", |
130 | 14 | FT_INT32, BASE_DEC, NULL, 0, |
131 | 14 | NULL, HFILL }}, |
132 | 14 | { &hf_nist_csor_aes_IV, |
133 | 14 | { "aes-IV", "nist-csor.aes_IV", |
134 | 14 | FT_BYTES, BASE_NONE, NULL, 0, |
135 | 14 | NULL, HFILL }}, |
136 | 14 | { &hf_nist_csor_numberOfBits, |
137 | 14 | { "numberOfBits", "nist-csor.numberOfBits", |
138 | 14 | FT_UINT32, BASE_DEC, NULL, 0, |
139 | 14 | NULL, HFILL }}, |
140 | 14 | }; |
141 | | |
142 | | /* List of subtrees */ |
143 | 14 | static int *ett[] = { |
144 | 14 | &ett_nist_csor_CFBParameters, |
145 | 14 | }; |
146 | | |
147 | | /* Register protocol */ |
148 | 14 | proto_nist_csor = proto_register_protocol(PNAME, PSNAME, PFNAME); |
149 | | |
150 | | /* Register fields and subtrees */ |
151 | 14 | proto_register_field_array(proto_nist_csor, hf, array_length(hf)); |
152 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
153 | 14 | } |
154 | | |
155 | | |
156 | | /*--- proto_reg_handoff_nist_csor -------------------------------------------*/ |
157 | 14 | void proto_reg_handoff_nist_csor(void) { |
158 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.2", dissect_AES_IV_PDU, proto_nist_csor, "id-aes128-CBC"); |
159 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.3", dissect_AES_IV_PDU, proto_nist_csor, "id-aes128-OFB"); |
160 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.4", dissect_CFBParameters_PDU, proto_nist_csor, "id-aes128-CFB"); |
161 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.22", dissect_AES_IV_PDU, proto_nist_csor, "id-aes192-CBC"); |
162 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.23", dissect_AES_IV_PDU, proto_nist_csor, "id-aes192-OFB"); |
163 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.24", dissect_CFBParameters_PDU, proto_nist_csor, "id-aes192-CFB"); |
164 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.42", dissect_AES_IV_PDU, proto_nist_csor, "id-aes256-CBC"); |
165 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.43", dissect_AES_IV_PDU, proto_nist_csor, "id-aes256-OFB"); |
166 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.44", dissect_CFBParameters_PDU, proto_nist_csor, "id-aes256-CFB"); |
167 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.2.17", dissect_ShakeOutputLen_PDU, proto_nist_csor, "id-shake128-len"); |
168 | 14 | register_ber_oid_dissector("2.16.840.1.101.3.4.2.18", dissect_ShakeOutputLen_PDU, proto_nist_csor, "id-shake256-len"); |
169 | | |
170 | 14 | oid_add_from_string("id-data","1.2.840.113549.1.7.1"); |
171 | | |
172 | | /* AES */ |
173 | 14 | oid_add_from_string("aes","2.16.840.1.101.3.4.1"); |
174 | | |
175 | | /* 128-bit AES information OIDs */ |
176 | 14 | oid_add_from_string("id-aes128-ECB","2.16.840.1.101.3.4.1.1"); |
177 | 14 | oid_add_from_string("id-aes128-wrap","2.16.840.1.101.3.4.1.5"); |
178 | 14 | oid_add_from_string("id-aes128-GCM","2.16.840.1.101.3.4.1.6"); |
179 | 14 | oid_add_from_string("id-aes128-CCM","2.16.840.1.101.3.4.1.7"); |
180 | 14 | oid_add_from_string("id-aes128-wrap-pad","2.16.840.1.101.3.4.1.8"); |
181 | | |
182 | | /* 192-bit AES information OIDs */ |
183 | 14 | oid_add_from_string("id-aes192-ECB","2.16.840.1.101.3.4.1.21"); |
184 | 14 | oid_add_from_string("id-aes192-wrap","2.16.840.1.101.3.4.1.25"); |
185 | 14 | oid_add_from_string("id-aes192-GCM","2.16.840.1.101.3.4.1.26"); |
186 | 14 | oid_add_from_string("id-aes192-CCM","2.16.840.1.101.3.4.1.27"); |
187 | 14 | oid_add_from_string("id-aes192-wrap-pad","2.16.840.1.101.3.4.1.28"); |
188 | | |
189 | | /* 256-bit AES information OIDs */ |
190 | 14 | oid_add_from_string("id-aes256-ECB","2.16.840.1.101.3.4.1.41"); |
191 | 14 | oid_add_from_string("id-aes256-wrap","2.16.840.1.101.3.4.1.45"); |
192 | 14 | oid_add_from_string("id-aes256-GCM","2.16.840.1.101.3.4.1.46"); |
193 | 14 | oid_add_from_string("id-aes256-CCM","2.16.840.1.101.3.4.1.47"); |
194 | 14 | oid_add_from_string("id-aes256-wrap-pad","2.16.840.1.101.3.4.1.48"); |
195 | | |
196 | | /* Secure Hash Algorithms */ |
197 | 14 | oid_add_from_string("hashAlgs","2.16.840.1.101.3.4.2"); |
198 | | |
199 | | /* SHA-2 family */ |
200 | 14 | oid_add_from_string("id-sha256","2.16.840.1.101.3.4.2.1"); |
201 | 14 | oid_add_from_string("id-sha384","2.16.840.1.101.3.4.2.2"); |
202 | 14 | oid_add_from_string("id-sha512","2.16.840.1.101.3.4.2.3"); |
203 | 14 | oid_add_from_string("id-sha224","2.16.840.1.101.3.4.2.4"); |
204 | 14 | oid_add_from_string("id-sha512-224","2.16.840.1.101.3.4.2.5"); |
205 | 14 | oid_add_from_string("id-sha512-256","2.16.840.1.101.3.4.2.6"); |
206 | | |
207 | | /* SHA-3 family */ |
208 | 14 | oid_add_from_string("id-sha3-224","2.16.840.1.101.3.4.2.7"); |
209 | 14 | oid_add_from_string("id-sha3-256","2.16.840.1.101.3.4.2.8"); |
210 | 14 | oid_add_from_string("id-sha3-384","2.16.840.1.101.3.4.2.9"); |
211 | 14 | oid_add_from_string("id-sha3-512","2.16.840.1.101.3.4.2.10"); |
212 | | |
213 | 14 | oid_add_from_string("id-shake128","2.16.840.1.101.3.4.2.11"); |
214 | 14 | oid_add_from_string("id-shake256","2.16.840.1.101.3.4.2.12"); |
215 | | |
216 | | /* HMAC with SHA-3 family */ |
217 | 14 | oid_add_from_string("id-hmacWithSHA3-224","2.16.840.1.101.3.4.2.13"); |
218 | 14 | oid_add_from_string("id-hmacWithSHA3-256","2.16.840.1.101.3.4.2.14"); |
219 | 14 | oid_add_from_string("id-hmacWithSHA3-384","2.16.840.1.101.3.4.2.15"); |
220 | 14 | oid_add_from_string("id-hmacWithSHA3-512","2.16.840.1.101.3.4.2.16"); |
221 | | |
222 | | /* Digital Signature Algorithms */ |
223 | 14 | oid_add_from_string("sigAlgs","2.16.840.1.101.3.4.3"); |
224 | | |
225 | | /* DSA with SHA-2 family */ |
226 | 14 | oid_add_from_string("id-dsa-with-sha224","2.16.840.1.101.3.4.3.1"); |
227 | 14 | oid_add_from_string("id-dsa-with-sha256","2.16.840.1.101.3.4.3.2"); |
228 | 14 | oid_add_from_string("id-dsa-with-sha384","2.16.840.1.101.3.4.3.3"); |
229 | 14 | oid_add_from_string("id-dsa-with-sha512","2.16.840.1.101.3.4.3.4"); |
230 | | |
231 | | /* DSA with SHA-3 family */ |
232 | 14 | oid_add_from_string("id-dsa-with-sha3-224","2.16.840.1.101.3.4.3.5"); |
233 | 14 | oid_add_from_string("id-dsa-with-sha3-256","2.16.840.1.101.3.4.3.6"); |
234 | 14 | oid_add_from_string("id-dsa-with-sha3-384","2.16.840.1.101.3.4.3.7"); |
235 | 14 | oid_add_from_string("id-dsa-with-sha3-512","2.16.840.1.101.3.4.3.8"); |
236 | | |
237 | | /* ECDSA with SHA-3 family */ |
238 | 14 | oid_add_from_string("id-ecdsa-with-sha3-224","2.16.840.1.101.3.4.3.9"); |
239 | 14 | oid_add_from_string("id-ecdsa-with-sha3-256","2.16.840.1.101.3.4.3.10"); |
240 | 14 | oid_add_from_string("id-ecdsa-with-sha3-384","2.16.840.1.101.3.4.3.11"); |
241 | 14 | oid_add_from_string("id-ecdsa-with-sha3-512","2.16.840.1.101.3.4.3.12"); |
242 | | |
243 | | /* RSA PKCS#1 v1.5 Signature with SHA-3 family */ |
244 | 14 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-224","2.16.840.1.101.3.4.3.13"); |
245 | 14 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-256","2.16.840.1.101.3.4.3.14"); |
246 | 14 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-384","2.16.840.1.101.3.4.3.15"); |
247 | 14 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-512","2.16.840.1.101.3.4.3.16"); |
248 | 14 | } |